void RiemannianGeodesic<Real>::ComputeGeodesic (const GVector<Real>& point0, const GVector<Real>& point1, int& quantity, GVector<Real>*& path) { assertion(Subdivisions < 32, "Exceeds maximum iterations\n"); quantity = (1 << Subdivisions) + 1; path = new1<GVector<Real> >(quantity); int i; for (i = 0; i < quantity; ++i) { path[i].SetSize(mDimension); } mCurrentQuantity = 2; path[0] = point0; path[1] = point1; for (mSubdivide = 1; mSubdivide <= Subdivisions; ++mSubdivide) { // A subdivision essentially doubles the number of points. int newQuantity = 2*mCurrentQuantity - 1; assertion(newQuantity <= quantity, "Unexpected condition.\n"); // Copy the old points so that there are slots for the midpoints // during the subdivision, the slots interleaved between the old // points. for (i = mCurrentQuantity-1; i > 0; --i) { path[2*i] = path[i]; } // Subdivide the polyline. for (i = 0; i <= mCurrentQuantity-2; ++i) { Subdivide(path[2*i], path[2*i+1], path[2*i+2]); } mCurrentQuantity = newQuantity; // Refine the current polyline vertices. for (mRefine = 1; mRefine <= Refinements; ++mRefine) { for (i = 1; i <= mCurrentQuantity-2; ++i) { Refine(path[i-1], path[i], path[i+1]); } } } assertion(mCurrentQuantity == quantity, "Unexpected condition\n"); mSubdivide = 0; mRefine = 0; mCurrentQuantity = 0; }
void Subdivide(float *v1, float *v2, float *v3, int depth) { GLfloat v12[3], v23[3], v31[3]; GLint i; if (depth==0) { DrawTriangle(v1, v2, v3); return; } for (i=0; i<3; i++) { v12[i] = v1[i]+v2[i]; v23[i] = v2[i]+v3[i]; v31[i] = v3[i]+v1[i]; } Normalize(v12); Normalize(v23); Normalize(v31); Subdivide(v1, v12, v31, depth-1); Subdivide(v2, v23, v12, depth-1); Subdivide(v3, v31, v23, depth-1); Subdivide(v12, v23, v31, depth-1); }
void KDTree::Build(Scene* scene) { TriangleList *triangles= scene->GetTriangles(); aabb box = scene->GetBoundingBox(); Subdivide(*m_Root,triangles,box,0); //Build the ropes in the kdtree KDTreeNode* RS[6]; for(int i=0; i<6; i++) RS[i] = NULL; ProcessNode(m_Root,RS); }
void SpherePointCloud::Subdivide(glm::vec3 pV1, glm::vec3 pV2, glm::vec3 pV3, unsigned short pDepth) { if( pDepth == 0 ) { CreateSphereCloudTriangle( pV1, pV2, pV3 ); } else { // Find the midpoint of each edge of the triangle glm::vec3 v12 = pV1 + pV2; glm::vec3 v23 = pV2 + pV3; glm::vec3 v31 = pV3 + pV1; // It's not necessary to divide by 2 the midpoints because we normalize them v12 = glm::normalize(v12); v23 = glm::normalize(v23); v31 = glm::normalize(v31); Subdivide( pV1, v12, v31, pDepth - 1 ); Subdivide( pV2, v23, v12, pDepth - 1 ); Subdivide( pV3, v31, v23, pDepth - 1 ); Subdivide( v12, v23, v31, pDepth - 1 ); } }
// ------------------------------------------------------------------------------------------------ // Create a subdivision sphere void StandardShapes::MakeSphere(unsigned int tess, std::vector<aiVector3D>& positions) { // Reserve enough storage. Every subdivision // splits each triangle in 4, the icosahedron consists of 60 verts positions.reserve(positions.size()+60 * integer_pow(4, tess)); // Construct an icosahedron to start with MakeIcosahedron(positions); // ... and subdivide it until the requested output // tesselation is reached for (unsigned int i = 0; i<tess;++i) Subdivide(positions); }
void Sky::BuildGeoSphere(UINT numSubdivisions, float radius, std::vector<D3DXVECTOR3>& vertices, std::vector<DWORD>& indices) { // Put a cap on the number of subdivisions. numSubdivisions = Min(numSubdivisions, UINT(5)); // Approximate a sphere by tesselating an icosahedron. const float X = 0.525731f; const float Z = 0.850651f; D3DXVECTOR3 pos[12] = { D3DXVECTOR3(-X, 0.0f, Z), D3DXVECTOR3(X, 0.0f, Z), D3DXVECTOR3(-X, 0.0f, -Z), D3DXVECTOR3(X, 0.0f, -Z), D3DXVECTOR3(0.0f, Z, X), D3DXVECTOR3(0.0f, Z, -X), D3DXVECTOR3(0.0f, -Z, X), D3DXVECTOR3(0.0f, -Z, -X), D3DXVECTOR3(Z, X, 0.0f), D3DXVECTOR3(-Z, X, 0.0f), D3DXVECTOR3(Z, -X, 0.0f), D3DXVECTOR3(-Z, -X, 0.0f) }; DWORD k[60] = { 1,4,0, 4,9,0, 4,5,9, 8,5,4, 1,8,4, 1,10,8, 10,3,8, 8,3,5, 3,2,5, 3,7,2, 3,10,7, 10,6,7, 6,11,7, 6,0,11, 6,1,0, 10,1,6, 11,0,9, 2,11,9, 5,2,9, 11,2,7 }; vertices.resize(12); indices.resize(60); for(int i = 0; i < 12; ++i) vertices[i] = pos[i]; for(int i = 0; i < 60; ++i) indices[i] = k[i]; for(UINT i = 0; i < numSubdivisions; ++i) Subdivide(vertices, indices); // Project vertices onto sphere and scale. for(size_t i = 0; i < vertices.size(); ++i) { D3DXVec3Normalize(&vertices[i], &vertices[i]); vertices[i] *= radius; } }
void QuadNode::Insert(ISceneNode * sceneNode) { _numberOfObject++; if (_children[0]!=NULL) { int numOfChild = PositionInChild(sceneNode->GetCollider()); if (numOfChild != -1) { _children[numOfChild]->Insert(sceneNode); return; } } _objlist.InsertAtLast(sceneNode); sceneNode->_quadNode = this; sceneNode->_quadTree=_tree; if (_objlist.GetLength()>_capacity &&_level < _maxLevel) { if (_children[0]==NULL) { Subdivide(); } int i = 0; while (i < _objlist.GetLength()) { int numOfChild = PositionInChild(sceneNode->GetCollider()); if (numOfChild!=-1) { _children[numOfChild]->Insert(sceneNode); _objlist.RemoveAtIndex(i); } else { i++; } } } }
Sphere::Sphere(int numSubdiv, bool smooth) : _vertices(NULL), _indices(NULL), _numVerts(0) { // not exception-safe _numVerts = NumVertices(numSubdiv); _vertices = new Mesh::Vertex[_numVerts]; _indices = new Mesh::Index[_numVerts]; Mesh::Vertex* vert = _vertices; unsigned numTris = NumTriangles(numSubdiv); for(Mesh::Index i = 0; i < 20; ++i) { Subdivide(&vert, numSubdiv, smooth, g_vertices[g_indices[i][0]].position, g_vertices[g_indices[i][1]].position, g_vertices[g_indices[i][2]].position); } for(Mesh::Index i = 0; i < _numVerts; i++) { _indices[i] = i; } }
void Quadtree::QuadtreeStatic(Voxel* v, int offsetX, int offsetY){ v->setOffset(offsetX, offsetY); if(ComputeHeightAverage(v->getOffsetX(), v->getOffsetY(), v->getLength() * 2) > delta){ if(v->getLength() > resolution){ Voxel* subdivide = Subdivide(v); QuadtreeStatic(&subdivide[0], offsetX, offsetY); QuadtreeStatic(&subdivide[1], offsetX + v->getLength(), offsetY); QuadtreeStatic(&subdivide[2], offsetX + v->getLength(), offsetY + v->getLength()); QuadtreeStatic(&subdivide[3], offsetX, offsetY + v->getLength()); }else{ voxels.push_back(v); } }else{ voxels.push_back(v); } }
void SpherePointCloud::SetToQuasiUniform(unsigned char pDepth) { // Create the initial vertices and faces from the sphere cloud CreateIcosahedron(); QVector< unsigned int > tempFaces = mFaces; mFaces.clear(); // Each triangle has to be subdivided as many times as the sphere depth for( int i = 0; i < tempFaces.size(); i += 3 ) { int face1 = tempFaces.at(i); int face2 = tempFaces.at(i+1); int face3 = tempFaces.at(i+2); Subdivide( mVertices.at(face1), mVertices.at(face2), mVertices.at(face3), pDepth ); } mNumberOfPoints = mVertices.size(); ComputeQuasiUniformNeighbours(); SetMeshInformation(); }
void MyOctant::ConstructTree(void) { //If this method is tried to be applied to something else //other than the root, don't. if (m_nLevel != 0) return; m_nOctantCount = 1; //clear the tree KillBranches(); //Calculates the initial size of the octant CalculateInitialSize(); //If the base tree if (ContainsMoreThan(m_nIdealBOCount)) { Subdivide(); } //Add octant ID to BOs AssignIDtoBO(); }
WingedEdge WingedEdge::LinearSubdivide(std::map<Vertex, std::vector<Vertex> > &derivations) { return Subdivide(true, false, derivations); }
// -- A whimsical subdivision that creates pascal's triangle like structures. WingedEdge WingedEdge::SillyPascalSubdivide() { return Subdivide(false, true); }
// -- Public interface wrapper functions. WingedEdge WingedEdge::ButterflySubdivide(std::map<Vertex, std::vector<Vertex> > &derivations) { return Subdivide(false, false, derivations); }
// Interface function, performs butterfly subdivision that does not account for the internal special cases. // The subdivision only accounts for the boundaries and 6 regular vertices. WingedEdge WingedEdge::ButterflySubdivide() { return Subdivide(false, false); }
// Interface function, performs linear subdivision on the mesh. WingedEdge WingedEdge::LinearSubdivide() { return Subdivide(true, false); }
void KDTree::Subdivide(KDTreeNode &node,TriangleList *triangles,aabb& box,int depth) { if(!triangles)return ; int count = triangles->GetCount(); if( count < minTrianglesPerleafNode ||(depth>=20&&count<=maxTrianglesPerleafNode)) { node.SetTriangleList(triangles); node.Type = LEFT; node.box = box; return ; } aabb frontBox,backBox; real splitPosition; bool foundOptimalSplit = findOptimalSplitPositon(triangles,box,depth,splitPosition,frontBox, backBox); if(foundOptimalSplit == true) { node.Type = PATITION; node.SetAxis(depth%Dimension); node.SetSplitPosition(splitPosition); node.box = box; TriangleList *frontTriangles = new TriangleList(); TriangleList *backTriangles = new TriangleList(); for( int i=0; i < count; i++) { //Determine on which side of the split each //triangle belongs. TriangleNode * triangle= triangles->GetHead(); triangles->DeleteHead(); int position = partitionTriangle(triangle,depth,splitPosition); triangle->next = NULL; switch(position) { case kdBefore: frontTriangles->append(triangle); break; case kdAfter: backTriangles->append(triangle); break; case kdIntersection: //frontTriangles->append(triangle); backTriangles->append(triangle); break; } } node.m_lchild = new KDTreeNode(); node.m_rchild = new KDTreeNode(); Subdivide(*node.m_lchild,frontTriangles,frontBox,depth+1); Subdivide(*node.m_rchild,backTriangles,backBox,depth+1); }else { node.SetTriangleList(triangles); node.Type = LEFT; node.box = box; } }
void d3d::Geometry::CreateGeosphere(float radius, UINT numSubdivisions, MeshData& meshData) { // Put a cap on the number of subdivisions. numSubdivisions = numSubdivisions < 5u ? numSubdivisions :5u; // Approximate a sphere by tessellating an icosahedron. const float X = 0.525731f; const float Z = 0.850651f; XMFLOAT3 pos[12] = { XMFLOAT3(-X, 0.0f, Z), XMFLOAT3(X, 0.0f, Z), XMFLOAT3(-X, 0.0f, -Z), XMFLOAT3(X, 0.0f, -Z), XMFLOAT3(0.0f, Z, X), XMFLOAT3(0.0f, Z, -X), XMFLOAT3(0.0f, -Z, X), XMFLOAT3(0.0f, -Z, -X), XMFLOAT3(Z, X, 0.0f), XMFLOAT3(-Z, X, 0.0f), XMFLOAT3(Z, -X, 0.0f), XMFLOAT3(-Z, -X, 0.0f) }; DWORD k[60] = { 1,4,0, 4,9,0, 4,5,9, 8,5,4, 1,8,4, 1,10,8, 10,3,8, 8,3,5, 3,2,5, 3,7,2, 3,10,7, 10,6,7, 6,11,7, 6,0,11, 6,1,0, 10,1,6, 11,0,9, 2,11,9, 5,2,9, 11,2,7 }; meshData.VertexData.resize(12); meshData.IndexData.resize(60); for(UINT i = 0; i < 12; ++i) meshData.VertexData[i].Pos = pos[i]; for(UINT i = 0; i < 60; ++i) meshData.IndexData[i] = k[i]; for(UINT i = 0; i < numSubdivisions; ++i) Subdivide(meshData); // Project vertices onto sphere and scale. for(UINT i = 0; i < meshData.VertexData.size(); ++i) { // Project onto unit sphere. XMVECTOR n = XMVector3Normalize(XMLoadFloat3(&meshData.VertexData[i].Pos)); // Project onto sphere. XMVECTOR p = radius*n; XMStoreFloat3(&meshData.VertexData[i].Pos, p); XMStoreFloat3(&meshData.VertexData[i].Normal, n); // Derive texture coordinates from spherical coordinates. float theta = MathHelper::AngleFromXY( meshData.VertexData[i].Pos.x, meshData.VertexData[i].Pos.z); float phi = acosf(meshData.VertexData[i].Pos.y / radius); meshData.VertexData[i].Tex.x = theta/XM_2PI; meshData.VertexData[i].Tex.y = phi/XM_PI; } }
QmitkMoveROIToolGUI::QmitkMoveROIToolGUI() :QmitkToolGUI() { //std::cout << "hi from " << __FUNCSIG__ << std::endl; // create the visible widgets QBoxLayout* verticalLayout = new QVBoxLayout( this ); QBoxLayout* horizontalLayout = new QHBoxLayout(); verticalLayout->addLayout(horizontalLayout); QBoxLayout* horizontalLayout1 = new QHBoxLayout(); verticalLayout->addLayout(horizontalLayout1); QBoxLayout* horizontalLayout2 = new QHBoxLayout(); verticalLayout->addLayout(horizontalLayout2); QBoxLayout* horizontalLayout3 = new QHBoxLayout(); verticalLayout->addLayout(horizontalLayout3); QBoxLayout* horizontalLayout4 = new QHBoxLayout(); verticalLayout->addLayout(horizontalLayout4); QBoxLayout* horizontalLayout5 = new QHBoxLayout(); verticalLayout->addLayout(horizontalLayout5); QBoxLayout* horizontalLayout6 = new QHBoxLayout(); verticalLayout->addLayout(horizontalLayout6); m_SelectSurfaceBox = new QComboBox(); horizontalLayout->addWidget(m_SelectSurfaceBox); connect(m_SelectSurfaceBox, SIGNAL(activated(int)), this, SLOT(SelectSurface(int))); QPushButton* pbtn_JumpToPosition = new QPushButton(); pbtn_JumpToPosition->setText("Jump to Position"); horizontalLayout->addWidget(pbtn_JumpToPosition); connect(pbtn_JumpToPosition, SIGNAL(clicked()), this, SLOT(JumpToPosition())); QLabel* label = new QLabel( "Radius", this ); QFont f = label->font(); f.setBold(false); label->setFont( f ); horizontalLayout1->addWidget(label); m_RadiusSlider = new QSlider(Qt::Horizontal); m_RadiusSlider->setSliderPosition(20); horizontalLayout1->addWidget(m_RadiusSlider); QObject::connect(m_RadiusSlider, SIGNAL(sliderMoved(int)), this, SLOT(RadiusChanged(int))); QPushButton* pbtn_CreateSurface = new QPushButton(); pbtn_CreateSurface->setText("Create Surface"); horizontalLayout2->addWidget(pbtn_CreateSurface); connect(pbtn_CreateSurface, SIGNAL(clicked()), this, SLOT(CombineSurfaces())); QPushButton* pbtn_Bulging = new QPushButton(); pbtn_Bulging->setText("Bulging"); horizontalLayout2->addWidget(pbtn_Bulging); connect(pbtn_Bulging, SIGNAL(clicked()), this, SLOT(Bulging())); QPushButton* pbtn_PatchHoles = new QPushButton(); pbtn_PatchHoles->setText("Patch Holes"); horizontalLayout3->addWidget(pbtn_PatchHoles); connect(pbtn_PatchHoles, SIGNAL(clicked()), this, SLOT(PatchHoles())); QPushButton* pbtn_SmoothROI = new QPushButton(); pbtn_SmoothROI->setText("Smooth ROI"); horizontalLayout3->addWidget(pbtn_SmoothROI); connect(pbtn_SmoothROI, SIGNAL(clicked()), this, SLOT(SmoothROI())); QLabel* label2 = new QLabel( "Smooth Iterations", this ); QFont f2 = label2->font(); f2.setBold(false); label2->setFont( f2 ); horizontalLayout4->addWidget(label2); QSlider* smoothSlider = new QSlider(Qt::Horizontal); smoothSlider->setSliderPosition(5); horizontalLayout4->addWidget(smoothSlider); QObject::connect(smoothSlider, SIGNAL(sliderMoved(int)), this, SLOT(SmoothChanged(int))); QPushButton* pbtn_Subdivide = new QPushButton(); pbtn_Subdivide->setText("Subdivide Surface"); horizontalLayout5->addWidget(pbtn_Subdivide); connect(pbtn_Subdivide, SIGNAL(clicked()), this, SLOT(Subdivide())); QPushButton* pbtn_SubdivideVOI = new QPushButton(); pbtn_SubdivideVOI->setText("Subdivide VOI"); horizontalLayout5->addWidget(pbtn_SubdivideVOI); connect(pbtn_SubdivideVOI, SIGNAL(clicked()), this, SLOT(SubdivideVOI())); QPushButton* pbtn_ColorSurface = new QPushButton(); pbtn_ColorSurface->setText("Color Surface"); horizontalLayout6->addWidget(pbtn_ColorSurface); connect(pbtn_ColorSurface, SIGNAL(clicked()), this, SLOT(ColorSurface())); connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) ); //std::cout << "ciao from " << __FUNCSIG__ << std::endl; }
void GeometryGenerator::CreateGeosphere(float radius, UINT numSubdivisions, MeshData& meshData) { numSubdivisions = MathHelper::Min(numSubdivisions, 5u); const float X = 0.525731f; const float Z = 0.850651f; glm::vec3 pos[12] = { glm::vec3(-X, 0.0f, Z), glm::vec3(X, 0.0f, Z), glm::vec3(-X, 0.0f, -Z), glm::vec3(X, 0.0f, -Z), glm::vec3(0.0f, Z, X), glm::vec3(0.0f, Z, -X), glm::vec3(0.0f, -Z, X), glm::vec3(0.0f, -Z, -X), glm::vec3(Z, X, 0.0f), glm::vec3(-Z, X, 0.0f), glm::vec3(Z, -X, 0.0f), glm::vec3(-Z, -X, 0.0f) }; DWORD k[60] = { 1,4,0, 4,9,0, 4,5,9, 8,5,4, 1,8,4, 1,10,8, 10,3,8, 8,3,5, 3,2,5, 3,7,2, 3,10,7, 10,6,7, 6,11,7, 6,0,11, 6,1,0, 10,1,6, 11,0,9, 2,11,9, 5,2,9, 11,2,7 }; meshData.Vertices.resize(12); meshData.Indices.resize(60); for(UINT i = 0; i < 12; ++i) meshData.Vertices[i].Position = pos[i]; for(UINT i = 0; i < 60; ++i) meshData.Indices[i] = k[i]; for(UINT i = 0; i < numSubdivisions; ++i) Subdivide(meshData); for(UINT i = 0; i < meshData.Vertices.size(); ++i) { glm::vec3 n = glm::normalize(meshData.Vertices[i].Position); glm::vec3 p = radius*n; meshData.Vertices[i].Position = p; meshData.Vertices[i].Normal = n; float theta = MathHelper::AngleFromXY( meshData.Vertices[i].Position.x, meshData.Vertices[i].Position.z); float phi = acosf(meshData.Vertices[i].Position.y / radius); meshData.Vertices[i].TexC.x = theta/(XM_PI * 2.0f); meshData.Vertices[i].TexC.y = phi/XM_PI; meshData.Vertices[i].TangentU.x = -radius*sinf(phi)*sinf(theta); meshData.Vertices[i].TangentU.y = 0.0f; meshData.Vertices[i].TangentU.z = +radius*sinf(phi)*cosf(theta); glm::vec3 T = meshData.Vertices[i].TangentU; meshData.Vertices[i].TangentU = glm::normalize(T); } }
WingedEdge WingedEdge::SillyPascalSubdivide(std::map<Vertex, std::vector<Vertex> > &derivations) { return Subdivide(false, true, derivations); }
void GeometryGenerator::CreateGeosphere(float radius, UINT numSubdivisions, MeshData& meshData) { // Put a cap on the number of subdivisions. numSubdivisions = MathHelper::Min(numSubdivisions, 5u); // Approximate a sphere by tessellating an icosahedron. const float X = 0.525731f; const float Z = 0.850651f; XMFLOAT3 pos[12] = { XMFLOAT3(-X, 0.0f, Z), XMFLOAT3(X, 0.0f, Z), XMFLOAT3(-X, 0.0f, -Z), XMFLOAT3(X, 0.0f, -Z), XMFLOAT3(0.0f, Z, X), XMFLOAT3(0.0f, Z, -X), XMFLOAT3(0.0f, -Z, X), XMFLOAT3(0.0f, -Z, -X), XMFLOAT3(Z, X, 0.0f), XMFLOAT3(-Z, X, 0.0f), XMFLOAT3(Z, -X, 0.0f), XMFLOAT3(-Z, -X, 0.0f) }; DWORD k[60] = { 1,4,0, 4,9,0, 4,5,9, 8,5,4, 1,8,4, 1,10,8, 10,3,8, 8,3,5, 3,2,5, 3,7,2, 3,10,7, 10,6,7, 6,11,7, 6,0,11, 6,1,0, 10,1,6, 11,0,9, 2,11,9, 5,2,9, 11,2,7 }; meshData.Vertices.resize(12); meshData.Indices.resize(60); for(UINT i = 0; i < 12; ++i) meshData.Vertices[i].Position = pos[i]; for(UINT i = 0; i < 60; ++i) meshData.Indices[i] = k[i]; for(UINT i = 0; i < numSubdivisions; ++i) Subdivide(meshData); // Project vertices onto sphere and scale. for(UINT i = 0; i < meshData.Vertices.size(); ++i) { // Project onto unit sphere. XMVECTOR n = XMVector3Normalize(XMLoadFloat3(&meshData.Vertices[i].Position)); // Project onto sphere. XMVECTOR p = radius*n; XMStoreFloat3(&meshData.Vertices[i].Position, p); XMStoreFloat3(&meshData.Vertices[i].Normal, n); // Derive texture coordinates from spherical coordinates. float theta = MathHelper::AngleFromXY( meshData.Vertices[i].Position.x, meshData.Vertices[i].Position.z); float phi = acosf(meshData.Vertices[i].Position.y / radius); meshData.Vertices[i].TexC.x = theta/XM_2PI; meshData.Vertices[i].TexC.y = phi/XM_PI; // Partial derivative of P with respect to theta meshData.Vertices[i].TangentU.x = -radius*sinf(phi)*sinf(theta); meshData.Vertices[i].TangentU.y = 0.0f; meshData.Vertices[i].TangentU.z = +radius*sinf(phi)*cosf(theta); XMVECTOR T = XMLoadFloat3(&meshData.Vertices[i].TangentU); XMStoreFloat3(&meshData.Vertices[i].TangentU, XMVector3Normalize(T)); } }
void ConstrainedFire::Init(ObjReader * obj) { FireVertex vertex; FireTriangle triangle; int end; //存储模型顶点 end = (int)obj->Positions.size(); for(int i=0;i<end;i++) { vertex.position = obj->Positions[i]*2.6; m_Vertices.push_back(vertex); } //存储模型面信息 end = (int) obj->m_Object[0]->posIndices.size(); for(int i=0;i<end;) { triangle.index[0] = obj->m_Object[0]->posIndices[i++]; triangle.index[1] = obj->m_Object[0]->posIndices[i++]; triangle.index[2] = obj->m_Object[0]->posIndices[i++]; triangle.area = TriangleArea(triangle.index[0],triangle.index[1],triangle.index[2]); m_Faces.push_back(triangle); } Normalize();//归一化顶点数据 Subdivide();//细分模型 objectImported =true; objVertexNum = (int)m_Vertices.size(); numParticlesSecondExp=m_Vertices.size()*1.8; KMeans(m_K);//聚类操作 GenerateQuadrantByKMean();//生成发射区域 //8个二次爆炸的粒子发生器的位置限制,注意顺序要与对象顶点分区编号对应 /*Point3f expP; expP=modelCenter(m_Quadrant0); expEmitter[0].pos.X()=expP.X(); expEmitter[0].pos.Y()=expP.Y(); expEmitter[0].pos.Z()=expP.Z(); expP=modelCenter(m_Quadrant1); expEmitter[1].pos.X()=expP.X(); expEmitter[1].pos.Y()=expP.Y(); expEmitter[1].pos.Z()=expP.Z(); expP=modelCenter(m_Quadrant2); expEmitter[2].pos.X()=expP.X(); expEmitter[2].pos.Y()=expP.Y(); expEmitter[2].pos.Z()=expP.Z(); expP=modelCenter(m_Quadrant3); expEmitter[3].pos.X()=expP.X(); expEmitter[3].pos.Y()=expP.Y(); expEmitter[3].pos.Z()=expP.Z(); expP=modelCenter(m_Quadrant4); expEmitter[4].pos.X()=expP.X(); expEmitter[4].pos.Y()=expP.Y(); expEmitter[4].pos.Z()=expP.Z(); expP=modelCenter(m_Quadrant5); expEmitter[5].pos.X()=expP.X(); expEmitter[5].pos.Y()=expP.Y(); expEmitter[5].pos.Z()=expP.Z(); expP=modelCenter(m_Quadrant6); expEmitter[6].pos.X()=expP.X(); expEmitter[6].pos.Y()=expP.Y(); expEmitter[6].pos.Z()=expP.Z(); expP=modelCenter(m_Quadrant7); expEmitter[7].pos.X()=expP.X(); expEmitter[7].pos.Y()=expP.Y(); expEmitter[7].pos.Z()=expP.Z();*/ }