Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Cleaned up the heavy mess with header file includes in OgreOde. It should now compile a lot faster.

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