Point resource construction examplesΒΆ
Example 1: Create a basic Steno3D Point resource
pt = steno3d.core.Point;
verts = rand(100, 3);
mesh = steno3d.core.Mesh0D;
mesh.Vertices = verts;
pt.Mesh = mesh;
example1 = steno3d.core.Project;
example1.Resources = pt;
clear pt verts mesh;
Example 2: Create a Point resource and set display options
pt = steno3d.core.Point;
pt.Title = 'Example 2 Point';
pt.Description = 'This Point resource will be yellow';
mesh = steno3d.core.Mesh0D;
mesh.Vertices = rand(100, 3);
pt.Mesh = mesh;
pt.Opts.Color = 'y';
pt.Opts.Opacity = 0.75;
example2 = steno3d.core.Project;
example2.Title = 'Example 2';
example2.Description = 'Project with some points';
example2.Resources = pt;
clear pt mesh;
Example 3: Create a Point resource with node data
Note
This constructor encapsulates all the features of pt from Example 2.
verts = rand(100, 3);
pt = steno3d.core.Point( ...
'Title', 'Example 3 Point', ...
'Description', 'This Point resource will have data', ...
'Mesh', steno3d.core.Mesh0D( ...
'Vertices', verts ...
), ...
'Opts', {'Color', 'y', 'Opacity', 0.75} ...
);
xdata = steno3d.core.DataArray( ...
'Title', 'X-Values', ...
'Array', verts(:, 1) ...
);
pt.Data = {'Location', 'N', 'Data', xdata};
example3 = steno3d.core.Project( ...
'Title', 'Example 3', ...
'Description', 'Project with some points', ...
'Resources', pt ...
);
clear pt xdata verts;
Example 4: Create a Point resource with an image projected onto it
pt = steno3d.core.Point( ...
'Title', 'Example 4 Point', ...
'Description', 'This Point resource will have an image', ...
'Mesh', steno3d.core.Mesh0D( ...
'Vertices', rand(100, 3) ...
), ...
'Opts', {'Color', 'y', 'Opacity', 0.75} ...
);
pngFile = [tempname '.png'];
imwrite(imread('ngc6543a.jpg'), pngFile, 'png');
tex = steno3d.core.Texture2DImage( ...
'Image', pngFile, ...
'O', [0 0 0], ...
'U', [1 0 0], ...
'V', [0 1 0] ...
);
pt.Textures = tex;
example4 = steno3d.core.Project( ...
'Title', 'Example 4', ...
'Description', 'Project with some points', ...
'Resources', pt ...
);
clear pt tex pngFile;
Example 5: Create a Point resource with multiple datasets and textures
Note
There are several new features introduced in this highly consolidated construction. (1) Multiple datasets and textures are assigned as a cell array. (2) Passing cell arrays of parameters (e.g. for Mesh) implicitly calls the correct constructor. (3) Data Location is not specified since ‘N’ is the only available location for points. (4) The texture uses default values for O, U, and V, and attempts to coerce a JPG file to PNG.
verts = rand(100, 3);
pt = steno3d.core.Point( ...
'Title', 'Example 5 Point', ...
'Description', 'This Point resource will have data', ...
'Mesh', {'Vertices', verts}, ...
'Opts', {'Color', 'y', 'Opacity', 0.75}, ...
'Data', { ...
{'Data', {'Title', 'X-Data', 'Array', verts(:, 1)}}, ...
{'Data', {'Title', 'Y-Data', 'Array', verts(:, 2)}}, ...
{'Data', {'Title', 'Z-Data', 'Array', verts(:, 3)}} ...
}, ...
'Textures', { ...
{'Image', 'ngc6543a.jpg', 'U', [.5 0 0]}, ...
{'Image', 'ngc6543a.jpg', 'V', [0 .5 0]} ...
} ...
);
example5 = steno3d.core.Project( ...
'Title', 'Example 5', ...
'Description', 'Project with some points', ...
'Resources', pt ...
);
clear pt verts;
You can run the above examples with:
steno3d.examples.core.point
Then plot the projects with:
example1.plot(); % etc...
See also steno3d.core.Point, steno3d.core.Mesh0D, steno3d.core.Project, steno3d.core.DataArray, steno3d.core.Texture2DImage