Transform a node/subgraph #include // Create transformation node osg::ref_ptr mypat = new osg::positionattitudetransform mypat->setposition(osg::vec3(1.0, ydist, zdist)) mypat->setscale(osg::vec3(xscale, yscale, zscale)) mypat->setattitude(osg::quat(angle_in_rads, axis_of_rot_vec)) // Attach node to be transformed mypat->addchild(mynode.get()) Notes: Don't forget to attach the transform node to the graph, whether at the root or elsewhere. This code creates a subgraph, which must ultimately be attached to your scenegraph at the root node or elsewhere. Attach a node under another somenode->addchild(othernode.get()) // if othernode is a ref_ptr somenode->addchild(othernode) // if othernode is a raw pointer Notes: The parent node must be a Group or a node type derived from Group. Linking requires the library osgdb.lib (or libosgdb.so under Unix/Linux). The node returned may be a Group node with children corresponding to the various objects defined in the file. Load object(s) from file #include osg::ref_ptr mynode = osgdb::readnodefile("mymodel.obj") Notes: Node files must be in a format supported by OSG. Initial properties of the shape primitives can be set at creation time or afterward (see API documentation for details). Other classes are provided also to support more complex shapes. Create a simple shape #include #include osg::ref_ptr mynode = new osg::geode mygeode->adddrawable(new osg::shapedrawable(new osg::sphere()) Notes: Predefined shape primitives include Box, Capsule, Cone, Cylinder, InfinitePlane & Sphere. Build Notes: To make your Visual Studio projects build properly, you must add osg.lib to your Additional Dependencies under the Linker->Input settings (under Unix/Linux it is libosg.so). 1 OpenSceneGraph Sample Code Snippets Fundamentals General Notes: You should have a basic understanding of basic graphics concepts, including scene graphs, before attempting to apply the examples given in this document.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |