void CreateTreeTool::doPress(int x, int y, int flags, float pressure) { Vector3 from; if (!m_view->traceWorld(x, y, from, SelectPart::All)) { return; } m_actor = new SpeedTree(); m_view->getContext()->setSelection(m_actor); m_actor->setProperty("tree", m_mapContext->getMapState()->treeFilename); if (m_mapContext->getMapState()->isSnapToGrid) { from = Internal::snap(from, m_mapContext->getMapState()->snapToGrid); } m_actor->bindToGame(); GroupHis* grouphis = new GroupHis(m_context, "Create SpeedTree"); ActorList actorlist; actorlist.push_back(m_actor); UndeleteHis* undelhis = new UndeleteHis(m_context, "Create SpeedTree", actorlist); History* selhis = m_view->getContext()->setSelectionHistoried(actorlist); grouphis->append(undelhis); grouphis->append(selhis); m_context->addHistory(grouphis); doDrag(x, y, flags, pressure); }
void CreateEntityTool::doPress(int x, int y, int flags, float pressure) { Vector3 from; if (!m_view->traceWorld(x, y, from, SelectPart::All)) { return; } m_actor = new Entity(m_mapContext->getMapState()->entityClass); if (m_mapContext->getMapState()->isSnapToGrid) { from = Internal::snap(from, m_mapContext->getMapState()->snapToGrid); } m_actor->getGameEntity()->autoGenerateName(); m_actor->setOrigin(from); m_actor->bindToGame(); GroupHis* grouphis = new GroupHis(m_context, "Create Entity"); ActorList actorlist; actorlist.push_back(m_actor); UndeleteHis* undelhis = new UndeleteHis(m_context, "Create Entity", actorlist); History* selhis = m_view->getContext()->setSelectionHistoried(actorlist); grouphis->append(undelhis); grouphis->append(selhis); m_context->addHistory(grouphis); }
// ---------------------------------------------------------------------------- // bool ActorSelectField::setValue( LPCSTR value ) { CString key( value ); ActorList actors; int curPos = 0; while ( true ) { CString resToken = key.Tokenize( _T(" ,"), curPos ); if ( resToken.IsEmpty() ) break; resToken.MakeUpper(); ActorSelectField::EntryMap::iterator it = m_entries.find( resToken ); if ( it == m_entries.end() ) throw FieldException( "Invalid fixture number %s", (LPCSTR)resToken ); actors.push_back( (*it).second.m_actor ); } if ( actors.size() == 0 ) throw FieldException( "Select at least one fixture" ); if ( actors.size() > 1 && !m_allow_multiple ) throw FieldException( "Select a single fixture" ); m_selected_actors = actors; return InputField::setValue( value ); }
// ---------------------------------------------------------------------------- // ActorSelectField::ActorSelectField( LPCSTR field_label, Venue* venue, bool include_groups ) : InputField( field_label, "" ), m_venue( venue ), m_allow_multiple( true ) { FixturePtrArray fixtures = venue->getFixtures(); ActorList actors; for ( FixturePtrArray::iterator it=fixtures.begin(); it != fixtures.end(); ++it ) actors.push_back( SceneActor( (*it) ) ); if ( include_groups ) { FixtureGroupPtrArray fixture_groups = m_venue->getFixtureGroups(); for ( FixtureGroupPtrArray:: iterator it=fixture_groups.begin(); it != fixture_groups.end(); ++it ) actors.push_back( SceneActor( venue, (*it) ) ); } ActorPtrArray actor_ptrs; for ( size_t i=0; i < actors.size(); i++) actor_ptrs.push_back( &actors[i] ); init( actor_ptrs, UIDArray() ); }
/* boost::shared_ptr<PhysicsMesh> createConvexMesh(const char *filename, IStorm3D_Model_Object *object) { boost::shared_ptr<PhysicsMesh> mesh(new PhysicsMesh()); MeshData data; data.mesh = mesh; data.object = object; data.filename = filename; meshList.push_back(data); return mesh; } */ boost::shared_ptr<PhysicsActor> createActor(boost::shared_ptr<PhysicsMesh> &mesh, const VC3 &position, const QUAT &rotation, const VC3 &velocity, const VC3 &angularVelocity, float mass, int collisionGroup, int soundGroup) { boost::shared_ptr<PhysicsActor> actor(new PhysicsActor(position, rotation)); physicsActorList.push_back(actor.get()); ActorData data; data.actor = actor; data.mesh = mesh; data.velocity = velocity; data.angularVelocity = angularVelocity; data.mass = mass; data.collisionGroup = collisionGroup; data.soundGroup = soundGroup; actorList.push_back(data); return actor; }