- Timestamp:
- Jun 9, 2005, 12:20:58 AM (20 years ago)
- Location:
- orxonox/tags/0.3.0-pre-alpha
- Files:
-
- 1 deleted
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
orxonox/tags/0.3.0-pre-alpha/src/lib/collision_detection/bounding_volume.cc
r4557 r4559 27 27 { 28 28 this->setClassID(CL_BOUNDING_VOLUME, "BoundingVolume"); 29 this->center = new Vector();30 29 31 30 } … … 39 38 { 40 39 // delete what has to be deleted here 41 delete this->center;42 40 } -
orxonox/tags/0.3.0-pre-alpha/src/lib/collision_detection/bounding_volume.h
r4557 r4559 35 35 Vector* center; //!< Center point of box 36 36 37 sVect3D* vertices; //!< if CD_STORE_VERTICES enabled, this is the place, where the vert. will be sotred 38 int numOfVertices; //!< number of vertices in the vertices buffer 37 tList<sVect3D>* verticesBuffer; //!< if CD_STORE_VERTICES enabled, this is the place, where the vert. will be sotred 39 38 }; 40 39 -
orxonox/tags/0.3.0-pre-alpha/src/lib/collision_detection/obb.cc
r4557 r4559 18 18 #include "obb.h" 19 19 #include "list.h" 20 #include "vector.h"21 20 22 21 using namespace std; … … 29 28 { 30 29 this->setClassID(CL_OBB, "OBB"); 31 this->axis = new Vector[3];32 this->halfLength = new float[3];33 30 } 34 31 … … 41 38 { 42 39 // delete what has to be deleted here 43 delete [] this->axis;44 delete [] this->halfLength;45 40 } 46 41 -
orxonox/tags/0.3.0-pre-alpha/src/lib/collision_detection/obb.h
r4557 r4559 32 32 33 33 34 p ublic:34 private: 35 35 Vector* axis; //!< Axes of oriented box [x,y,z] 36 float* halfLength; //!< Half lengths of the box along the axis 37 float covarianceMatrix[3][3]; //!< the covariance matrix 36 sVect3D* halfLength; //!< Half lengths of the box 38 37 38 OBB* leftNode; //!< left node of the tree 39 OBB* rightNode; //!< right node of the tree 39 40 }; 40 41 -
orxonox/tags/0.3.0-pre-alpha/src/lib/collision_detection/obb_tree_node.cc
r4557 r4559 55 55 void OBBTreeNode::spawnBVTree(const int depth, sVec3D *verticesList, const int length) 56 56 { 57 this->bvElement = this->createBox();58 this->calculateBoxAttributes(box);59 this->forkBox(box);60 }61 62 63 OBB* OBBTreeNode::createBox()64 {65 return new OBB();66 }67 68 69 void OBBTreeNode::calculateBoxAttributes(OBB* box)70 {71 57 float facelet[length]; //!< surface area of the i'th triangle of the convex hull 72 58 float face; //!< surface area of the entire convex hull 73 59 Vector centroid[length]; //!< centroid of the i'th convex hull 74 Vector center; //!< the center of the entire hull 60 Vector centre; //!< the centre of the entire hull 61 OBB* obb = new OBB(); //!< the new obb to add 75 62 Vector p, q, r; //!< holder of the polygon data, much more conveniant to work with Vector than sVec3d 76 63 Vector t1, t2; //!< temporary values … … 98 85 centroid[i] = (p + q + r) * 1/3; 99 86 /* now calculate the centroid of the entire convex hull, weighted average of triangle centroids */ 100 cent er+= centroid[i] * facelet[i];87 centre += centroid[i] * facelet[i]; 101 88 } 102 89 /* take the average of the centroid sum */ 103 cent er/= face;90 centre /= face; 104 91 105 92 /* now calculate the covariance matrix - if not written in three for-loops, it would compute faster: minor */ … … 115 102 116 103 covariance[j][k] = facelet[i] / (12.0f * face) * (9.0f * centroid[i][j] * centroid[i][k] + p[j]* p[k] + 117 q[j] * q[k] + r[j]*r[k]) - cent er[j] * center[k];104 q[j] * q[k] + r[j]*r[k]) - centre[j] * centre[k]; 118 105 } 119 106 } 120 107 } 121 108 122 109 printf("Covariance Matrix:\n"); 123 110 for(int j = 0; j < 3; ++j) … … 136 123 printf("vertex %i: %f, %f, %f\n", i, verticesList[i][0], verticesList[i][1], verticesList[i][2]); 137 124 } 138 139 140 141 box->covarianceMatrix = covariance;142 box->center = center;143 144 145 /* now getting spanning vectors of the sub-space:146 the eigenvectors of a symmertric matrix, such as the147 covarience matrix are mutually orthogonal.148 after normalizing them, they can be used as a the basis149 vectors150 */151 152 153 }154 155 156 void OBBTreeNode::forkBox(OBB* box)157 {158 /* get the longest axis of the box */159 float aLength = -1.0f;160 int axisNr = 0;161 for(int i = 0; i < 3; ++i)162 {163 if( aLength < box->axis[i])164 {165 aLength = box->axis[i];166 axisNr = i;167 }168 }169 170 /* get the closest vertex near the center */171 125 172 126 } … … 191 145 192 146 void OBBTreeNode::drawBVPolygon(int currentDepth, const int depth) const 193 { 194 this->bvElement->axis; 195 196 glBegin(GL_TRIANGLE); 197 glVertex3f(this->bvElement->center ); 198 glEnd(); 199 } 147 {} 200 148 201 149 -
orxonox/tags/0.3.0-pre-alpha/src/lib/collision_detection/obb_tree_node.h
r4557 r4559 14 14 // FORWARD DEFINITION 15 15 class BoundingVolume; 16 class OBB;17 16 //struct sVec3D; 18 17 … … 36 35 virtual void drawBVBlended(int currentDepth, const int depth) const; 37 36 38 private:39 OBB* createBox();40 void calculateBoxAttributes(OBB* box);41 void forkBox(OBB* box);42 43 44 37 45 38 protected: -
orxonox/tags/0.3.0-pre-alpha/src/story_entities/world.cc
r4558 r4559 506 506 new PhysicsConnection(system, gravity); 507 507 // new PhysicsConnection(this->localPlayer, gravity); 508 509 508 510 509 TestEntity* testEntity = new TestEntity();
Note: See TracChangeset
for help on using the changeset viewer.