Download presentation
Presentation is loading. Please wait.
Published byFarida Hermawan Modified over 6 years ago
1
Nodes and Groups Lee Young Gun Open Inventor
2
Content The Scene Database & Scene Graphs Types of Nodes & Groups
Shared Instancing of Nodes & Path Fields within a Node Ignore flag and Override Flag References and Deletion Node Types & Naming Nodes - 2 -
3
The Scene Database & Scene Graphs
Consist of information scene Using of SoDB class Contain several scene graphs Two basic operation SoDB :: init() Read function : read from a file into the scene database scene graph Consist of one or more node, represent a geometry, property or grouping object Inventor Database - 3 -
4
Type of Nodes & Groups - 1 Node
Type of Nodes & Groups - 1 Node The fundamental element of a scene graph Contain the data and methods If create a node, insert into a database Three basic categories Shape nodes : 3D geometric objects Property nodes : appearance and characteristics Group nodes : collect nodes into graphs - 4 - Open Inventor
5
Type of Nodes & Groups - 2 Create Node Contents of Node Action of Node
Type of Nodes & Groups - 2 Create Node SoSphere * headSphere = new SoSphere; Contents of Node compose a set of data element, called fields ex) SoPointLight : intensity, color, location, on Action of Node create action class SoGLRenderAction, SoGetBoundingBoxAction traverse the graph by rules (top->bottom, left->right) - 5 - Open Inventor
6
Type of Nodes & Groups - 3 Basic category of Node Shape node
Represent 3D geometric objects Cube, cone, sphere, texture etc. Property node Represent appearance and characteristics Surface material, drawing style, geometric transformation Replace the values in a corresponding elements Group node A container for collecting child objects Collect property, shape, other group node - 6 -
7
Type of Nodes & Groups - 4 Groups
First create a group, has no children node Base class of group : SoGroup By using the method of addChild, attach the group to nodes ex) SoGroup * head = new SoGroup head->addChild(myXform); head->addChild(bronze); head->addChild(headSphere); Ordering of children : from left to right Simple Group - 7 -
8
Type of Nodes & Groups - 5 Indexing of child Important ordering
when the child insert, each child node is indexed first node : index of 0, second node : index of 1 insert method : insertChild(SoNode *child, int newIndex) insert a child node into a group at the new location by newIndex ex : body->insertChild(wireStyle, 1); Important ordering The property of other node is inherited by the property of root node Combining Group - 8 -
9
Type of Nodes & Groups - 6 Subclass of SoGroup SoSeperator
To isolate the effects of nodes in a group Before traversing its children, saves the current traversal state Restore the previous traversal state No effect anything above or right node in the graph Separator Groups - 9 -
10
Type of Nodes & Groups - 7 Other subclass of SoGroup SoSwitch
Visit only one of its children Contain one filed, is used whichChild SoSwitch * s = new SoSwitch; s->addChild(a); s->addChild(b); s->addChild(d); s->whichChild =2; Default value : SO_WITCH_NONE(no visiting child node) SoLevelOfDetail Specify the same object with varying levels of detail Useful for applications requiring the fastest rendering possible Contain one field : screenArea(SoMFFloat) SoSelection - 10 -
11
Type of Nodes & Groups - 8 Scene Graph with Level-of-Detail Node
Different Levels of Detail for an object - 11 -
12
Shared Instancing of Nodes & Path - 1
Sharing instancing A single node has more than one parent Path Use to isolate particular objects in the scene graph If want to refer to the particular node, must be represented by the path, starting at the root node All action that can be performed on a node can be performed on a path - 12 -
13
Shared Instancing of Nodes & Path - 2
Example of Sharing instancing & path - 13 -
14
Example of Inventor - 14 -
15
Fields within a Node - 1 Field value
Property value of node As creating node, set to predefine values Ex) SoDrawStyle * d = new SoDrawStyle; d->style.setvalue(SoDrawStyle::LINES); d->lineWidth.setvalue(3); d->linePattern.setvalue(0xf0f0); Single value vs. Multiple value field Single value field To have one value of a given type Class used the letters ‘SF’ : SoSFBool Multiple value field To contain an array of values Class used the letters ‘MF’ : SoMFVec3f - 15 -
16
Fields within a Node - 2 Single value field Multiple value field
Setting and Getting value Setting value Using method is called setValue() cam->height.setValue(1.); or cam->height = 1.; Getting value Using method is called getValue() Float result = cam->height.getValue(); Multiple value field nodeName->fieldName.setValues(starting index,number of values, pointer to array of values); SoMaterial * mtl; float vals[3]; vals[0] = 0.2; vals[1] = 0.5; vals[2] = 0.9; mtl->transparency.setValues(0, 3, vals); - 16 -
17
Ignore flag and Override Flag
Ignore Flag Methods Every field has an Ignore flag Use the setIgnored() method to set or reset the Ignore flag When Flag is set, the fields is disregarded Bronze->specularColor.setIgnored(true); // ignore field Override Flag Every node has an Override flag When Flag is set, any nodes of the same type encountered later in the graph are ignore setOverride() : set and reset the Override flag isOverride() : return the state of the Override flag - 17 -
18
References and Deletion - 1
Reference counting The number of references made to that node within the database By calling ref(), unref(), control the reference count Adds node B to node A : B’s counter = 1 Node C : add to two different parent group C’s counter = 2 root->ref() : be not referenced being a child Referencing a node in a path Incremental the node’s reference count Incremental the Reference counts Reference counts - 18 -
19
References and Deletion - 2
Node deletion Use a reference-counting mechanism Remove a reference node and a child Decrements the reference count If node’s reference count is 0 Delete from the database Order of decrement P 0 Q 0 S 1 R 0 S 0 When a group is deleted, all child are removed - 19 -
20
References and Deletion - 3
Summary of References and Deletion Increments Reference Count by 1 Decrements Reference Count by 1 Adding a node as a child of another node increments child’s reference count Removing a node as a child of another node Adding a node to a path Removing a node from a path Applying an action to a node or path increments reference count of all nodes that are traversed When traversal for the action finishes, all nodes that were traversed are unreferenced Adding a node to an SoNodeList node Removing a node from an SoNodeList - 20 -
21
Node Types and Naming Nodes
For runtime type-checking through the SoType class getTypeId() : obtain the SoType for that instance getParent() : to find the parent class pf a type CreateInstance() : to create an instance of a particular type getName() : to obtain an SbName for the class type Naming Nodes Assign a name to a node, path or engine and then search for the object by name Useful way of identifying objects Apply to Writing to file or reading from file - 21 -
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.