Revision 3071,
1.2 KB
checked in by mattausch, 16 years ago
(diff) |
worked on dynamic objects
|
Line | |
---|
1 | #include "SceneEntityConverter.h"
|
---|
2 | #include "SceneEntity.h"
|
---|
3 | #include "Geometry.h"
|
---|
4 | #include "Shape.h"
|
---|
5 |
|
---|
6 |
|
---|
7 | using namespace std;
|
---|
8 |
|
---|
9 |
|
---|
10 | namespace CHCDemoEngine
|
---|
11 | {
|
---|
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 |
|
---|
23 | Vector3 *vertices = new Vector3[36];
|
---|
24 | Vector3 *normals = new Vector3[36];
|
---|
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 |
|
---|
41 | cout << "number of triangles in box: " << (int)triangles.size() << endl;
|
---|
42 |
|
---|
43 | Geometry *geom = new Geometry(vertices, normals, NULL, 36, false);
|
---|
44 |
|
---|
45 | Shape *shape = new Shape(geom, mat);
|
---|
46 | ent->AddShape(shape);
|
---|
47 |
|
---|
48 | LODLevel lodLevel(0);
|
---|
49 |
|
---|
50 | lodLevel.AddShape(shape);
|
---|
51 | ent->AddLODLevel(lodLevel);
|
---|
52 |
|
---|
53 | return ent;
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.