Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/ogreode/OgreOdeTriangleMeshData.cpp @ 1919

Last change on this file since 1919 was 1919, checked in by rgrieder, 16 years ago

Added OgreODE to our source repository because already we really need the newest version. And there is no hope to find any packages under linux.
The files included should compile and link with Ogre 1.4/1.6 and ODE 0.9/0.10. I was only able to test Ogre 1.4 and ODE 0.9/.10 under msvc until now.

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1
2#include "OgreOdePrecompiledHeaders.h"
3
4#include "OgreOdeGeometry.h"
5#include "OgreOdeWorld.h"
6#include "OgreOdeSpace.h"
7#include "OgreOdeBody.h"
8#include "OgreOdeCollision.h"
9#include "OgreOdeDebugObject.h"
10#include "OgreOdeDebugContact.h"
11
12#include "OgreOdeTriangleMeshData.h"
13
14#include "OgreOdeTriangleMeshDataManager.h"
15
16using namespace OgreOde;
17using namespace Ogre;
18
19
20//------------------------------------------------------------------------------------------------
21TriangleMeshData::TriangleMeshData(String name,
22                                                                   Vector3 scale,
23                                                                   const Ogre::Vector3* vertices,
24                                                                   unsigned int vertex_count,
25                                                                   const TriangleIndex* indices,
26                                                                   unsigned int index_count
27                                                                   ) : 
28    _vertex_count (vertex_count),
29    _index_count (index_count)
30{
31        _name = name;
32        _scale = scale;
33        _vertex_count = vertex_count;
34        _index_count = index_count;
35        _vertices = new dVector3[vertex_count];
36        _indices = new TriangleIndex[index_count];
37
38        for(unsigned int i = 0;i < vertex_count;i++)
39        {
40                _vertices[i][0] = (dReal)vertices[i].x;
41                _vertices[i][1] = (dReal)vertices[i].y;
42                _vertices[i][2] = (dReal)vertices[i].z;
43        }
44
45        memcpy(_indices, indices, sizeof(unsigned int) * index_count);
46
47        _data = dGeomTriMeshDataCreate(); 
48        dGeomTriMeshDataBuildSimple(_data, (const dReal*)_vertices, (int)vertex_count, (dTriIndex*)_indices, (int)index_count); 
49       
50}
51
52
53
54
55//------------------------------------------------------------------------------------------------
56TriangleMeshData::~TriangleMeshData()
57{
58
59        //printf ("destroy TriangleMeshData\n");
60       
61        dGeomTriMeshDataDestroy(_data);
62       
63        TriangleMeshDataManager::getSingleton().removeTriangleMeshData(_name, _scale);
64       
65        delete[] _vertices;
66        delete[] _indices;
67}
68
69
Note: See TracBrowser for help on using the repository browser.