Get from Ico-github-logo

Highlights from
Export figure to 3D interactive PDF

  • [strmodelshading, strface...
  • check_file_extension(fnam...
    See also CLEAR_FILE_EXTENSION, ISFILEXTENSION.
  • clear_file_extension(fnam...
    See also CHECK_FILE_EXTENSION, ISFILEXTENSION.
  • create_marker_lines(h, ty...
  • cut_line_to_pieces(x, npe...
  • doc_examples
  • draw_crystal_lattice
  • examples
  • fig2idtf(filename,...
    FIG2IDTF Save figure in IDTF format.
  • fig2latex(ax, fname, medi...
    FIG2LATEX Convert axes to U3D file, generating LaTeX code including it.
  • fig2pdf3d(ax, filename, m...
    FIG2PDF3D Convert axes to PDF with embedded interactive 3D image.
  • fig2u3d(ax, fname, imgtyp...
    FIG2U3D Convert figure to U3D file.
  • get_line_xyz(h)
  • get_quiver_data
  • heart3d
  • idtf2u3d(idtffile, u3dfile)
    IDTF2U3D Convert IDTF to U3D file.
  • idtf_model_nodes(n_meshes...
  • isfilextension(fname, ext...
    See also CHECK_FILE_EXTENSION, CLEAR_FILE_EXTENSION.
  • latex2pdf3d(fname, latex_...
    LATEX2PDF3D Compile LaTeX code to PDF.
  • line_pieces(vertices_all,...
    % See also u3d_pre_line, u3d_pre_contourgroup.
  • mesh_normals(points,faces)
    MESH_NORMALS compute mesh normals
  • populate_line_resource_st...
    % See also FACE_VERTEX_DATA_EQUALS_NPOINTS, VERBATIM.
  • populate_mesh_resource_st...
    % See also FACE_VERTEX_DATA_EQUALS_NPOINTS, MESH_NORMALS, VERBATIM.
  • populate_point_resource_s...
  • shaders_materials_modifie...
    File: shaders_materials_modifiers.m
  • single_mesh_resource_str(...
    % See also u3d_pre_patch.
  • test_hexagram_shape
  • u3d_in_latex(fname, media...
    U3D_IN_LATEX LaTeX code which includes a U3D file.
  • u3d_pre_contourgroup(ax)
    U3D_PRE_CONTOURGROUP Preprocess contour output to u3d.
  • u3d_pre_line(ax)
    U3D_PRE_LINE Preprocess line output to u3d.
  • u3d_pre_patch(ax)
    U3D_PRE_PATCH Preprocess surface output to u3d.
  • u3d_pre_quivergroup(ax)
    U3D_PRE_QUIVERGROUP Preprocess quiver output to u3d.
  • u3d_pre_surface(ax)
    U3D_PRE_SURFACE Preprocess surface output to u3d.
  • verbatim
    VERBATIM Get the text that appears in the next comment block.
  • view2vws(ax, filename, pa...
    VIE2VWS Saves current view in a views file for LaTeX media9 package.
  • test_fig2u3d_contour_surf.m
    function [] = test_fig2u3d_contour_surf
  • test_spiral.m
    function [] = test_fig2u3d_spiral
  • View all files
image thumbnail

Export figure to 3D interactive PDF

by

 

27 Jul 2012 (Updated )

Export figure as U3D file or directly to 3D interactive graphics within PDF.

populate_point_resource_str(points, colors, n_resources)
function [pointset_resources] = populate_point_resource_str(points, colors, n_resources)
%
% See also VERBATIM.
%
% File:      populate_point_resource_str.m
% Author:    Ioannis Filippidis, jfilippidis@gmail.com
% Date:      2012.06.14 - 
% Language:  MATLAB R2012a
% Purpose:   point resource strings
% Copyright: Ioannis Filippidis, 2012-

% depends
%   verbatim

n_pointsets = size(points, 2);
pnt_rc = cell(1, n_pointsets);
for i=1:n_pointsets
    cur_points = points{1, i};
    cur_color = colors{1, i};
    
    cur_resource = single_pointset_resource_str(cur_points, cur_color,...
                                                i, n_resources);
    
    pnt_rc{1, i} = ['\n\n', cur_resource];
end
pointset_resources = [pnt_rc{:} ];
%disp(pointset_resources)

function [line_resource_str] = single_pointset_resource_str(points, point_color,...
                                    pointset_id, n_resources)
str = pointset_resource_str;
npnt = size(points, 2);

resource_id = n_resources +pointset_id -1;

point_position_list = 0:(npnt-1);
point_normal_list = 0:(npnt-1);

point_position_list_str = sprintf('%d\n', point_position_list);
point_normal_list_str = sprintf('%d\n', point_normal_list);
point_shading_list_str = sprintf('%d\n', zeros(npnt, 1) );
point_diffuse_color_list_str = sprintf('%d\n', zeros(npnt, 1) );

model_position_list_str = sprintf('%1.6f %1.6f %1.6f\n', points);

model_normal_count = npnt;
model_normal_list_str = sprintf('%f %f %f\n', zeros(3, npnt) );

% fliplr is used because of a bug in IDTFConverter.exe
% which recognizes BGR instead of RGB
model_diffuse_color_list_str = sprintf('%f %f %f\n', fliplr(point_color) );

line_resource_str = sprintf(str,...
    resource_id, pointset_id, npnt,...
    npnt, model_normal_count,...
    point_position_list_str, point_normal_list_str,...
    point_shading_list_str, point_diffuse_color_list_str,...
    model_position_list_str, model_normal_list_str, model_diffuse_color_list_str);

function [str] = pointset_resource_str
% resource_id, pointset_id, point_count,
%
% model_position_count, model_normal_count,
%
% point_position_list, point_normal_list,
% point_shading_list, point_diffuse_color_list,
%
% model_position_list, model_normal_list, model_diffuse_color_list
str = verbatim;
%{

RESOURCE %d {
    RESOURCE_NAME "MyPoints%d"
    MODEL_TYPE "POINT_SET"
    POINT_SET {
        POINT_COUNT %d
        MODEL_POSITION_COUNT %d
        MODEL_NORMAL_COUNT %d
        MODEL_DIFFUSE_COLOR_COUNT 1
        MODEL_SPECULAR_COLOR_COUNT 0
        MODEL_TEXTURE_COORD_COUNT 0
        
        MODEL_SHADING_COUNT 1
        MODEL_SHADING_DESCRIPTION_LIST {
            SHADING_DESCRIPTION 0 {
                TEXTURE_LAYER_COUNT 0
                SHADER_ID 0
            }
        }
        POINT_POSITION_LIST {
            %s
        }
        POINT_NORMAL_LIST {
            %s
        }
        POINT_SHADING_LIST {
            %s
        }
        POINT_DIFFUSE_COLOR_LIST {
            %s
        }
        
        MODEL_POSITION_LIST {
            %s
        }
        MODEL_NORMAL_LIST {
            %s
        }
        MODEL_DIFFUSE_COLOR_LIST {
            %s
        }
    }
}

%}

Contact us