NewtonCollision* MakeConvexHull(const DemoEntity* const bodyPart) const { dVector points[1024 * 16]; const DemoEntity* const meshEntity = FindMesh(bodyPart); DemoMesh* const mesh = (DemoMesh*)meshEntity->GetMesh(); dAssert(mesh->IsType(DemoMesh::GetRttiType())); dAssert(mesh->m_vertexCount && (mesh->m_vertexCount < int(sizeof(points) / sizeof(points[0])))); // go over the vertex array and find and collect all vertices's weighted by this bone. const dFloat* const array = mesh->m_vertex; for (int i = 0; i < mesh->m_vertexCount; i++) { points[i][0] = array[i * 3 + 0]; points[i][1] = array[i * 3 + 1]; points[i][2] = array[i * 3 + 2]; points[i][3] = 0.0f; } dMatrix matrix(meshEntity->GetMeshMatrix()); matrix = matrix * meshEntity->GetCurrentMatrix(); //matrix = matrix * bodyPart->GetParent()->GetCurrentMatrix(); matrix.TransformTriplex(&points[0][0], sizeof(dVector), &points[0][0], sizeof(dVector), mesh->m_vertexCount); // return NewtonCreateConvexHull(GetWorld(), mesh->m_vertexCount, &points[0][0], sizeof(dVector), 1.0e-3f, SERVO_VEHICLE_DEFINITION::m_bodyPart, NULL); return NewtonCreateConvexHull(GetWorld(), mesh->m_vertexCount, &points[0][0], sizeof(dVector), 1.0e-3f, 0, NULL); }
bool DexSkinMesh::SetTexture(int8 meshId, int8 textureId) { DexMesh* mesh = FindMesh(meshId); DEX_ENSURE_B(mesh); mesh->m_iTextureId = textureId; return true; }
void DexSkinMesh::AddMeshTriangle(int8 meshId, int32 index0, int32 index1, int32 index2) { DexMesh* pMesh = FindMesh(meshId); DEX_ENSURE(pMesh != NULL); pMesh->m_vecIndices.push_back(index0); pMesh->m_vecIndices.push_back(index1); pMesh->m_vecIndices.push_back(index2); }
DexSkinMesh::DexMesh* DexSkinMesh::AddMesh(int8 meshId) { DexMesh* mesh = FindMesh(meshId); DEX_ENSURE_P(mesh == NULL); mesh = new DexMesh; mesh->id = meshId; m_vecMeshs.push_back(mesh); return mesh; }
bool VsMeshMgr::ContainesMesh(std::string strFilename) { std::pair<std::string, osg::ref_ptr<osg::Node>> MeshPair; if(FindMesh(strFilename, MeshPair, false)) return true; else return false; }
bool ExportScene::AddMesh( ExportMeshBase* pMesh ) { if( !pMesh ) return false; if( FindMesh( pMesh->GetName() ) ) return false; m_vMeshes.push_back( pMesh ); return true; }
void DexSkinMesh::SetMeshIndices(int8 meshId, void* indics, int32 count) { DexMesh* mesh = FindMesh(meshId); DEX_ENSURE(mesh); mesh->m_vecIndices.clear(); mesh->m_vecIndices.resize(count); memcpy(&mesh->m_vecIndices[0], indics, sizeof(int32)*count); //for (uint32 i = 0; i < count; ++i) // mesh->m_vecIndices.push_back(((int32*)indics)[i]); }
void DexSkinMesh::SetMeshVertexs(int8 meshId, void* vertexs, int32 count) { DexMesh* mesh = FindMesh(meshId); DEX_ENSURE(mesh); mesh->m_vecVertexsBuffer.clear(); mesh->m_vecVertexsBuffer.resize(count); memcpy(&mesh->m_vecVertexsBuffer[0], vertexs, sizeof(stMeshVertex)*count); //for (uint32 i = 0; i < count; ++i) // mesh->m_vecVertexs.push_back(((stVertex3*)vertexs)[i]); }
DexSkinMesh::DexMesh* DexSkinMesh::AddMesh(const char* meshName) { DexMesh* mesh = FindMesh(meshName); DEX_ENSURE_P(mesh == NULL); mesh = new DexMesh; mesh->id = m_vecMeshs.size(); memcpy(mesh->name, meshName, strlen(meshName)); m_vecMeshs.push_back(mesh); return mesh; }
void DexSkinMesh::AddVertex(int8 meshId, const DexVector3& pos, const DexVector3& normal, const DexVector2& uv) { DexMesh* mesh = FindMesh(meshId); DEX_ENSURE(mesh); if (!FindVertex(pos)) {//添加新顶点并绑到根节点上 AddVertex(pos, NULL, NULL, 0); } mesh->AddVertex(pos, normal, uv.x, uv.y); }
void VsMeshMgr::ReleaseMesh(std::string strFilename) { int iIndex=0; std::pair<std::string, osg::ref_ptr<osg::Node>> MeshPair; if(!FindMesh(strFilename, MeshPair, false)) return; MeshPair.second.release(); m_aryMeshes.Remove(Std_CheckString(strFilename)); }
osg::Node *VsMeshMgr::LoadMesh(std::string strFilename) { std::pair<std::string, osg::ref_ptr<osg::Node>> MeshPair; //If not found then load it. if(!FindMesh(strFilename, MeshPair, false)) return AddMesh(strFilename); else { std::string strCreateDate = FileCreateTime(strFilename); //If the create dates match then use this one. //If they do not then lets reload it. if(strCreateDate == MeshPair.first) return MeshPair.second.get(); else { ReleaseMesh(strFilename); return AddMesh(strFilename); } } }
void DexSkinMesh::AddVertex(int8 meshId, const DexVector3& pos, const DexVector3& normal, const DexVector2& uv, int16* JointId, float* weight, uint16 jointCount) { DexMesh* mesh = FindMesh(meshId); DEX_ENSURE(mesh); stMeshVertex vertex; vertex.pos = pos; vertex.normal = normal; vertex.color = DEXCOLOR_WHITE; vertex.uv = uv; if (JointId == NULL) {//bind to root vertex.JointIndex[0] = 0; vertex.JointWeights[0] = 1.0f; } else { for (uint16 i = 0; i < jointCount; ++i) { vertex.JointIndex[i] = JointId[i]; vertex.JointWeights[i] = weight[i]; } } mesh->m_vecVertexsBuffer.push_back(vertex); }
void L3DS::ReadKeyframeData(const LChunk &parent) { uint frames = 0; LChunk node_hdr; node_hdr.id = NODE_HDR; char str[20]; LMesh *mesh; GotoChunk(parent); if (!FindChunk(node_hdr, parent)) return; GotoChunk(node_hdr); ReadASCIIZ(str, 19); mesh = FindMesh(str); if (mesh == 0) return; GotoChunk(parent); // read the pivot //LVector3 pivot = zero3; LChunk pivotchunk; pivotchunk.id = PIVOT; if (FindChunk(pivotchunk, parent)) { GotoChunk(pivotchunk); /*pivot.x =*/ ReadFloat(); /*pivot.y =*/ ReadFloat(); /*pivot.z =*/ ReadFloat(); } GotoChunk(parent); // read frame 0 from the position track //LVector3 pos = zero3; frames = 0; LChunk poschunk; poschunk.id = POS_TRACK_TAG; if (FindChunk(poschunk, parent)) { GotoChunk(poschunk); // read the trackheader structure ReadShort(); ReadInt(); ReadInt(); frames = ReadInt(); if (frames > 0) { ReadKeyheader(); /*pos.x =*/ ReadFloat(); /*pos.y =*/ ReadFloat(); /*pos.z =*/ ReadFloat(); } } GotoChunk(parent); // now read the rotation track //LVector4 rot = zero4; LChunk rotchunk; rotchunk.id = ROT_TRACK_TAG; frames = 0; if (FindChunk(rotchunk, parent)) { GotoChunk(rotchunk); // read the trackheader structure ReadShort(); ReadInt(); ReadInt(); frames = ReadInt(); if (frames > 0) { ReadKeyheader(); /*rot.x =*/ ReadFloat(); /*rot.y =*/ ReadFloat(); /*rot.z =*/ ReadFloat(); /*rot.w =*/ ReadFloat(); } } GotoChunk(parent); // now read the scaling chunk //LVector3 scale; //scale.x = 1; //scale.y = 1; //scale.z = 1; LChunk scalechunk; scalechunk.id = SCL_TRACK_TAG; frames = 0; if (FindChunk(scalechunk, parent)) { GotoChunk(scalechunk); // read the trackheader structure ReadShort(); ReadInt(); ReadInt(); frames = ReadInt(); if (frames > 0) { ReadKeyheader(); /*scale.x =*/ ReadFloat(); /*scale.y =*/ ReadFloat(); /*scale.z =*/ ReadFloat(); } } GotoChunk(parent); }