R: [Plib-devel] SSG Tree help needed
Brought to you by:
sjbaker
From: Paolo L. <p.l...@ci...> - 2005-11-29 09:42:28
|
> -----Messaggio originale----- > Da: pli...@li...=20 > [mailto:pli...@li...] Per conto di=20 > po...@cs... > Inviato: sabato 19 novembre 2005 20.54 > A: pli...@li... > Oggetto: [Plib-devel] SSG Tree help needed >=20 >=20 > Hi! We are creating car simulation, and we are planning to=20 > use PLIB (SSG=20 > loader). I know the structure of SSG tree, but if I add some=20 > image (object)=20 > in the scence graph, I want to know in which classes the different=20 > attributes (like color, texture, animation) of that image=20 > goes? As far as for 'adding an image to the scene graph' you mean a texture = which maps a (somehow flat) object, it is actually a texture attribute to a = state. A tipical node structure in SSG is: ssgBranch (Transform, grouping, Range Selector, Switch, Texture = transform, etc.) | V ssgLeaf (geometry, e.g. VtxArray) | V ssgState (actually SimpleState, i.e. leaf attributes such as texture, = color, GL modes, etc.) Thus, for answering the question, the different attributes go to the ssgSimpleState class object, e.g. ssgSimpleState *s =3D new ssgSimpleState(); s->setTexture( "imagefilename.ext", true, true ); ssgLeaf *l; // create and fill geometry node l - ssgLeaf is just an abstract class l->setState( s ); About animation, we should agree on what kind of it - texture animation = in terms of texture transform can be accomplished in two ways: 1. inserting a ssgTextureTransform node before the ssgLeaf, and setting = the wanted texture transform on that; 2. setting up a pre-draw callback for the leaf node, which sets the GL texture transform matrix, and a post-draw callback which resets it ti = the identity. The pre-draw one has to return 1 for the leaf to be drawn. Choice 2. doesn't change your scene graph structure. Other kind of animations could imply color attributes to be changed, yet = you have to manage for timing since there's no built-in mechanism for this. = You have timed swiches instead, which actually act by selecting one of = children nodes in a timed sequence. There should be other timed animation = mechanisms in SSG that you can search for in ssg.h, along with a mine of methods = for the standard classes which will be useful to you for your advanced apps. > Because ssgVTable class contains the information like leaf geometry=20 > as arrays of=20 > vertex, normal, texture coordinate and colour data then what=20 > does the Root,=20 > branches and kids of the tree contains? Does kids only=20 > contains the objects=20 > of the scene? Yes, leaf nodes contain scene objects, but are not the very last leaf in = the strict sense, being this the state node. > What is exact difference between ssgRoot, ssgBaseTransform=20 > and ssgEntity? For the transform object does the ssgRoot is=20 > always be the=20 > parent node? Regarding the realtion between a Transform and the Root node, yes and = no, since for structuring hierarchical transformation you'll probably create = a structure where a ssgTransform is one of the children of another ssgTransform (the classic "robot arm" example). The Root node is still = there only for historical reasons, since latest Plib versions make = ssgCullAndDraw to start from a ssgBranch, and ssgLoad to return a ssgEntity. > Kindly pls. find time to reply earliest possible. > Thnaks a lot. > - Poonam. You're welcome, greetings - Paolo Leoncini |