Changeset 683
- Timestamp:
- 06/27/07 16:55:33 (17 months ago)
- Location:
- trunk/common
- Files:
-
- 5 modified
-
lc_application.cpp (modified) (3 diffs)
-
lc_flexpiece.cpp (modified) (3 diffs)
-
lc_mesh.cpp (modified) (4 diffs)
-
lc_mesh.h (modified) (2 diffs)
-
lc_pivot.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/lc_application.cpp
r663 r683 1 1 #include "lc_global.h" 2 #include "lc_application.h" 3 2 4 #include <stdio.h> 3 #include "lc_ application.h"5 #include "lc_mesh.h" 4 6 #include "library.h" 5 7 #include "system.h" … … 257 259 SystemInit(); 258 260 261 lcCreateDefaultMeshes(); 262 259 263 // Create a new project. 260 264 Project* project = new Project(); … … 410 414 m_Library = NULL; 411 415 416 lcDestroyDefaultMeshes(); 417 412 418 GL_Shutdown(); 413 419 } -
trunk/common/lc_flexpiece.cpp
r681 r683 275 275 // FIXME: split this into another file 276 276 277 // FIXME: move the sphere somewhere else. 278 static lcMesh* SphereMesh; 277 #define LC_FLEXPIECE_POINT_SIZE 0.2f 279 278 280 279 lcFlexiblePiecePoint::lcFlexiblePiecePoint(lcFlexiblePiece* Parent) … … 282 281 { 283 282 m_Parent = Parent; 284 285 if (!SphereMesh)286 SphereMesh = lcCreateSphereMesh(0.2f, 8);287 283 } 288 284 … … 301 297 // FIXME: lcFlexiblePiece 302 298 299 Matrix44 ScaleMatrix(Vector4(LC_FLEXPIECE_POINT_SIZE, 0.0f, 0.0f, 0.0f), Vector4(0.0f, LC_FLEXPIECE_POINT_SIZE, 0.0f, 0.0f), Vector4(0.0f, 0.0f, LC_FLEXPIECE_POINT_SIZE, 0.0f), Vector4(0.0f, 0.0f, 0.0f, 1.0f)); 300 301 Matrix44 ModelWorld = IdentityMatrix44(); 302 ModelWorld.SetTranslation(m_WorldPosition); 303 303 304 lcRenderSection RenderSection; 304 305 305 306 RenderSection.Owner = (lcPieceObject*)this; 306 RenderSection.ModelWorld = IdentityMatrix44(); 307 RenderSection.ModelWorld.SetTranslation(m_WorldPosition); 308 RenderSection.Mesh = SphereMesh; 309 RenderSection.Section = &SphereMesh->m_Sections[0]; 307 RenderSection.ModelWorld = Mul(ScaleMatrix, ModelWorld);; 308 RenderSection.Mesh = lcSphereMesh; 309 RenderSection.Section = &lcSphereMesh->m_Sections[0]; 310 310 RenderSection.Color = 0; 311 311 -
trunk/common/lc_mesh.cpp
r680 r683 1 1 #include "lc_global.h" 2 #include "lc_mesh.h" 3 2 4 #include <malloc.h> 3 5 #include <stdlib.h> 4 6 #include "opengl.h" 5 7 #include "globals.h" 6 #include "lc_mesh.h"7 8 #include "system.h" 8 9 #include "debug.h" 10 11 lcMesh* lcSphereMesh; 12 lcMesh* lcBoxMesh; 13 lcMesh* lcWireframeBoxMesh; 14 15 void lcCreateDefaultMeshes() 16 { 17 lcSphereMesh = lcCreateSphereMesh(1.0f, 16); 18 lcBoxMesh = lcCreateBoxMesh(Vector3(-1.0f, -1.0f, -1.0f), Vector3(1.0f, 1.0f, 1.0f)); 19 lcWireframeBoxMesh = lcCreateWireframeBoxMesh(Vector3(-1.0f, -1.0f, -1.0f), Vector3(1.0f, 1.0f, 1.0f)); 20 } 21 22 void lcDestroyDefaultMeshes() 23 { 24 delete lcSphereMesh; 25 lcSphereMesh = NULL; 26 delete lcBoxMesh; 27 lcBoxMesh = NULL; 28 delete lcWireframeBoxMesh; 29 lcWireframeBoxMesh = NULL; 30 } 9 31 10 32 lcMesh* lcCreateSphereMesh(float Radius, int Slices) … … 88 110 } 89 111 90 lcMesh* lcCreate WireframeBoxMesh(const Vector3& Min, const Vector3& Max)91 { 92 int NumIndices = 12;112 lcMesh* lcCreateBoxMesh(const Vector3& Min, const Vector3& Max) 113 { 114 int NumIndices = 24; 93 115 int NumVertices = 8; 94 116 … … 96 118 97 119 lcMeshEditor<u16> MeshEdit(BoxMesh); 98 MeshEdit.StartSection(GL_ LINES, LC_COL_DEFAULT);120 MeshEdit.StartSection(GL_QUADS, LC_COL_DEFAULT); 99 121 100 122 MeshEdit.AddVertex(Vector3(Min[0], Min[1], Min[2])); … … 109 131 MeshEdit.AddIndex(0); 110 132 MeshEdit.AddIndex(1); 133 MeshEdit.AddIndex(2); 134 MeshEdit.AddIndex(3); 135 MeshEdit.AddIndex(7); 136 MeshEdit.AddIndex(6); 137 MeshEdit.AddIndex(5); 138 MeshEdit.AddIndex(4); 139 140 MeshEdit.AddIndex(0); 141 MeshEdit.AddIndex(1); 142 MeshEdit.AddIndex(5); 143 MeshEdit.AddIndex(4); 144 MeshEdit.AddIndex(2); 145 MeshEdit.AddIndex(3); 146 MeshEdit.AddIndex(7); 147 MeshEdit.AddIndex(6); 148 149 MeshEdit.AddIndex(0); 150 MeshEdit.AddIndex(3); 151 MeshEdit.AddIndex(7); 152 MeshEdit.AddIndex(4); 153 MeshEdit.AddIndex(1); 154 MeshEdit.AddIndex(2); 155 MeshEdit.AddIndex(6); 156 MeshEdit.AddIndex(5); 157 158 MeshEdit.EndSection(); 159 160 return BoxMesh; 161 } 162 163 lcMesh* lcCreateWireframeBoxMesh(const Vector3& Min, const Vector3& Max) 164 { 165 int NumIndices = 24; 166 int NumVertices = 8; 167 168 lcMesh* BoxMesh = new lcMesh(1, NumIndices, NumVertices, NULL); 169 170 lcMeshEditor<u16> MeshEdit(BoxMesh); 171 MeshEdit.StartSection(GL_LINES, LC_COL_DEFAULT); 172 173 MeshEdit.AddVertex(Vector3(Min[0], Min[1], Min[2])); 174 MeshEdit.AddVertex(Vector3(Min[0], Max[1], Min[2])); 175 MeshEdit.AddVertex(Vector3(Max[0], Max[1], Min[2])); 176 MeshEdit.AddVertex(Vector3(Max[0], Min[1], Min[2])); 177 MeshEdit.AddVertex(Vector3(Min[0], Min[1], Max[2])); 178 MeshEdit.AddVertex(Vector3(Min[0], Max[1], Max[2])); 179 MeshEdit.AddVertex(Vector3(Max[0], Max[1], Max[2])); 180 MeshEdit.AddVertex(Vector3(Max[0], Min[1], Max[2])); 181 182 MeshEdit.AddIndex(0); 183 MeshEdit.AddIndex(1); 111 184 MeshEdit.AddIndex(1); 112 185 MeshEdit.AddIndex(2); -
trunk/common/lc_mesh.h
r680 r683 3 3 4 4 #include "opengl.h" 5 #include "algebra.h" 5 6 6 7 class lcVertexBuffer … … 273 274 274 275 lcMesh* lcCreateSphereMesh(float Radius, int Slices); 276 lcMesh* lcCreateBoxMesh(const Vector3& Min, const Vector3& Max); 275 277 lcMesh* lcCreateWireframeBoxMesh(const Vector3& Min, const Vector3& Max); 276 278 279 void lcCreateDefaultMeshes(); 280 void lcDestroyDefaultMeshes(); 281 282 extern lcMesh* lcSphereMesh; 283 extern lcMesh* lcBoxMesh; 284 extern lcMesh* lcWireframeBoxMesh; 285 277 286 #endif -
trunk/common/lc_pivot.cpp
r681 r683 56 56 void lcPivot::AddToScene(lcScene* Scene, int Color) 57 57 { 58 Matrix44 ScaleMatrix(Vector4(LC_PIVOT_SIZE, 0.0f, 0.0f, 0.0f), Vector4(0.0f, LC_PIVOT_SIZE, 0.0f, 0.0f), Vector4(0.0f, 0.0f, LC_PIVOT_SIZE, 0.0f), Vector4(0.0f, 0.0f, 0.0f, 1.0f)); 59 58 60 // fixme: lcPivot 59 static lcMesh* BoxMesh = lcCreateWireframeBoxMesh(Vector3(-LC_PIVOT_SIZE, -LC_PIVOT_SIZE, -LC_PIVOT_SIZE), Vector3(LC_PIVOT_SIZE, LC_PIVOT_SIZE, LC_PIVOT_SIZE));60 61 61 lcRenderSection RenderSection; 62 62 63 63 RenderSection.Owner = this; 64 RenderSection.ModelWorld = m_ModelWorld;65 RenderSection.Mesh = BoxMesh;66 RenderSection.Section = & BoxMesh->m_Sections[0];64 RenderSection.ModelWorld = Mul(ScaleMatrix, m_ModelWorld); 65 RenderSection.Mesh = lcWireframeBoxMesh; 66 RenderSection.Section = &lcWireframeBoxMesh->m_Sections[0]; 67 67 RenderSection.Color = 1; 68 68
