void DrawSimulationGrid(const bbox_t& gbbox, const vec3i_t& dim, int slice) { vec3i_t gridDim = dim; vec3i_t gridIdx; vec3_t cellSize((gbbox.max.x-gbbox.min.x)/dim.x,(gbbox.max.y-gbbox.min.y)/dim.y,(gbbox.max.z-gbbox.min.z)/dim.z); bbox_t bbox; vec3_t mn, mx; if(slice != -1) { gridIdx.z = slice; gridDim.z = slice+1; } for(; gridIdx.z < gridDim.z; gridIdx.z++) for(gridIdx.x = 0; gridIdx.x < gridDim.x; gridIdx.x++) for(gridIdx.y = 0; gridIdx.y < gridDim.y; gridIdx.y++) { mn.reset(gbbox.min.x + cellSize.x*gridIdx.x,gbbox.min.y + cellSize.y*gridIdx.y,gbbox.min.z + cellSize.z*gridIdx.z); mx.reset(mn.x + cellSize.x,mn.y + cellSize.y, mn.z + cellSize.z); bbox.reset(mn,mx); DrawBBox(bbox); } }
void CRasterTerrainModel::RenderBounds() const { glDisable(GL_LIGHTING); glColor3f(1.f, 1.f, 0.f); std::vector<Patch*>::const_iterator itr, itre = mActivePatches.end(); for (itr = mActivePatches.begin(); itr != itre; ++itr) { DrawBBox(*itr); } glEnable(GL_LIGHTING); }
/// Move forward the simulation of this sim object by a time delta /// @param dt the amount of time to simulate forward void SceneObject::ProcessTick( float32_t dt ) { Assert( mSharedData ); // set the position and rotation of our object if( mSceneNode ) { // Note: jsheblak 28July2007 // Setting the position of some large meshes in irrlicht every frame // causes them to flicker or disappear. Compare the position first and // update if necessary. if( mSharedData->IsDirty(SimEntityData::kDB_Position) ) { // convert from open nero's coordinate system to irrlicht's SetPosition( mSharedData->GetPosition() ); // the position is set here, but it might change after drawAll because of collisions etc // thus, the next time we see this sceneNode, we should make sure to get the position back // to the state. } if( mSharedData->IsDirty(SimEntityData::kDB_Rotation) ) { // Irrlicht expects a left handed basis with the x-z plane being horizontal and y being up // OpenNero uses a right handed basis with x-y plane being horizontal and z being up SetRotation( mSharedData->GetRotation() ); } if ( mSharedData->IsDirty(SimEntityData::kDB_Scale) ) { // set the node scale Vector3f scale = mSceneObjectTemplate->mScale; /// we can optionally multiply by a custom scale scale.X = scale.X * mSharedData->GetScale().X; scale.Y = scale.Y * mSharedData->GetScale().Y; scale.Z = scale.Z * mSharedData->GetScale().Z; // convert from open nero's coordinate system to irrlicht's mSceneNode->setScale( ConvertNeroToIrrlichtPosition(scale) ); } if ( mSharedData->IsDirty(SimEntityData::kDB_Label) && mSceneObjectTemplate->mDrawLabel ) { SetText(mSharedData->GetLabel()); } if ( mSharedData->IsDirty(SimEntityData::kDB_Color) ) { if (mAniSceneNode) { // The above workaround is not necessary anymore in Irrlicht 1.5 mAniSceneNode->getMaterial(0).DiffuseColor = mSharedData->GetColor(); } } // add our bounding box to the lineset if( mSceneNode && mSceneObjectTemplate->mDrawBoundingBox ) { BBoxf bbox = getTransformedBoundingBox(); DrawBBox(bbox, LineSet::LineColor(255,0,255,0)); } if (mFPSCamera && !mCamera) { Kernel::GetSimContext()->getActiveCamera()->attach(this->GetEntity(), mFPSCamera); } mSharedData->ClearDirtyBits(); } }
void DrawAABB(const AABB_t& aabb) { DrawBBox(bbox_t::from_aabb(aabb)); }