void MeshManager::create() { if(mCreated) { return; } // Create mesh and submesh mMesh = Ogre::MeshManager::getSingleton().createManual("SkyXMesh", SKYX_RESOURCE_GROUP); mSubMesh = mMesh->createSubMesh(); mSubMesh->useSharedVertices = false; // Create mesh geometry _createGeometry(); // End mesh creation mMesh->load(); mMesh->touch(); mEntity = mSkyX->getSceneManager()->createEntity("SkyXMeshEnt", "SkyXMesh"); mEntity->setMaterialName(mMaterialName); mEntity->setCastShadows(false); mEntity->setRenderQueueGroup(Ogre::RENDER_QUEUE_SKIES_EARLY); mSceneNode = mSkyX->getSceneManager()->getRootSceneNode()->createChildSceneNode(); mSceneNode->showBoundingBox(false); mSceneNode->attachObject(mEntity); mSceneNode->setPosition(mSkyX->getCamera()->getDerivedPosition()); mCreated = true; _updateGeometry(); }
void Portal::_update() { if( mIsGeometryDirty ) _updateGeometry(); _updateConnectivity(); }
void ConvexShape::recenter() { if ( mGeometry.points.size() == 0 ) return; Point3F volCenterOS( 0,0,0 ); F32 areaSum = 0.0f; F32 faceCount = mGeometry.faces.size(); for ( S32 i = 0; i < faceCount; i++ ) { volCenterOS += mGeometry.faces[i].centroid * mGeometry.faces[i].area; areaSum += mGeometry.faces[i].area; } volCenterOS /= areaSum; for ( S32 i = 0; i < mSurfaces.size(); i++ ) mSurfaces[i].setPosition( mSurfaces[i].getPosition() - volCenterOS ); Point3F volCenterWS; MatrixF objToWorld( mObjToWorld ); objToWorld.scale( mObjScale ); objToWorld.mulP( volCenterOS, &volCenterWS ); setPosition( volCenterWS ); _updateGeometry(true); }
void ConvexShape::inspectPostApply() { Parent::inspectPostApply(); _updateGeometry( true ); setMaskBits( UpdateMask ); }
void GeometryManager::updateGeometry(Ogre::Camera* c, const Ogre::Real& timeSinceLastCameraFrame) { if (!mCreated) { return; } mSceneNode->setPosition(mVClouds->getCamera()->getDerivedPosition().x, mHeight.x, mVClouds->getCamera()->getDerivedPosition().z); mSceneNode->_update(false, false); _updateGeometry(c, timeSinceLastCameraFrame); }
void GeometryManager::update(const Ogre::Real& timeSinceLastFrame) { if (!mCreated) { return; } mSceneNode->setPosition(mVClouds->getCamera()->getDerivedPosition().x, mHeight.x, mVClouds->getCamera()->getDerivedPosition().z); _updateGeometry(timeSinceLastFrame); mLastCameraPosition = mVClouds->getCamera()->getDerivedPosition(); }
void GeometryManager::updateGeometry(BaseCamera* c, const float& timeSinceLastCameraFrame) { if (!mCreated) { return; } noVec3 trans(mVClouds->getCamera()->GetFrom().x, mHeight.x, mVClouds->getCamera()->GetFrom().z); mSceneNode->SetTrans(trans); mSceneNode->Update(0.f); _updateGeometry(c, timeSinceLastCameraFrame); }
void ConvexShape::unpackUpdate( NetConnection *conn, BitStream *stream ) { Parent::unpackUpdate( conn, stream ); if ( stream->readFlag() ) // TransformMask { mathRead(*stream, &mObjToWorld); mathRead(*stream, &mObjScale); setTransform( mObjToWorld ); setScale( mObjScale ); } if ( stream->readFlag() ) // UpdateMask { stream->read( &mMaterialName ); if ( isProperlyAdded() ) _updateMaterial(); mSurfaces.clear(); const U32 surfCount = stream->readInt( 32 ); for ( S32 i = 0; i < surfCount; i++ ) { mSurfaces.increment(); MatrixF &mat = mSurfaces.last(); QuatF quat; Point3F pos; mathRead( *stream, &quat ); mathRead( *stream, &pos ); quat.setMatrix( &mat ); mat.setPosition( pos ); } if ( isProperlyAdded() ) _updateGeometry( true ); } }
void Portal::_renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance* overrideMat ) { if( overrideMat ) return; // Update geometry if necessary. if( mIsGeometryDirty ) _updateGeometry(); // Render portal polygon. GFXStateBlockDesc desc; desc.setBlend( true ); desc.setZReadWrite( true, false ); desc.setCullMode( GFXCullNone ); PlaneF::Side viewSide = mPortalPlane.whichSide( state->getCameraPosition() ); ColorI color; switch( mClassification ) { case InvalidPortal: color = ColorI( 255, 255, 255, 45 ); break; case ExteriorPortal: color = viewSide == PlaneF::Front ? ColorI( 0, 128, 128, 45 ) : ColorI( 0, 255, 255, 45 ); break; case InteriorPortal: color = viewSide == PlaneF::Front ? ColorI( 128, 128, 0, 45 ) : ColorI( 255, 255, 0, 45 ); break; } GFX->getDrawUtil()->drawPolygon( desc, mPortalPolygonWS.address(), mPortalPolygonWS.size(), color ); desc.setFillModeWireframe(); GFX->getDrawUtil()->drawPolygon( desc, mPortalPolygonWS.address(), mPortalPolygonWS.size(), ColorF::RED ); // Render rest. Parent::_renderObject( ri, state, overrideMat ); }
bool ConvexShape::onAdd() { if ( !Parent::onAdd() ) return false; //mObjBox.set( -0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f ); //resetWorldBox(); // Face Order: // Top, Bottom, Front, Back, Left, Right // X Axis static const Point3F cubeTangents[6] = { Point3F( 1, 0, 0 ), Point3F(-1, 0, 0 ), Point3F( 1, 0, 0 ), Point3F(-1, 0, 0 ), Point3F( 0, 1, 0 ), Point3F( 0, -1, 0 ) }; // Y Axis static const Point3F cubeBinormals[6] = { Point3F( 0, 1, 0 ), Point3F( 0, 1, 0 ), Point3F( 0, 0, -1 ), Point3F( 0, 0, -1 ), Point3F( 0, 0, -1 ), Point3F( 0, 0, -1 ) }; // Z Axis static const Point3F cubeNormals[6] = { Point3F( 0, 0, 1), Point3F( 0, 0, -1), Point3F( 0, 1, 0), Point3F( 0, -1, 0), Point3F(-1, 0, 0), Point3F( 1, 0, 0), }; if ( mSurfaces.empty() ) { for ( S32 i = 0; i < 6; i++ ) { mSurfaces.increment(); MatrixF &surf = mSurfaces.last(); surf.identity(); surf.setColumn( 0, cubeTangents[i] ); surf.setColumn( 1, cubeBinormals[i] ); surf.setColumn( 2, cubeNormals[i] ); surf.setPosition( cubeNormals[i] * 0.5f ); } } if ( isClientObject() ) _updateMaterial(); _updateGeometry( true ); addToScene(); return true; }