8#include <OgreSubMesh.h>
9#include <OgreSceneNode.h>
14 namespace CollisionPrimitives
35 NewtonDestroyCollision(
m_col);
58 NewtonDestroyCollision(
m_col);
62 NewtonCollision* sphere_col = 0;
63 if ((size.x == size.y) && (size.y == size.z))
67 float radius = std::min(std::min(size.x, size.y), size.z);
68 Ogre::Vector3 scale = Ogre::Vector3(size.x / radius, size.y / radius, size.z / radius);
70 NewtonCollisionSetScale(
m_col, dFloat(scale.x), dFloat(scale.y), dFloat(scale.z));
82 const Ogre::Quaternion& orient,
const Ogre::Vector3& pos) :
ConvexCollision(world)
89 NewtonDestroyCollision(
m_col);
105 const Ogre::Quaternion& orient,
const Ogre::Vector3& pos) :
ConvexCollision(world)
112 NewtonDestroyCollision(
m_col);
128 const Ogre::Quaternion& orient,
const Ogre::Vector3& pos) :
ConvexCollision(world)
135 NewtonDestroyCollision(
m_col);
150 const Ogre::Quaternion& orient,
const Ogre::Vector3& pos) :
ConvexCollision(world)
157 NewtonDestroyCollision(
m_col);
177 Ogre::MeshPtr mesh = obj->getMesh();
180 unsigned short sub = mesh->getNumSubMeshes();
182 size_t total_verts = 0;
184 Ogre::VertexData* v_data;
185 bool addedShared =
false;
187 for (
unsigned short i = 0; i < sub; i++)
189 Ogre::SubMesh* sub_mesh = mesh->getSubMesh(i);
190 if (sub_mesh->useSharedVertices)
194 v_data = mesh->sharedVertexData;
195 total_verts += v_data->vertexCount;
202 v_data = sub_mesh->vertexData;
203 total_verts += v_data->vertexCount;
210 Ogre::Vector3* vertices =
new Ogre::Vector3[total_verts];
211 unsigned int offset = 0;
214 for (
unsigned short i = 0; i < sub; i++)
216 Ogre::SubMesh* sub_mesh = mesh->getSubMesh(i);
217 Ogre::VertexDeclaration* v_decl;
218 const Ogre::VertexElement* p_elem;
224 if (sub_mesh->useSharedVertices)
228 v_data = mesh->sharedVertexData;
229 v_count = v_data->vertexCount;
230 v_decl = v_data->vertexDeclaration;
231 p_elem = v_decl->findElementBySemantic(Ogre::VES_POSITION);
237 v_data = sub_mesh->vertexData;
238 v_count = v_data->vertexCount;
239 v_decl = v_data->vertexDeclaration;
240 p_elem = v_decl->findElementBySemantic(Ogre::VES_POSITION);
245 size_t start = v_data->vertexStart;
247 Ogre::HardwareVertexBufferSharedPtr v_sptr = v_data->vertexBufferBinding->getBuffer(p_elem->getSource());
248 unsigned char* v_ptr =
static_cast<unsigned char*
>(v_sptr->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
249 unsigned char* v_offset;
252 for (
size_t j = start; j < (start + v_count); j++)
255 v_offset = v_ptr + (j * v_sptr->getVertexSize());
256 p_elem->baseVertexPointerToElement(v_offset, &v_Posptr);
259 vertices[offset].x = *v_Posptr; v_Posptr++;
260 vertices[offset].y = *v_Posptr; v_Posptr++;
261 vertices[offset].z = *v_Posptr; v_Posptr++;
263 vertices[offset] *= scale;
279 NewtonDestroyCollision(
m_col);
283 m_col = NewtonCreateConvexHull(
m_world->
getNewtonWorld(), (
int)total_verts, (
float*)&vertices[0].x,
sizeof(Ogre::Vector3), tolerance,
id, &matrix[0]);
302 NewtonDestroyCollision(
m_col);
306 m_col = NewtonCreateConvexHull(
m_world->
getNewtonWorld(), vertcount, (
float*)&verts[0].x,
sizeof(Ogre::Vector3), tolerance,
id, &matrix[0]);
320 NewtonDestroyCollision(
m_col);
326 NewtonMeshBeginFace(nmesh);
328 Ogre::MeshPtr mesh = obj->getMesh();
330 unsigned short sub = mesh->getNumSubMeshes();
332 for (
unsigned short cs = 0; cs < sub; cs++)
334 Ogre::SubMesh* sub_mesh = mesh->getSubMesh(cs);
337 Ogre::VertexData* v_data;
339 if (sub_mesh->useSharedVertices)
341 v_data = mesh->sharedVertexData;
345 v_data = sub_mesh->vertexData;
349 Ogre::VertexDeclaration* v_decl = v_data->vertexDeclaration;
350 const Ogre::VertexElement* p_elem = v_decl->findElementBySemantic(Ogre::VES_POSITION);
353 Ogre::HardwareVertexBufferSharedPtr v_sptr = v_data->vertexBufferBinding->getBuffer(p_elem->getSource());
354 unsigned char* v_ptr =
static_cast<unsigned char*
>(v_sptr->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
357 Ogre::IndexData* i_data = sub_mesh->indexData;
358 size_t index_count = i_data->indexCount;
359 size_t poly_count = index_count / 3;
362 Ogre::HardwareIndexBufferSharedPtr i_sptr = i_data->indexBuffer;
365 bool uses32bit = (i_sptr->getType() == Ogre::HardwareIndexBuffer::IT_32BIT);
366 Ogre::uint32* i_Longptr;
367 Ogre::uint16* i_Shortptr;
371 i_Longptr =
static_cast<Ogre::uint32*
>(i_sptr->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
376 i_Shortptr =
static_cast<Ogre::uint16*
>(i_sptr->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
383 for (
size_t i = 0; i < poly_count; i++)
385 Ogre::Vector3 poly_verts[3];
386 unsigned char* v_offset;
392 for (
int j = 0; j < 3; j++)
394 idx = i_Longptr[i_offset + j];
395 v_offset = v_ptr + (idx * v_sptr->getVertexSize());
396 p_elem->baseVertexPointerToElement(v_offset, &v_Posptr);
398 poly_verts[j].x = *v_Posptr; v_Posptr++;
399 poly_verts[j].y = *v_Posptr; v_Posptr++;
400 poly_verts[j].z = *v_Posptr; v_Posptr++;
402 poly_verts[j] *= scale;
407 for (
int j = 0; j < 3; j++)
409 idx = i_Shortptr[i_offset + j];
410 v_offset = v_ptr + (idx * v_sptr->getVertexSize());
411 p_elem->baseVertexPointerToElement(v_offset, &v_Posptr);
415 poly_verts[j].x = *v_Posptr; v_Posptr++;
416 poly_verts[j].y = *v_Posptr; v_Posptr++;
417 poly_verts[j].z = *v_Posptr; v_Posptr++;
419 poly_verts[j] *= scale;
422 NewtonMeshAddFace(nmesh, 3, (
float*)&poly_verts[0].x,
sizeof(Ogre::Vector3), cs);
433 NewtonMeshEndFace(nmesh);
434 NewtonMeshFixTJoints(nmesh);
435 NewtonMesh*
const omesh = NewtonMeshApproximateConvexDecomposition(nmesh, 0.5f, 0.1f, 10, 1000, NULL, NULL);
438 NewtonMeshDestroy(nmesh);
442 NewtonDestroyCollision(
m_col);
451 NewtonMeshDestroy(omesh);
472 Ogre::MeshPtr mesh = obj->getMesh();
475 unsigned short sub = mesh->getNumSubMeshes();
476 int countConvexFaces = 0;
478 for (
unsigned short cs = 0; cs < sub; cs++)
480 Ogre::SubMesh* sub_mesh = mesh->getSubMesh(cs);
483 Ogre::VertexData* v_data;
485 if (sub_mesh->useSharedVertices)
487 v_data = mesh->sharedVertexData;
491 v_data = sub_mesh->vertexData;
495 Ogre::VertexDeclaration* v_decl = v_data->vertexDeclaration;
496 const Ogre::VertexElement* p_elem = v_decl->findElementBySemantic(Ogre::VES_POSITION);
499 Ogre::HardwareVertexBufferSharedPtr v_sptr = v_data->vertexBufferBinding->getBuffer(p_elem->getSource());
500 unsigned char* v_ptr =
static_cast<unsigned char*
>(v_sptr->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
503 Ogre::IndexData* i_data = sub_mesh->indexData;
504 size_t index_count = i_data->indexCount;
505 size_t poly_count = index_count / 3;
508 Ogre::HardwareIndexBufferSharedPtr i_sptr = i_data->indexBuffer;
511 bool uses32bit = (i_sptr->getType() == Ogre::HardwareIndexBuffer::IT_32BIT);
512 Ogre::uint32* i_Longptr;
513 Ogre::uint16* i_Shortptr;
517 i_Longptr =
static_cast<Ogre::uint32*
>(i_sptr->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
522 i_Shortptr =
static_cast<Ogre::uint16*
>(i_sptr->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
528 for (
size_t i = 0; i < poly_count; i++)
530 Ogre::Vector3 poly_verts[3];
531 unsigned char* v_offset;
537 for (
int j = 0; j < 3; j++)
539 idx = i_Longptr[i_offset + j];
540 v_offset = v_ptr + (idx * v_sptr->getVertexSize());
541 p_elem->baseVertexPointerToElement(v_offset, &v_Posptr);
543 poly_verts[j].x = *v_Posptr; v_Posptr++;
544 poly_verts[j].y = *v_Posptr; v_Posptr++;
545 poly_verts[j].z = *v_Posptr; v_Posptr++;
547 poly_verts[j] *= scale;
552 for (
int j = 0; j < 3; j++)
554 idx = i_Shortptr[i_offset + j];
555 v_offset = v_ptr + (idx * v_sptr->getVertexSize());
556 p_elem->baseVertexPointerToElement(v_offset, &v_Posptr);
560 poly_verts[j].x = *v_Posptr; v_Posptr++;
561 poly_verts[j].y = *v_Posptr; v_Posptr++;
562 poly_verts[j].z = *v_Posptr; v_Posptr++;
564 poly_verts[j] *= scale;
574 Ogre::Vector3 rev_poly_verts[3];
575 rev_poly_verts[0] = poly_verts[0];
576 rev_poly_verts[0] = poly_verts[2];
577 rev_poly_verts[0] = poly_verts[1];
583 bool convexface =
true;
584 Ogre::Vector3 p0(poly_verts[2]);
585 for (
int k = 0; k < 3; k++)
587 Ogre::Vector3 p1(poly_verts[k]);
588 Ogre::Vector3 edge(p1 - p0);
589 float mag2 = edge.dotProduct(edge);
597 Ogre::Vector3 edge0(poly_verts[2] - poly_verts[0]);
598 Ogre::Vector3 edge1(poly_verts[1] - poly_verts[0]);
599 Ogre::Vector3 normal(edge0 * edge1);
600 float mag2 = normal.dotProduct(normal);
601 if ((mag2 != 0.0) && (mag2 < 1.0e-7f))
618 if (countConvexFaces)
625 NewtonDestroyCollision(
m_col);
647 int numPolys = numIndices / 3;
649 Ogre::Vector3 *vecVertices =
new Ogre::Vector3[numVertices];
651 for (
int curVertex = 0; curVertex < numVertices; curVertex++)
653 vecVertices[curVertex].x = vertices[0 + curVertex * 3];
654 vecVertices[curVertex].y = vertices[1 + curVertex * 3];
655 vecVertices[curVertex].z = vertices[2 + curVertex * 3];
658 for (
int poly = 0; poly < numPolys; poly++)
660 Ogre::Vector3 poly_verts[3];
664 poly_verts[0] = vecVertices[indices[0 + poly * 3]];
665 poly_verts[1] = vecVertices[indices[1 + poly * 3]];
666 poly_verts[2] = vecVertices[indices[2 + poly * 3]];
670 poly_verts[0] = vecVertices[indices[0 + poly * 3]];
671 poly_verts[2] = vecVertices[indices[1 + poly * 3]];
672 poly_verts[1] = vecVertices[indices[2 + poly * 3]];
678 delete[] vecVertices;
688 unsigned int numPolys = indexData->indexCount / 3;
689 Ogre::HardwareIndexBufferSharedPtr hwIndexBuffer = indexData->indexBuffer;
690 size_t indexSize = hwIndexBuffer->getIndexSize();
691 void* indices = hwIndexBuffer->lock(Ogre::HardwareBuffer::HBL_READ_ONLY);
693 assert((indexSize == 2) || (indexSize == 4));
697 unsigned short* curIndex = (
unsigned short*)indices;
698 for (
unsigned int poly = 0; poly < numPolys; poly++)
700 Ogre::Vector3 poly_verts[3];
705 poly_verts[0] = vertices[*curIndex]; curIndex++;
706 poly_verts[1] = vertices[*curIndex]; curIndex++;
707 poly_verts[2] = vertices[*curIndex]; curIndex++;
711 poly_verts[0] = vertices[*curIndex]; curIndex++;
712 poly_verts[2] = vertices[*curIndex]; curIndex++;
713 poly_verts[1] = vertices[*curIndex]; curIndex++;
721 unsigned int* curIndex = (
unsigned int*)indices;
722 for (
unsigned int poly = 0; poly < numPolys; poly++)
724 Ogre::Vector3 poly_verts[3];
728 poly_verts[0] = vertices[*curIndex]; curIndex++;
729 poly_verts[1] = vertices[*curIndex]; curIndex++;
730 poly_verts[2] = vertices[*curIndex]; curIndex++;
734 poly_verts[0] = vertices[*curIndex]; curIndex++;
735 poly_verts[2] = vertices[*curIndex]; curIndex++;
736 poly_verts[1] = vertices[*curIndex]; curIndex++;
743 hwIndexBuffer->unlock();
749 Ogre::SceneNode::ObjectMap objmap = node->getAttachedObjects();
750 for (
unsigned int i = 0; i < objmap.size(); i++)
752 Ogre::MovableObject* mobj = objmap[i];
753 if (mobj->getMovableType() ==
"Entity")
755 Ogre::Entity* obj =
static_cast<Ogre::Entity*
>(mobj);
756 Ogre::Vector3 npos = node->_getDerivedPosition();
757 Ogre::Vector3 nscale = node->_getDerivedScale();
758 Ogre::Quaternion nquat = node->_getDerivedOrientation();
759 Ogre::MeshPtr mesh = obj->getMesh();
762 unsigned short sub = mesh->getNumSubMeshes();
764 for (
unsigned short cs = 0; cs < sub; cs++)
766 Ogre::SubMesh* sub_mesh = mesh->getSubMesh(cs);
769 Ogre::VertexData* v_data;
771 if (sub_mesh->useSharedVertices)
773 v_data = mesh->sharedVertexData;
777 v_data = sub_mesh->vertexData;
781 Ogre::VertexDeclaration* v_decl = v_data->vertexDeclaration;
782 const Ogre::VertexElement* p_elem = v_decl->findElementBySemantic(Ogre::VES_POSITION);
785 Ogre::HardwareVertexBufferSharedPtr v_sptr = v_data->vertexBufferBinding->getBuffer(p_elem->getSource());
786 unsigned char* v_ptr =
static_cast<unsigned char*
>(v_sptr->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
789 Ogre::IndexData* i_data = sub_mesh->indexData;
790 size_t index_count = i_data->indexCount;
791 size_t poly_count = index_count / 3;
794 Ogre::HardwareIndexBufferSharedPtr i_sptr = i_data->indexBuffer;
797 bool uses32bit = (i_sptr->getType() == Ogre::HardwareIndexBuffer::IT_32BIT);
798 Ogre::uint32* i_Longptr;
799 Ogre::uint16* i_Shortptr;
803 i_Longptr =
static_cast<Ogre::uint32*
>(i_sptr->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
808 i_Shortptr =
static_cast<unsigned short*
>(i_sptr->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
814 for (
size_t i = 0; i < poly_count; i++)
816 Ogre::Vector3 poly_verts[3];
817 unsigned char* v_offset;
823 for (
int j = 0; j < 3; j++)
825 idx = i_Longptr[i_offset + j];
826 v_offset = v_ptr + (idx * v_sptr->getVertexSize());
827 p_elem->baseVertexPointerToElement(v_offset, &v_Posptr);
829 poly_verts[j].x = *v_Posptr; v_Posptr++;
830 poly_verts[j].y = *v_Posptr; v_Posptr++;
831 poly_verts[j].z = *v_Posptr; v_Posptr++;
833 poly_verts[j] = mainNode->_getDerivedOrientation().Inverse() * ((nquat * (poly_verts[j] * nscale)) + npos - mainNode->_getDerivedPosition()) / mainNode->_getDerivedScale() * scale;
838 for (
int j = 0; j < 3; j++)
840 idx = i_Shortptr[i_offset + j];
841 v_offset = v_ptr + (idx * v_sptr->getVertexSize());
842 p_elem->baseVertexPointerToElement(v_offset, &v_Posptr);
846 poly_verts[j].x = *v_Posptr; v_Posptr++;
847 poly_verts[j].y = *v_Posptr; v_Posptr++;
848 poly_verts[j].z = *v_Posptr; v_Posptr++;
850 poly_verts[j] = mainNode->_getDerivedOrientation().Inverse() * ((nquat * (poly_verts[j] * nscale)) + npos - mainNode->_getDerivedPosition()) / mainNode->_getDerivedScale() * scale;
860 Ogre::Vector3 rev_poly_verts[3];
861 rev_poly_verts[0] = poly_verts[0];
862 rev_poly_verts[0] = poly_verts[2];
863 rev_poly_verts[0] = poly_verts[1];
879 Ogre::SceneNode::ConstChildNodeIterator nodei = node->getChildIterator();
881 while (nodei.hasMoreElements())
883 const Ogre::SceneNode* subNode =
static_cast<const Ogre::SceneNode*
>(nodei.getNext());
893 NewtonDestroyCollision(
m_col);
901 NewtonTreeCollisionBeginBuild(
m_col);
906 NewtonTreeCollisionAddFace(
m_col, 3, (
float*)&polys[0].x,
sizeof(Ogre::Vector3), ID);
913 NewtonTreeCollisionEndBuild(
m_col, optimize);
918 catch (std::exception &)
922 NewtonDestroyCollision(
m_col);
940 ((
Raycast*)userData)->userCallback(bod, Ogre::Real(distance), Ogre::Vector3(Ogre::Real(normal[0]), Ogre::Real(normal[1]), Ogre::Real(normal[2])), faceId);
942 ((
Raycast*)userData)->m_treecollisioncallback_bodyalreadyadded =
true;
956 ((Raycast*)userData)->userCallback( bod, interception, Ogre::Vector3(normal[0], normal[1], normal[2]), faceId );
958 ((Raycast*)userData)->m_treecollisioncallback_bodyalreadyadded = true;
968 NewtonTreeCollisionSetUserRayCastCallback(col, NULL);
971 int TreeCollisionSceneParser::count = 0;
985 Ogre::Quaternion rootOrient = Ogre::Quaternion::IDENTITY;
986 Ogre::Vector3 rootPos = Ogre::Vector3::ZERO;
987 Ogre::Vector3 rootScale = startNode->getScale();;
989 _parseNode(startNode, rootOrient, rootPos, rootScale, fw);
994 void TreeCollisionSceneParser::_parseNode(Ogre::SceneNode *node,
const Ogre::Quaternion &curOrient,
const Ogre::Vector3 &curPos,
const Ogre::Vector3 &curScale,
FaceWinding fw)
998 Ogre::Quaternion thisOrient = curOrient * node->getOrientation();
999 Ogre::Vector3 thisPos = curPos + (curOrient * (node->getPosition() * curScale));
1000 Ogre::Vector3 thisScale = curScale * node->getScale();
1002 Ogre::SceneNode::ChildNodeIterator child_it = node->getChildIterator();
1004 while (child_it.hasMoreElements())
1006 _parseNode((Ogre::SceneNode*)child_it.getNext(), thisOrient, thisPos, thisScale, fw);
1012 Ogre::SceneNode::ObjectMap objmap = node->getAttachedObjects();
1013 for (
unsigned int co = 0; co < objmap.size(); co++)
1015 Ogre::MovableObject* obj = objmap[co];
1016 if (obj->getMovableType() !=
"Entity")
1019 Ogre::Entity* ent = (Ogre::Entity*)obj;
1024 Ogre::MeshPtr mesh = ent->getMesh();
1027 unsigned short sub = mesh->getNumSubMeshes();
1029 for (
unsigned short cs = 0; cs < sub; cs++)
1031 Ogre::SubMesh* sub_mesh = mesh->getSubMesh(cs);
1034 Ogre::VertexData* v_data;
1036 if (sub_mesh->useSharedVertices)
1038 v_data = mesh->sharedVertexData;
1042 v_data = sub_mesh->vertexData;
1046 Ogre::VertexDeclaration* v_decl = v_data->vertexDeclaration;
1047 const Ogre::VertexElement* p_elem = v_decl->findElementBySemantic(Ogre::VES_POSITION);
1050 Ogre::HardwareVertexBufferSharedPtr v_sptr = v_data->vertexBufferBinding->getBuffer(p_elem->getSource());
1051 unsigned char* v_ptr =
static_cast<unsigned char*
>(v_sptr->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
1054 Ogre::IndexData* i_data = sub_mesh->indexData;
1055 size_t index_count = i_data->indexCount;
1056 size_t poly_count = index_count / 3;
1059 Ogre::HardwareIndexBufferSharedPtr i_sptr = i_data->indexBuffer;
1062 bool uses32bit = (i_sptr->getType() == Ogre::HardwareIndexBuffer::IT_32BIT);
1063 Ogre::uint32* i_Longptr;
1064 Ogre::uint16* i_Shortptr;
1068 i_Longptr =
static_cast<Ogre::uint32*
>(i_sptr->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
1072 i_Shortptr =
static_cast<Ogre::uint16*
>(i_sptr->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
1078 for (
size_t i = 0; i < poly_count; i++)
1080 Ogre::Vector3 poly_verts[3];
1081 unsigned char* v_offset;
1087 for (
int j = 0; j < 3; j++)
1089 idx = i_Longptr[i_offset + j];
1090 v_offset = v_ptr + (idx * v_sptr->getVertexSize());
1091 p_elem->baseVertexPointerToElement(v_offset, &v_Posptr);
1093 poly_verts[j].x = *v_Posptr; v_Posptr++;
1094 poly_verts[j].y = *v_Posptr; v_Posptr++;
1095 poly_verts[j].z = *v_Posptr; v_Posptr++;
1097 poly_verts[j] = thisPos + (thisOrient * (poly_verts[j] * curScale));
1102 for (
int j = 0; j < 3; j++)
1104 idx = i_Shortptr[i_offset + j];
1105 v_offset = v_ptr + (idx * v_sptr->getVertexSize());
1106 p_elem->baseVertexPointerToElement(v_offset, &v_Posptr);
1110 poly_verts[j].x = *v_Posptr; v_Posptr++;
1111 poly_verts[j].y = *v_Posptr; v_Posptr++;
1112 poly_verts[j].z = *v_Posptr; v_Posptr++;
1114 poly_verts[j] = thisPos + (thisOrient * (poly_verts[j] * curScale));
1124 Ogre::Vector3 rev_poly_verts[3];
1125 rev_poly_verts[0] = poly_verts[0];
1126 rev_poly_verts[0] = poly_verts[2];
1127 rev_poly_verts[0] = poly_verts[1];
1156 NewtonDestroyCollision(
m_col);
1166 unsigned int num = col_array.size();
1167 NewtonCompoundCollisionBeginAddRemove(
m_col);
1168 for (
unsigned int i = 0; i < num; i++)
1172 NewtonCompoundCollisionEndAddRemove(
m_col);
1190 dFloat* vertices =
new dFloat[15];
1191 unsigned short idx = 0;
1194 for (
int ix = -1; ix <= 1; ix += 2)
1196 for (
int iz = -1; iz <= 1; iz += 2)
1198 vertices[idx++] = (size.x / 2.0f) * ix;
1199 vertices[idx++] = -(size.y / 3.0f);
1200 vertices[idx++] = (size.z / 2.0f) * iz;
1205 vertices[idx++] = 0.0f;
1206 vertices[idx++] = (size.y*2.0f / 3.0f);
1207 vertices[idx++] = 0.0f;
1212 NewtonDestroyCollision(
m_col);
main class for all Rigid Bodies in the system.
represents a shape for collision detection
NewtonCollision *const getNewtonCollision() const
retrieve the Newton pointer
Box(const World *world)
constructor
Capsule(const World *world)
constructor
ChamferCylinder(const World *world)
constructor
CompoundCollision(const World *world)
constructor
ConcaveHull(const World *world)
constructor
Cone(const World *world)
constructor
ConvexHull(const World *world)
constructor
Cylinder(const World *world)
constructor
Ellipsoid(const World *world)
constructor
Null(const World *world)
constructor
Pyramid(const World *world)
constructor
TreeCollision - complex polygonal collision.
TreeCollision(const World *world)
constructor
void start(int id)
start a tree collision creation
static dFloat _CDECL newtonRayCastCallback(const NewtonBody *const body, const NewtonCollision *const treeCollision, dFloat distance, dFloat *normal, int faceId, void *userData)
used internally
void AddEntities(const Ogre::SceneNode *node, const Ogre::SceneNode *mainNode, const Ogre::Vector3 scale, FaceWinding fw=FW_DEFAULT)
void setRayCastCallbackactive(bool active=true)
set RayCastCallback active/disabled
void finish(bool optimize)
finish the tree collision
void addPoly(Ogre::Vector3 *polys, unsigned int ID)
add a poly to the tree collision
virtual bool entityFilter(const Ogre::SceneNode *currentNode, const Ogre::Entity *currentEntity, FaceWinding &fw)
this is a user-inherited function that lets you filter which Entities will be added to the treeCollis...
void parseScene(Ogre::SceneNode *startNode, int id, bool optimize=true, FaceWinding fw=FW_DEFAULT)
parse the scene.
TreeCollisionSceneParser(OgreNewt::World *world)
represents a collision shape that is explicitly convex.
represents a physics world.
NewtonWorld * getNewtonWorld() const
retrieves a pointer to the NewtonWorld
FaceWinding
face-winding enum.
_OgreNewtExport void QuatPosToMatrix(const Ogre::Quaternion &quat, const Ogre::Vector3 &pos, dFloat *matrix)
Take a Quaternion and Position Matrix and create a Newton-happy float matrix!