SE_RenderUnit* SE_MeshSimObject::createWireRenderUnit() { //generate world geometry data SE_GeometryData data; SE_Matrix4f m2w = this->getSpatial()->getWorldTransform(); SE_GeometryData::transform(mMesh->getGeometryData(),m2w,&data); int faceNum = data.getFaceNum(); int vertexNum = data.getVertexNum(); SE_Vector3f* vertex = data.getVertexArray(); SE_Vector3i* faces = data.getFaceArray(); SE_Segment* seg = new SE_Segment[faceNum * 3]; int n = 0 ; for(int i = 0 ; i < faceNum ; i++) { SE_Vector3i* f = &faces[i]; seg[n++].set(vertex[f->x], vertex[f->y]); seg[n++].set(vertex[f->y], vertex[f->z]); seg[n++].set(vertex[f->z], vertex[f->x]); } SE_RenderUnit* ru = new SE_LineSegRenderUnit(seg, faceNum * 3, SE_Vector3f(0, 1, 0)); delete[] seg; return ru; }
void SE_Geometry::forceUpdateBoundingVolume() { if(mWorldBoundingVolume) { delete mWorldBoundingVolume; mWorldBoundingVolume = NULL; } switch(getBVType()) { case AABB: mWorldBoundingVolume = new SE_AABBBV; break; case OBB: mWorldBoundingVolume = new SE_OBBBV; break; case SPHERE: mWorldBoundingVolume = new SE_SphereBV; break; } if(mWorldBoundingVolume) { SE_Geometry::_Impl::SimObjectList::iterator it; for(it = mImpl->attachObject.begin() ; it != mImpl->attachObject.end() ; it++) { //generate world geometry data SE_GeometryData data; SE_Matrix4f m2w = this->getWorldTransform(); SE_GeometryData::transform((*it)->getMesh()->getGeometryData(),m2w,&data); //(*it)->doTransform(getWorldTransform()); SE_Vector3f* points = data.getVertexArray(); if(!points) { continue; } int num = data.getVertexNum(); mWorldBoundingVolume->createFromPoints(points, num); (*it)->setCenter(mWorldBoundingVolume->getCenter()); } } //if this is a shadow creator,tell render to update shadow map if(this->isSpatialEffectHasAttribute(SE_SpatialAttribute::SHADOWGENERATOR)) { //SE_Application::getInstance()->getSpatialManager()->shadowCreatorTransformed(); SE_Application::getInstance()->getRenderManager()->shadowCreatorTransformed(); } if(this->isSpatialEffectHasAttribute(SE_SpatialAttribute::MIRRORGENERATOR)) { //SE_Application::getInstance()->getSpatialManager()->mirrorCreatorTransformed(); SE_Application::getInstance()->getRenderManager()->mirrorCreatorTransformed(); } }
bool SE_NewGeometry::showFrame(int index){ SE_NewGeometry::_Impl::SimObjectList::iterator it; for(it = mImpl->attachObject.begin() ; it != mImpl->attachObject.end() ; it++) { SE_SimObject* simObject = *it; SE_Mesh* mesh = simObject->getMesh(); mMaxFrame = mesh->mKeyFrames.size(); std::list<SE_KeyFrame<SE_NewTransform>*>::iterator it; for(it = mesh->mKeyFrames.begin() ; it != mesh->mKeyFrames.end() ; it++) { SE_KeyFrame<SE_NewTransform>* kf = *it; if(kf->key == index) { if (kf->data.vertexNum > 0) { SE_GeometryData* geometryData = mesh->getGeometryData(); SE_Vector3f* oldVertex = geometryData->getVertexArray(); int oldVertexNum = geometryData->getVertexNum(); for (int i=0; i< oldVertexNum; i++) { oldVertex[i].x = kf->data.vertexArray[i].x; oldVertex[i].y = kf->data.vertexArray[i].y; oldVertex[i].z = kf->data.vertexArray[i].z; } SE_Surface* surface = mesh->getSurface(0); surface->upDateFaceVertex(); } mWorldTransform = getPrevMatrix().mul(kf->data.matrix).mul(getPostMatrix()); break; } } } std::list<SE_Spatial*>::iterator itchild = mImplchild->children.begin(); for(; itchild != mImplchild->children.end() ; itchild++) { SE_NewGeometry* s = (SE_NewGeometry*)*itchild; s->showFrame(index); } return index < mMaxFrame -1; }
void SE_TriSurfaceRenderUnit::getVertex(_Vector3f*& vertex, int & vertexNum) { if(mVertex != NULL) { vertex = mVertex; vertexNum = mVertexNum; SE_ASSERT(0); return; } SE_GeometryData* geomData = mSurface->getGeometryData(); int facetNum = mSurface->getFacetNum(); int* facets = mSurface->getFacetArray(); SE_Vector3i* faceArray = geomData->getFaceArray(); SE_Vector3f* vertexArray = geomData->getVertexArray(); mVertex = new _Vector3f[facetNum * 3]; mVertexNum = facetNum * 3; int k = 0; for(int i = 0 ; i < facetNum ; i++) { SE_Vector3i f = faceArray[facets[i]]; mVertex[k].d[0] = vertexArray[f.x].x; mVertex[k].d[1] = vertexArray[f.x].y; mVertex[k].d[2] = vertexArray[f.x].z; k++; mVertex[k].d[0] = vertexArray[f.y].x; mVertex[k].d[1] = vertexArray[f.y].y; mVertex[k].d[2] = vertexArray[f.y].z; k++; mVertex[k].d[0] = vertexArray[f.z].x; mVertex[k].d[1] = vertexArray[f.z].y; mVertex[k].d[2] = vertexArray[f.z].z; k++; } vertex = mVertex; vertexNum = mVertexNum; }