Revision 3245,
1.1 KB
checked in by mattausch, 15 years ago
(diff) |
pvs seems to work now
|
Rev | Line | |
---|
[2946] | 1 | #include "SceneEntityConverter.h"
|
---|
[2951] | 2 | #include "SceneEntity.h"
|
---|
| 3 | #include "Geometry.h"
|
---|
| 4 | #include "Shape.h"
|
---|
[2946] | 5 |
|
---|
| 6 |
|
---|
| 7 | using namespace std;
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | namespace CHCDemoEngine
|
---|
| 11 | {
|
---|
[2951] | 12 |
|
---|
| 13 | SceneEntity *SceneEntityConverter::ConvertBox(const AxisAlignedBox3 &box,
|
---|
| 14 | Material *mat,
|
---|
| 15 | Transform3 *trafo)
|
---|
| 16 | {
|
---|
| 17 | SceneEntity *ent = new SceneEntity(trafo);
|
---|
| 18 |
|
---|
| 19 | vector<Triangle3> triangles;
|
---|
| 20 |
|
---|
| 21 | box.Triangulate(triangles);
|
---|
| 22 |
|
---|
[2953] | 23 | Vector3 *vertices = new Vector3[36];
|
---|
| 24 | Vector3 *normals = new Vector3[36];
|
---|
[2951] | 25 |
|
---|
| 26 | for (size_t i = 0; i < triangles.size(); ++ i)
|
---|
| 27 | {
|
---|
| 28 | Triangle3 tri = triangles[i];
|
---|
| 29 |
|
---|
| 30 | vertices[i * 3 + 0] = tri.mVertices[0];
|
---|
| 31 | vertices[i * 3 + 1] = tri.mVertices[1];
|
---|
| 32 | vertices[i * 3 + 2] = tri.mVertices[2];
|
---|
| 33 |
|
---|
| 34 | Vector3 normal = tri.GetNormal();
|
---|
| 35 |
|
---|
| 36 | normals[i * 3 + 0] = normal;
|
---|
| 37 | normals[i * 3 + 1] = normal;
|
---|
| 38 | normals[i * 3 + 2] = normal;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
[3126] | 41 | Geometry *geom = new Geometry(vertices, normals, NULL, 36, false, NULL);
|
---|
[2951] | 42 |
|
---|
[3071] | 43 | Shape *shape = new Shape(geom, mat);
|
---|
[2951] | 44 | ent->AddShape(shape);
|
---|
| 45 |
|
---|
[3070] | 46 | LODLevel lodLevel(0);
|
---|
[2953] | 47 |
|
---|
[3070] | 48 | lodLevel.AddShape(shape);
|
---|
[2953] | 49 | ent->AddLODLevel(lodLevel);
|
---|
| 50 |
|
---|
[2951] | 51 | return ent;
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 |
|
---|
[2946] | 55 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.