Misc
		// some types used in the application:
		typedef gfx::node<gfx::ogre_traits> node_t; // Yes, we use OGRE!
		typedef gfx::camera<gfx::ogre_traits> camera_t;
		typedef gfx::translate_op<node_t> translate_op;
		typedef gfx::vector3 vector3;
 
		// create minimal node wrapper - implicitely uses handle_t<Ogre::SceneNode>.
		//Ogre::SceneNode* sn = sceneMgr->createSceneNode(autoName("sn_"));
		node_t node(sn);
 
		vector3 pos = node.getPosition(); // access node_t (wrapper object)
		Ogre::Vector3 pos2 = node->getPosition(); // access wrapped Ogre::SceneNode
		Ogre::SceneNode* sn2 = *node; // dereference wrapper object to access wrapped object
		assert( sn == sn2 );
 
		pos = getPosition(node); // query using free function
		node.setPosition(pos + vector3(1,0,0));
 
		// Create list of nodes (not pointers!)
		std::vector<node_t> nodes;
		nodes.push_back( node_t(sn) );
 
		// Translate all nodes
		std::for_each( nodes.begin(), nodes.end(), translate_op(vector3(0,2,0)) );
		gfx::translate_all( nodes, vector3(10,0,0) );
 
		// create camera
		Ogre::Camera* cam = sceneMgr->createCamera("cam0");
		camera_t cam(cam);
 
		// let camera use transform from node
		node.attach(cam);
 
		// Access attached objects
		cam = node.getAttachedCamera("cam0");
 
		// create 2nd node
		node_t node2(sn2);
 
		// let 2nd node follow 1st node
		typedef gfx::transform_forwarder<node_t> forwarder_t;
		forwarder_t followNode(node, node2, forwarder_t::POSITION_AND_ORIENTATION);
		followNode.update(); // call this at regular intervals
		//followNode.add(node3);
XForm
		// XFORM
 
		// sn1 and sn2 can be of any type that supports
		// the 'movable' interface independently of the
		// vector/orientation types used.
 
		// Specializations take care of conversion when mixed
		// types are used (e.g. graphics::node<> and Ogre::SceneNode, and
		// therefore graphics::vector3 and Ogre::Vector3 etc).
 
		// apply transformation of sn1 to sn2:
		gfx::forward_xform( *sn1, n2 );
 
		// position sn2 halfway(0.5) between sn1 and sn2, update orientation immediately (1.).
		gfx::forward_xform_ratio( *sn1, n2, 0.5/*translational ratio*//*, 1.rotational factor*/ );
 
psy/scrapbook.txt · Last modified: 2008/02/21 21:58 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki