- Timestamp:
- 01/12/09 03:36:41 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntityConverter.cpp
r3259 r3270 3 3 #include "Geometry.h" 4 4 #include "Shape.h" 5 5 #include "Plane3.h" 6 6 7 7 using namespace std; … … 53 53 54 54 55 SceneEntity *SceneEntityConverter::ConvertSphere(float radius, 56 float xspans, 57 float yspans, 58 Material *mat, 59 Transform3 *trafo) 60 { 61 // todo 62 return NULL; 55 63 } 64 65 66 SceneEntity *SceneEntityConverter::ConvertPlane(const Plane3 &plane, 67 float xsize, 68 float ysize, 69 float xspans, 70 float yspans, 71 Material *mat, 72 Transform3 *trafo) 73 { 74 SceneEntity *ent = new SceneEntity(trafo); 75 76 vector<Triangle3> triangles; 77 78 Vector3 x1, x2, x3, x4; 79 float xsize_h = xsize * 0.5f; 80 float ysize_h = xsize * 0.5f; 81 82 x1 = Vector3(xsize_h, ysize_h, 0); 83 x2 = Vector3(xsize_h, -ysize_h, 0); 84 x3 = Vector3(-xsize_h, -ysize_h, 0); 85 x4 = Vector3(-xsize_h, ysize_h, 0); 86 87 triangles.push_back(Triangle3(x3, x2, x1)); 88 triangles.push_back(Triangle3(x3, x1, x4)); 89 90 Vector3 *vertices = new Vector3[6]; 91 Vector3 *normals = new Vector3[6]; 92 Texcoord2 *tex = new Texcoord2[6]; 93 94 tex[0].first = 0; tex[0].second = 0; 95 tex[1].first = 1; tex[1].second = 0; 96 tex[2].first = 1; tex[2].second = 1; 97 98 tex[3].first = 0; tex[3].second = 0; 99 tex[4].first = 1; tex[4].second = 1; 100 tex[5].first = 0; tex[5].second = 1; 101 102 for (size_t i = 0; i < triangles.size(); ++ i) 103 { 104 Triangle3 tri = triangles[i]; 105 106 vertices[i * 3 + 0] = tri.mVertices[0]; 107 vertices[i * 3 + 1] = tri.mVertices[1]; 108 vertices[i * 3 + 2] = tri.mVertices[2]; 109 110 Vector3 normal = tri.GetNormal(); 111 112 normals[i * 3 + 0] = normal; 113 normals[i * 3 + 1] = normal; 114 normals[i * 3 + 2] = normal; 115 } 116 117 Geometry *geom = new Geometry(vertices, normals, tex, 6, true, NULL); 118 119 Shape *shape = new Shape(geom, mat); 120 ent->AddShape(shape); 121 122 LODLevel lodLevel(0); 123 124 lodLevel.AddShape(shape); 125 ent->AddLODLevel(lodLevel); 126 127 return ent; 128 } 129 130 }
Note: See TracChangeset
for help on using the changeset viewer.