shapes properties binding 2001.08.14 chung ji hye
TRANSCRIPT
Graphics Laboratory Korea University ch
ung ji hye -2-
Content
Use a variety of shapes in the sceneIndexed shapes specify their own orderDifferent effects for color values, shininess and transparencyRender a scene using different drawing stylesCreate a scene with fog Use the shape hintsMaterial and normal binding
Graphics Laboratory Korea University ch
ung ji hye -3-
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
Graphics Laboratory Korea University ch
ung ji hye -4-
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
Graphics Laboratory Korea University ch
ung ji hye -5-
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 f
ace set Use only when some type of indexed material binding is specified i
n the SoMaterialBinding node NormalIndex
Contains indices into the current normals SoNormalBinding node
TextureCoordIndex Contains indices of the texture coordinates
Graphics Laboratory Korea University ch
ung ji hye -6-
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
Graphics Laboratory Korea University ch
ung ji hye -7-
Triangle Strip Set
Triangle Strip Set Example
Graphics Laboratory Korea University ch
ung ji hye -8-
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
Graphics Laboratory Korea University ch
ung ji hye -9-
Complex Shapes
Examples SoQuadMesh *myQuadMesh = new soQuadMesh; myQuadMesh->verticesPerRow = 12 myquadMesh ->VerticesPerColumn = 5
Static float vertexPositions[160][3] = { //1st row
{ } { } { }{ } { } { }{ } { } { }{ } { } { } , // Add 11 rows };
Each row in this quad mesh contains 12 vertices. Each column contains 5
vertices
Graphics Laboratory Korea University ch
ung ji hye -11-
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 rend
ering SoEnvironment
Simulate various atmospheric effects (fog, haze, pollution…)
Graphics Laboratory Korea University ch
ung ji hye -12-
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 shap
es in the scene graph
All of which are derived from SoNodeEach of these classes affects different elements of the rendering state
Graphics Laboratory Korea University ch
ung ji hye -13-
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
Graphics Laboratory Korea University ch
ung ji hye -14-
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 : opaq
ue)
Graphics Laboratory Korea University ch
ung ji hye -15-
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
Graphics Laboratory Korea University ch
ung ji hye -16-
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
Graphics Laboratory Korea University ch
ung ji hye -18-
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
Graphics Laboratory Korea University ch
ung ji hye -19-
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
Graphics Laboratory Korea University ch
ung ji hye -20-
Environment Node
SoEnvironment node Simulate various atmospheric effects – fog, haze, pollution a
nd so on Allows you to specify color, intensity, ambient lighting, many f
actor 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
Graphics Laboratory Korea University ch
ung ji hye -21-
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 fr
om the camera fogColor
Color of the fog
Graphics Laboratory Korea University ch
ung ji hye -22-
Shape-Hint Node
Use the SoShapeHints node to notify Inventor It can optimize certain rendering featuresIncludes 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
Graphics Laboratory Korea University ch
ung ji hye -23-
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
Graphics Laboratory Korea University ch
ung ji hye -24-
Complexity Node
SoComplexity node Amout of subdivision into polygons for subsequent shape no
de 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
Graphics Laboratory Korea University ch
ung ji hye -25-
Complexity Node
example
OBJECT_SPACE SCREEN_SPACE
Graphics Laboratory Korea University ch
ung ji hye -26-
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
Graphics Laboratory Korea University ch
ung ji hye -27-
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…
Graphics Laboratory Korea University ch
ung ji hye -28-
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
Graphics Laboratory Korea University ch
ung ji hye -29-
Indexed Binding
Use the current material values in a new orderInventor 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
Graphics Laboratory Korea University ch
ung ji hye -30-
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)
Graphics Laboratory Korea University ch
ung ji hye -31-
Binding per Vertex
PER_VERTEX Selects materials in order from the materials list
PER_VERTEX_INDEXED Selects materials in order from the materials index
Graphics Laboratory Korea University ch
ung ji hye -32-
Normal Binding
SoNormalBinding node Type of normal binding specified Hint to the shape node about how to apply the current normal
s 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 fi
eld is not used
Indexed normals do not cycle
Graphics Laboratory Korea University ch
ung ji hye -33-
Generating normals Automatically
SoVertexShape Normals can be generated automatically for any shape derive
d
Generating normals DEFAULT normal binding is used Do not specify any normals The number of normals is different from the number of vertic
es
Graphics Laboratory Korea University ch
ung ji hye -34-
Transformations
Cumulative effect on the current geometric transformationSoTransform 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
Graphics Laboratory Korea University ch
ung ji hye -35-
Order of Transformations
Last field in the node affects the shape object first
The groups with transformations in different order