Creating your own glpyhs and reading in elements with different nodes in
different fields.
Jason Mathews NASA/Goddard Space Flight Center.
I got the model from the UK VR-SIG 3D
Object Archive
#Example a/biplane.
#Loading in your own glyph
#Create materials for the wheels and propeller
gfx create material wheels ambient 0 0 0 diffuse 0.22 0.28 0.22 emission 0 0 0 specular 1 1 1 alpha 1 shininess 0.84
gfx create material propeller ambient 0.72 0.17 0 diffuse 0.5 0 0 emission 0 0 0 specular 0 0 0 alpha 1 shininess 0
gfx create material plane ambient 0.5 0.8 0.5 diffuse 0.5 0.8 0.0 emission 0 0 0 specular 0.4 0.9 0.0 alpha 1 shininess 0.7
#Read in the wavefront file as a graphics object. If your
#wavefront obj file contains material definitions then these
#will always override the material selected in the graphical
#element. This allows mixed material glyphs which still vary
#according to a spectrum. In this example the main body of
#the plane is left up to the spectrum but the propeller and
#wheels are the same for every plane.
gfx read wavefront as biplane $example/biplane.obj
#instead you can draw the glyph using static graphic
gfx modify g_element "/" point glyph biplane
gfx create window hangar
#Write out the VRML2 description of the biplane. The scene
#parameter allows you to specify a subpart of a scene using
#the dot operator to reference components.
gfx export vrml file biplane.wrl
#Don't draw static graphic version of biplane any more
gfx modify g_element "/" point glyph biplane delete
#Put the biplane into the glyph object list, if you now draw
#node_points or element_points as below or using the
#graphical element editor the glyph "biplane" will be available
#in the chooser. By choosing the
gfx modify glyph biplane material none
#Read in the exnode and exelem version of this file
#The texture coordinates and coordinates are defined seperately
#in the obj format and so each element interpolates different
#nodes for each field. Generated from the obj using obj2ex.
gfx read nodes $example/biplane.exnode
gfx read elements $example/biplane.exelem
#Define the lines of the plane as they aren't in the file
gfx define faces egroup biplane
#View the model
gfx modify g_element "/" general clear;
gfx modify g_element biplane general clear;
gfx modify g_element biplane lines material default;
gfx mod win hangar image view_all
#Read in the wavefront file as a graphics object at other times. Note: this feature has been removed on cmgui version3.1
#gfx read wavefront as biplane $example/biplane2.obj time 1
#gfx read wavefront as biplane $example/biplane3.obj time 2
gfx read wavefront as biplane $example/biplane3.obj
gfx timekeeper default minimum 0 maximum 3 speed 8 skip_frames
#Draw points at every node and biplanes at those you have selected
#The biplanes are coloured according to the spectrum and the number of
#the node they represent.
gfx modify spectrum default clear overwrite_colour
gfx modify spectrum default linear reverse range 1 900 extend_above extend_below rainbow colour_range 0 1 ambient diffuse component 1
gfx modify g_element biplane node_points glyph point size "0.1*0.1*0.1" centre 0,0,0 select_on material default selected_material default_selected
gfx define field plane_direction coordinate_system rectangular_cartesian scale field coordinates scale_factors -1 -1 -1
gfx modify g_element biplane node_points glyph biplane size "0.2*0.2*0.2" centre 0,0,0 orientation plane_direction scale_factors "0*0*0" draw_selected material plane data cmiss_number spectrum default selected_material default_selected
#Write out the VRML2 description of the biplane. The scene
#parameter allows you to specify a subpart of a scene using
#the dot operator to reference components, the subset now
#refers to the graphical_element_group. Select just one
#node so that vrml2 output isn't too large.
gfx select nodes 45
gfx export vrml file biplane2.wrl scene default
#Select a few points using the node_tool,
#selecting too many will make the model take too long to draw.
gfx select nodes 45,48,126,318,329,366,478,492,541,667,745,749
#Set the propellers spinning
#gfx timekeeper default play