void Object::init(pObject const& parent) { setupSceneAndManager(parent); body_ = smgr_->addEmptySceneNode( parent->body() ); body_->grab(); //added so its d'tor order is consistent with view::Object. body_->setIsDebugObject(true); }
void Object::setupSceneAndManager(pObject const& parent) { if( pScene p = dynamic_pointer_cast<Scene>( parent ) ) scene_ = p; else scene_ = parent->scene(); smgr_ = scene()->smgr_; }
pAnimatedSceneObject AnimatedSceneObject::init(pObject const& parent) { setupSceneAndManager(parent); std::ostringstream oss; oss << Conf::i().expand("rc/model/") << name_ << ".x"; IAnimatedMesh* mesh = smgr_->getMesh( oss.str().c_str() ); IAnimatedMeshSceneNode* temp = smgr_->addAnimatedMeshSceneNode( mesh, parent->body() ); temp->setAnimationSpeed(0); body_ = temp; body_->grab(); //added so its d'tor order is consistent with view::Object. body_->getMaterial(0).Shininess = 0; for( size_t i = 0; i < body_->getMaterialCount(); ++i ) { body_->getMaterial(i).MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; body_->getMaterial(i).MaterialTypeParam = 0.01f; body_->getMaterial(i).DiffuseColor.set(255, 255, 255, 255); } //test body_->grab(); pAnimatedSceneObject self = static_pointer_cast<AnimatedSceneObject>( shared_from_this() ); scene()->addPickMapping( body_, self ); return self; }
list<const Light*> Light::filterLights(pObject object) { list<const Light*> result; list<const Object*> temp; object->filter(temp, filter_light); BOOST_FOREACH(const Object* obj, temp) result.push_back(dynamic_cast<const Light*>(obj)); return result; }
void Sprite::setupMeshAndNode(IMesh*& out_mesh, ISceneNode*& out_node, pObject const& parent, dimension2df const& size, bool const& center, std::string const& debug_name) { IMeshManipulator* mani = smgr_->getMeshManipulator(); out_mesh = mani->createMeshCopy( sprite_plane_ptr_ ); mani->scaleMesh( out_mesh, vector3df(size.Width, size.Height, 1) ); if( center ) { matrix4 mat; mat.setTranslation( vector3df(-size.Width/2, size.Height/2, 0) ); mani->transformMesh( out_mesh, mat ); } out_node = smgr_->addMeshSceneNode( out_mesh, parent->body(), -1, vector3df(0,0,0) ); out_node->setAutomaticCulling(EAC_OFF); out_node->setName( debug_name.c_str() ); //body_->setDebugDataVisible(EDS_BBOX); //de-comment this when debugging. }
Object::Object(pObject& p): p(p) { Application::initialize(); p.constructor(); }