コード例 #1
0
ファイル: SE_MeshSimObject.cpp プロジェクト: wljcom/3DHomeHD
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;
}
コード例 #2
0
ファイル: SE_Geometry.cpp プロジェクト: AiAndroid/3DHomeHD
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();
    }

}
コード例 #3
0
ファイル: SE_NewGeometry.cpp プロジェクト: 3DHome/3DHomeHD
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;
}