void T3DSceneComponent::_ComputeObjectBox() { _objectBox->set(Box3F(10E30f, 10E30f, 10E30f, -10E30f, -10E30f, -10E30f)); bool gotone = false; for (T3DSceneClient * walk = _sceneClientList; walk != NULL; walk = walk->getNextSceneClient()) { ISolid3D * solid = dynamic_cast<ISolid3D*>(walk); if (solid == NULL) continue; Box3F box = solid->getObjectBox(); if (solid->getTransform3D() != NULL) { MatrixF mat; solid->getTransform3D()->getObjectMatrix(mat, true); mat.mul(box); } box.extend(_objectBox->get().min); box.extend(_objectBox->get().max); _objectBox->set(box); gotone = true; } if (!gotone) _objectBox->set(Box3F()); setDirtyObjectBox(false); setDirtyWorldBox(true); }
SceneObject::SceneObject() { mContainer = 0; mTypeMask = DefaultObjectType; mCollisionMask = 0xFF; mCollisionCount = 0; mGlobalBounds = false; mObjScale.set(1,1,1); mObjToWorld.identity(); mWorldToObj.identity(); mObjBox = Box3F(Point3F(0, 0, 0), Point3F(0, 0, 0)); mWorldBox = Box3F(Point3F(0, 0, 0), Point3F(0, 0, 0)); mWorldSphere = SphereF(Point3F(0, 0, 0), 0); mRenderObjToWorld.identity(); mRenderWorldToObj.identity(); mRenderWorldBox = Box3F(Point3F(0, 0, 0), Point3F(0, 0, 0)); mRenderWorldSphere = SphereF(Point3F(0, 0, 0), 0); mContainerSeqKey = 0; mBinRefHead = NULL; mSceneManager = NULL; mNumCurrZones = 0; mZoneRefHead = NULL; mZoneRefDirty = false; mBinMinX = 0xFFFFFFFF; mBinMaxX = 0xFFFFFFFF; mBinMinY = 0xFFFFFFFF; mBinMaxY = 0xFFFFFFFF; mLightPlugin = NULL; mMount.object = NULL; mMount.link = NULL; mMount.list = NULL; mMount.node = -1; mMount.xfm = MatrixF::Identity; mMountPID = NULL; mSceneObjectLinks = NULL; for(U32 i = 0; i < Palette::NumSlots; i++) mPalette.colors[i] = Palette::defaultColor; mFlickerTime = 0; mObjectFlags.set( RenderEnabledFlag | SelectionEnabledFlag ); mIsScopeAlways = false; }
SceneObject::SceneObject() { mContainer = 0; mTypeMask = DefaultObjectType; mCollisionCount = 0; mGlobalBounds = false; mObjScale.set(1,1,1); mObjToWorld.identity(); mWorldToObj.identity(); mObjBox = Box3F(Point3F(0, 0, 0), Point3F(0, 0, 0)); mWorldBox = Box3F(Point3F(0, 0, 0), Point3F(0, 0, 0)); mWorldSphere = SphereF(Point3F(0, 0, 0), 0); mRenderObjToWorld.identity(); mRenderWorldToObj.identity(); mRenderWorldBox = Box3F(Point3F(0, 0, 0), Point3F(0, 0, 0)); mRenderWorldSphere = SphereF(Point3F(0, 0, 0), 0); mContainerSeqKey = 0; mBinRefHead = NULL; mSceneManager = NULL; mNumCurrZones = 0; mZoneRefHead = NULL; mZoneRefDirty = false; mBinMinX = 0xFFFFFFFF; mBinMaxX = 0xFFFFFFFF; mBinMinY = 0xFFFFFFFF; mBinMaxY = 0xFFFFFFFF; mLightPlugin = NULL; mMount.object = NULL; mMount.link = NULL; mMount.list = NULL; mMount.node = -1; mMount.xfm = MatrixF::Identity; mMountPID = NULL; mSceneObjectLinks = NULL; mObjectFlags.set( RenderEnabledFlag | SelectionEnabledFlag ); mIsScopeAlways = false; //.logicking guidebot >> m_worldObject = NULL; //.logicking guidebot << }
//--------------------------------------------------------------------------- void Sky::makeBoundingBox() { // This bounding box is less than the root container's bounding box, but // greater than any "real" bounding box, ie the terrain. // Point3F pMin(-1e10f, -1e10f, -1e10f); Point3F pMax( 1e10f, 1e10f, 1e10f); setBoundingBox(Box3F(pMin, pMax)); }
bool afxMooring::onAdd() { if(!Parent::onAdd()) return false; mObjBox = Box3F(Point3F(-0.5, -0.5, -0.5), Point3F(0.5, 0.5, 0.5)); addToScene(); return true; }
Box3F Box3F::aroundPoints( const Point3F* points, U32 numPoints ) { AssertFatal( points != NULL, "Box3F::aroundPoints - Receive a NULL pointer" ); AssertFatal( numPoints >= 1, "Box3F::aroundPoints - Must have at least one point" ); Box3F box; Point3F minPoint = points[ 0 ]; Point3F maxPoint = points[ 0 ]; for( U32 i = 1; i < numPoints; ++ i ) for( U32 n = 0; n < 3; ++ n ) { minPoint[ n ] = getMin( minPoint[ n ], points[ i ][ n ] ); maxPoint[ n ] = getMax( maxPoint[ n ], points[ i ][ n ] ); } return Box3F( minPoint, maxPoint ); }
void SimExplosionCloud::finishAddToManager() { // add to timer Set -- we'll give contained explosions timer updates ourself addToSet(SimTimerSetId); // add ourselves to the render Set so we can find out where camera is addToSet(SimRenderSetId); removeFromRenderSet = false; // add ourself to the root and set our bounding box SimContainer *root = NULL; root = findObject(manager, SimRootContainerId,root); containerMask = 0; // so nothing gets in... root->addObject(this); if (form==Box) setBoundingBox(box); else setBoundingBox(Box3F(center,center)); }
// Install into the TSShape, the shape is expected to be empty. // Data is not copied, the TSShape is modified to point to memory // managed by this object. This object is also bound to the TSShape // object and will be deleted when it's deleted. void TSShapeLoader::install() { // Arrays that are filled in by ts shape init, but need // to be allocated beforehand. shape->subShapeFirstTranslucentObject.setSize(shape->subShapeFirstObject.size()); // Construct TS sub-meshes shape->meshes.setSize(appMeshes.size()); for (U32 m = 0; m < appMeshes.size(); m++) shape->meshes[m] = appMeshes[m] ? appMeshes[m]->constructTSMesh() : NULL; // Remove empty meshes and objects for (S32 iObj = shape->objects.size()-1; iObj >= 0; iObj--) { TSShape::Object& obj = shape->objects[iObj]; for (S32 iMesh = obj.numMeshes-1; iMesh >= 0; iMesh--) { TSMesh *mesh = shape->meshes[obj.startMeshIndex + iMesh]; if (mesh && !mesh->primitives.size()) { S32 oldMeshCount = obj.numMeshes; destructInPlace(mesh); shape->removeMeshFromObject(iObj, iMesh); iMesh -= (oldMeshCount - obj.numMeshes - 1); // handle when more than one mesh is removed } } if (!obj.numMeshes) shape->removeObject(shape->getName(obj.nameIndex)); } // Add a dummy object if needed so the shape loads and renders ok if (!shape->details.size()) { shape->addDetail("detail", 2, 0); shape->subShapeNumObjects.last() = 1; shape->meshes.push_back(NULL); shape->objects.increment(); shape->objects.last().nameIndex = shape->addName("dummy"); shape->objects.last().nodeIndex = 0; shape->objects.last().startMeshIndex = 0; shape->objects.last().numMeshes = 1; shape->objectStates.increment(); shape->objectStates.last().frameIndex = 0; shape->objectStates.last().matFrameIndex = 0; shape->objectStates.last().vis = 1.0f; } // Update smallest visible detail shape->mSmallestVisibleDL = -1; shape->mSmallestVisibleSize = 999999; for (S32 i = 0; i < shape->details.size(); i++) { if ((shape->details[i].size >= 0) && (shape->details[i].size < shape->mSmallestVisibleSize)) { shape->mSmallestVisibleDL = i; shape->mSmallestVisibleSize = shape->details[i].size; } } computeBounds(shape->bounds); if (!shape->bounds.isValidBox()) shape->bounds = Box3F(1.0f); shape->bounds.getCenter(&shape->center); shape->radius = (shape->bounds.maxExtents - shape->center).len(); shape->tubeRadius = shape->radius; shape->init(); }
bool Projectile::onAdd() { if(!Parent::onAdd()) return false; if( !mDataBlock ) { Con::errorf("Projectile::onAdd - Fail - Not datablock"); return false; } if (isServerObject()) { ShapeBase* ptr; if (Sim::findObject(mSourceObjectId, ptr)) { mSourceObject = ptr; // Since we later do processAfter( mSourceObject ) we must clearProcessAfter // if it is deleted. SceneObject already handles this in onDeleteNotify so // all we need to do is register for the notification. deleteNotify( ptr ); } else { if (mSourceObjectId != -1) Con::errorf(ConsoleLogEntry::General, "Projectile::onAdd: mSourceObjectId is invalid"); mSourceObject = NULL; } // If we're on the server, we need to inherit some of our parent's velocity // mCurrTick = 0; } else { if (bool(mDataBlock->projectileShape)) { mProjectileShape = new TSShapeInstance(mDataBlock->projectileShape, isClientObject()); if (mDataBlock->activateSeq != -1) { mActivateThread = mProjectileShape->addThread(); mProjectileShape->setTimeScale(mActivateThread, 1); mProjectileShape->setSequence(mActivateThread, mDataBlock->activateSeq, 0); } } if (mDataBlock->particleEmitter != NULL) { ParticleEmitter* pEmitter = new ParticleEmitter; pEmitter->onNewDataBlock(mDataBlock->particleEmitter,false); if (pEmitter->registerObject() == false) { Con::warnf(ConsoleLogEntry::General, "Could not register particle emitter for particle of class: %s", mDataBlock->getName()); delete pEmitter; pEmitter = NULL; } mParticleEmitter = pEmitter; } if (mDataBlock->particleWaterEmitter != NULL) { ParticleEmitter* pEmitter = new ParticleEmitter; pEmitter->onNewDataBlock(mDataBlock->particleWaterEmitter,false); if (pEmitter->registerObject() == false) { Con::warnf(ConsoleLogEntry::General, "Could not register particle emitter for particle of class: %s", mDataBlock->getName()); delete pEmitter; pEmitter = NULL; } mParticleWaterEmitter = pEmitter; } } if (mSourceObject.isValid()) processAfter(mSourceObject); // Setup our bounding box if (bool(mDataBlock->projectileShape) == true) mObjBox = mDataBlock->projectileShape->bounds; else mObjBox = Box3F(Point3F(0, 0, 0), Point3F(0, 0, 0)); MatrixF initialTransform( true ); initialTransform.setPosition( mCurrPosition ); setTransform( initialTransform ); // calls resetWorldBox addToScene(); if ( PHYSICSMGR ) mPhysicsWorld = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" ); return true; }
bool Projectile::onAdd() { if(!Parent::onAdd()) return false; if (isServerObject()) { ShapeBase* ptr; if (Sim::findObject(mSourceObjectId, ptr)) mSourceObject = ptr; else { if (mSourceObjectId != -1) Con::errorf(ConsoleLogEntry::General, "Projectile::onAdd: mSourceObjectId is invalid"); mSourceObject = NULL; } // If we're on the server, we need to inherit some of our parent's velocity // mCurrTick = 0; } else { if (bool(mDataBlock->projectileShape)) { mProjectileShape = new TSShapeInstance(mDataBlock->projectileShape, isClientObject()); if (mDataBlock->activateSeq != -1) { mActivateThread = mProjectileShape->addThread(); mProjectileShape->setTimeScale(mActivateThread, 1); mProjectileShape->setSequence(mActivateThread, mDataBlock->activateSeq, 0); } } if (mDataBlock->particleEmitter != NULL) { ParticleEmitter* pEmitter = new ParticleEmitter; pEmitter->onNewDataBlock(mDataBlock->particleEmitter); if (pEmitter->registerObject() == false) { Con::warnf(ConsoleLogEntry::General, "Could not register particle emitter for particle of class: %s", mDataBlock->getName()); delete pEmitter; pEmitter = NULL; } mParticleEmitter = pEmitter; } if (mDataBlock->particleWaterEmitter != NULL) { ParticleEmitter* pEmitter = new ParticleEmitter; pEmitter->onNewDataBlock(mDataBlock->particleWaterEmitter); if (pEmitter->registerObject() == false) { Con::warnf(ConsoleLogEntry::General, "Could not register particle emitter for particle of class: %s", mDataBlock->getName()); delete pEmitter; pEmitter = NULL; } mParticleWaterEmitter = pEmitter; } } if (mSourceObject.isValid()) processAfter(mSourceObject); // Setup our bounding box if (bool(mDataBlock->projectileShape) == true) mObjBox = mDataBlock->projectileShape->bounds; else mObjBox = Box3F(Point3F(0, 0, 0), Point3F(0, 0, 0)); resetWorldBox(); addToScene(); if ( gPhysicsPlugin ) mPhysicsWorld = gPhysicsPlugin->getWorld( isServerObject() ? "Server" : "Client" ); return true; }
Box3F Convex::getBoundingBox() const { return Box3F();//mObject->getWorldBox(); }