370 likes | 1.16k Views
Shapes Properties Binding. 2001.08.14 Chung Ji Hye. Content. Use a variety of shapes in the scene Indexed shapes specify their own order Different effects for color values, shininess and transparency Render a scene using different drawing styles Create a scene with fog
E N D
Shapes Properties Binding 2001.08.14 Chung Ji Hye
Content • Use a variety of shapes in the scene • Indexed shapes specify their own order • Different effects for color values, shininess and transparency • Render a scene using different drawing styles • Create a scene with fog • Use the shape hints • Material and normal binding
Shapes • All shape nodes are derived from the abstract base class SoShape • Simple shape Complex shapes • CubeCube Face set • Cone Line set • Sphere Tirangle strip set • Cylinder Quad mesh
Complex Shapes[FaceSet] • SoFaceSet is a shape node • Represents a polygonal object • Current coordinates, normals, materials, textures • Uses the values within each node in the order they are given • SoIndexedFaceSet • Represents a polygonal object formed by constructing faces • Uses those values in any order • Contains four field
Complex Shapes[FaceSet] • Four Fields • coordIndex • Contains indices into the coordinates list • SO_END_FACE_INDEX(-1) • materialIndex • Contains indices into the current material for the materials of the face set • Use only when some type of indexed material binding is specified in the SoMaterialBinding node • NormalIndex • Contains indices into the current normals • SoNormalBindingnode • TextureCoordIndex • Contains indices of the texture coordinates
Complex Shapes • Triangle Strip Set • SoTriangleStripSet • constructs triangle strips out of the vertices • One of the fastest ways to draw polygonal object • Starting by startIndex field (in order) • Static long numvertices[2] ={32, 8}; SoTriangleStripSet *myStrips = new SoTriangleStripSet; myStrips->numbertices.setValues(0,2, numVertices); //32 triangle stripset, 8 triangle stripset //face 0 determined the vertex ordering
Triangle Strip Set Triangle Strip Set Example
Complex Shapes • Quad Mesh • SoQuadMesh • Constructs quadrilaterals from the vertices located at the current coordinates • Use the coordinates in order • Starting at the index specified by the startIndex field • verticesPerColume : number of vertices in the columns • VerticesPerRow : number of vertices in the rows
Complex Shapes • Examples • SoQuadMesh *myQuadMesh =new soQuadMesh; • myQuadMesh->verticesPerRow = 12 • myquadMesh ->VerticesPerColumn = 5 • Static float vertexPositions[160][3] = • { //1st row Each row in this quad mesh contains 12 vertices. Each column contains 5 vertices { } { } { } { } { } { } { } { } { } { } { } { } , // Add 11 rows };
Property Nodes • Property classes • SoMaterial • Sets ambient, diffuse, specular, emissive color, shininess, transparency • SoDrawStyle • Drawing technique to use during rendering • SolightModel • Shape nodes show to compute lighting calculations during rendering • SoEnvironment • Simulate various atmospheric effects (fog, haze, pollution…)
Property Nodes • Property classes • SoShapeHints • Additional information regarding vertex shapes to allow inventor to optimize certain rendering features • SoUnits • Define a standard unit of measurement for all subsequent shapes in the scene graph • All of which are derived from SoNode • Each of these classes affects different elements of the rendering state
Material Node • SoMaterial node includes the following fields • ambientColor(SoMFColor) • Reflected color of an object in response to the ambient lighting in the scene • diffuseColor • Object’s base color • specularColor • Reflective quality of an Object’s highlights
Material Node • SoMaterial node includes the following fields • emissiveColor • Light produced by an objcet • Shininess • Degree of shininess of an object’s surface • 0.0 : no shininess • Transparency • Degree of transparency of an object’s surface( 0.0 : opaque)
Material Node • Examples • //set material values • SoMaterial *Gold = new soMaterial; • Gold -> ambientColor.setValue(.3, .3, .1); • Gold ->diffuseColor.setValue(.8, .7, .2); • Gold ->specularcolor.setValue(.4, .3, .1); • Gold -> shininess = .4; • Gold -> transparency = .0; //gold is opaque
Draw Style Node • SoDrawStyle node include • Style • Current drawing style • SoDrawStyle::FILLED • Filled regions(default) • SoDrawStyle::LINES • Nonfilled outlines • SoDrawStyle::POINTS • Points • SoDrawStyle::INVISIBLE • Not drawn at all
Draw Style Node solid line point
Draw Style Node • SoDrawStyle node include • pointSize • radius of points, in printer’s points • 0.0 indicates to use the fastest value for rendering • lineWidth • Line width in printer’s points • Values can range from 0.0 to 256.0 • linePattern • Line-stipple pattern • Values can range from 0 to 0xffff
Light-Model Node • SoLightModel node includes field • Model • Tells the shape node how to compute lighting calculations during rendering • SoLightModel::BASE_COLOR • Ignore light source • Uses only diffuse color and transparency of the current material • SoLightModel::PHONG • Uses the OpenGL Phong lighting model • Account all light sources in the scene
Environment Node • SoEnvironment node • Simulate various atmospheric effects – fog, haze, pollution and so on • Allows you to specify color, intensity, ambient lighting, many factor for fog • Includes fields • ambientIntensity • intensity of ambient light in the screen • Used with phong lighting • attenuation • Defines how light drops off the distance from a light source • Used with phong lighting
Environment Node • SoEnvironment node • Includes fields • fogType • SoEnvironment::NONE • SoEnvironment::HAZE • Opacity of the fog Increases linearly with the distance from the camera • SoEnvironment::FOG • Opacity of the fog Increases exponentially with the distance from the camera • fogColor • Color of the fog
Shape-Hint Node • Use the SoShapeHints node to notify Inventor • It can optimize certain rendering features • Includes fields • vertexOrdering • Provides hints about the ordering of the faces of a vertex based shaped derived from SoVertexShape • Describes the ordering of all the vertices of all the faces • SoShapeHints::COLCKWISE • SoShapeHints::COUNTERCLOCKWISE • SoShapeHints::UNKNOWN_ORDERING
Shape-Hint Node • Includes fields • shapeType • SoShapeHints::UNKNOWN_SHAPE_TYPE • SoShapeHints::SOLID(not an open surface) • Turns on backface culling & turn off two sided lighting • faceType • SoShapeHints::UNKNOWN_SHAPE_TYPE • SoShapeHints::CONVEX
Complexity Node • SoComplexity node • Amout of subdivision into polygons for subsequent shape node in the scene graph • Three fields • Type • General type of complexity • SoComplexity::SCREEN_SPACE • SoComplexity::OBJECT_SPACE • Value • Provides a hint about the amount of subdivision desired • textureQuality • Hint about the quality of texture mapping used on the object
Complexity Node • example OBJECT_SPACE SCREEN_SPACE
Units Node • SoUnits node • Define your data in a variety of different units • Acts like a scale node by scaling subsequent shapes into the specified units • SoUnits::METERS • SoUnits::CENTIMETERS • SoUnits::MILLIMETERS • SoUnits::KILOMETERS • SoUnits::YARDS
Binding Nodes • SoMaterialBinding • How to bind materials to shapes • SoMaterialBinding::DEFAULT • Uses the best binding for each shape • SoMaterialBinding::OVERALL • Uses the first current material for the entire shape • SoMaterialBinding::PER_PART • Binds one material to each part in the shape • SoMaterialBinding::PER_PART_INDEXED • Binds one material to each part by index • And so on…
Thinking • If the number of current materials is greater than the number of parts? • Simply ignore the extra materials if they’re not required • If the current material contains fewer values than the binding requires? • Cycles through the current values as often as needed
Indexed Binding • Use the current material values in a new order • Inventor refer to the materials-index field of the shape node(SoIndexdFaceSet, SoIndexedLineSet) • PER_FACE_INDEX, PER_VERTEX_INDEX… • Example • SoIndexedFaceSet • Material List 0 peach 1 khaki 2 white Material Index 1, 1, 0, 2
Indexed Binding • Specify PER_FACE • Ignores the materialIndex field, cycles in order • Face1 peach (0) • Face2 khaki (1) • Face3 white (2) • Face4 peach (0) • Specify PER_FACE_INDEXED • Face1 khaki (1) • Face2 khaki (1) • Face3 peach(0) • Face4 white (2)
Binding per Vertex • PER_VERTEX • Selects materials in order from the materials list • PER_VERTEX_INDEXED • Selects materials in order from the materials index
Normal Binding • SoNormalBinding node • Type of normal binding specified • Hint to the shape node about how to apply the current normals to that shape • SoIndexedFaceSet, SoIndexedTriangleStripSet • Contain a normalIndex field • normalIndex field store indices into the normals list • Ginding specifed does not require indices, the normalindex field is not used • Indexed normals do not cycle
Generating normals Automatically • SoVertexShape • Normals can be generated automatically for any shape derived • Generating normals • DEFAULT normal binding is used • Do not specify any normals • The number of normals is different from the number of vertices
Transformations • Cumulative effect on the current geometric transformation • SoTransform Node • Translation • Translation in x, y, z • Rotation • Rotation in terms of an axis and angle : x, y, z, angle • scaleFactor • Scaling factor in x, y, z • ScaleOrientation • Ratation to apply before the scale is applied • Center • Center point for rotation and scaling
Order of Transformations • Last field in the node affects the shape object first The groups with transformations in different order
Order of Transformations Effects of ordering transformation