1 | /* |
---|
2 | SimpleScenes_TriMesh.h |
---|
3 | --------------------- |
---|
4 | A reimplementation of the ODE triangle mesh collision |
---|
5 | demo using Ogre and the OgreOde wrapper. |
---|
6 | */ |
---|
7 | #ifndef _SIMPLESCENES_TRIMESH_H_ |
---|
8 | #define _SIMPLESCENES_TRIMESH_H_ |
---|
9 | |
---|
10 | /* |
---|
11 | The box stacking test extends the box stacking demo, but adds a trimesh! |
---|
12 | */ |
---|
13 | class SimpleScenes_TriMesh:public SimpleScenes_BoxStack |
---|
14 | { |
---|
15 | public: |
---|
16 | // Standard constructor, but create a triangle mesh |
---|
17 | SimpleScenes_TriMesh(OgreOde::World *world) : |
---|
18 | SimpleScenes_BoxStack (world) |
---|
19 | { |
---|
20 | // Create the visual entity and scene node |
---|
21 | Entity* entity = _mgr->createEntity("Landscape","landscape.mesh"); |
---|
22 | |
---|
23 | SceneNode* node = _mgr->getRootSceneNode()->createChildSceneNode(entity->getName()); |
---|
24 | node->attachObject(entity); |
---|
25 | node->setScale(Vector3(0.4,0.3,0.4)); |
---|
26 | node->setPosition(Vector3(0,3,0)); |
---|
27 | node->setOrientation(Quaternion(Degree(30),Vector3::UNIT_Y)); |
---|
28 | |
---|
29 | entity->setNormaliseNormals(true); |
---|
30 | //entity->setCastShadows(false); |
---|
31 | |
---|
32 | // Turn it into a triangle mesh static geometry |
---|
33 | OgreOde::EntityInformer ei(entity,node->_getFullTransform()); |
---|
34 | OgreOde::Geometry *geom = ei.createStaticTriangleMesh(_world, _space); |
---|
35 | entity->setUserObject (geom); |
---|
36 | _geoms.push_back(geom); |
---|
37 | } |
---|
38 | |
---|
39 | // Destructor, manually destroy the entity and node, since they're |
---|
40 | // not associated with a body they won't get deleted automatically |
---|
41 | virtual ~SimpleScenes_TriMesh() |
---|
42 | { |
---|
43 | _mgr->destroySceneNode("Landscape"); |
---|
44 | _mgr->destroyEntity("Landscape"); |
---|
45 | } |
---|
46 | |
---|
47 | // Return our name for the test application to display |
---|
48 | virtual const String& getName() |
---|
49 | { |
---|
50 | static String name = "Test Triangle Mesh"; |
---|
51 | return name; |
---|
52 | } |
---|
53 | }; |
---|
54 | |
---|
55 | #endif |
---|