FLODCluster::FLODCluster(AActor* Actor1, AActor* Actor2) : Bound(ForceInit) , bValid(true) { FSphere Actor1Bound = AddActor(Actor1); FSphere Actor2Bound = AddActor(Actor2); // calculate new filling factor FillingFactor = CalculateFillingFactor(Actor1Bound, 1.f, Actor2Bound, 1.f); ClusterCost = FMath::Pow(Bound.W, 3) / FillingFactor; }
void FLODCluster::SubtractCluster(const FLODCluster& Other) { for(int32 ActorId=0; ActorId<Actors.Num(); ++ActorId) { if (Other.Actors.Contains(Actors[ActorId])) { Actors.RemoveAt(ActorId); --ActorId; } } TArray<AActor*> NewActors = Actors; Actors.Empty(); // need to recalculate parameter if (NewActors.Num() == 0) { Invalidate(); } else if (NewActors.Num() == 1) { Bound = FSphere(ForceInitToZero); AddActor(NewActors[0]); FillingFactor = 1.f; ClusterCost = FMath::Pow(Bound.W, 3) / FillingFactor; } else if (NewActors.Num() >= 2) { Bound = FSphere(ForceInit); FSphere Actor1Bound = AddActor(NewActors[0]); FSphere Actor2Bound = AddActor(NewActors[1]); // calculate new filling factor FillingFactor = CalculateFillingFactor(Actor1Bound, 1.f, Actor2Bound, 1.f); // if more actors, we add them manually for (int32 ActorId=2; ActorId<NewActors.Num(); ++ActorId) { // if not contained, it shouldn't be check (!Actors.Contains(NewActors[ActorId])); FSphere NewBound = AddActor(NewActors[ActorId]); FillingFactor = CalculateFillingFactor(NewBound, 1.f, Bound, FillingFactor); Bound += NewBound; } ClusterCost = FMath::Pow(Bound.W, 3) / FillingFactor; } }
Tree* Game::SpawnTree(MapCoordinates SpawnCoordinates, int16_t TreeType, bool isAlive) { Tree* NewTree = new Tree(TreeType, SpawnCoordinates, isAlive); //NewTree->Init(SpawnCoordinates); AddActor(NewTree, 1); return NewTree; }
void Game_Party::SetupBattleTestMembers() { Clear(); for (auto& btdata : Data::system.battletest_data) { AddActor(btdata.actor_id); Game_Actor* actor = Game_Actors::GetActor(btdata.actor_id); // Filter garbage btdata inserted by the editor std::array<int, 5> ids = { btdata.weapon_id, btdata.shield_id, btdata.armor_id, btdata.helmet_id, btdata.accessory_id }; std::replace_if(ids.begin(), ids.end(), [] (const int& item_id) { return ReaderUtil::GetElement(Data::items, item_id) == nullptr; }, 0); actor->SetEquipment(RPG::Item::Type_weapon, ids[0]); actor->SetEquipment(RPG::Item::Type_shield, ids[1]); actor->SetEquipment(RPG::Item::Type_armor, ids[2]); actor->SetEquipment(RPG::Item::Type_helmet, ids[3]); actor->SetEquipment(RPG::Item::Type_accessory, ids[4]); actor->ChangeLevel(btdata.level, false); actor->SetHp(actor->GetMaxHp()); actor->SetSp(actor->GetMaxSp()); } data().party_size = data().party.size(); Main_Data::game_player->Refresh(); }
Actor* EngineCore::AddActor(WorldComponent* rootComp) { Actor* actor = AddActor(); actor->Attach(rootComp); return actor; }
Pawn* Game::SpawnPawn(MapCoordinates SpawnCoordinates) { Pawn* NewPawn = new Pawn(); NewPawn->Init(SpawnCoordinates); AddActor(NewPawn, 1); return NewPawn; }
Actor* EngineCore::AddActor_RigidBodyCapsule(float height, float radius, float mass /*= 0*/) { RigidBodyComponent* rigidComp = AddComponent_RigidBodyCapsule(height, radius, mass); Actor* actor = AddActor(rigidComp); rigidComp->SetUserPointer(actor); return actor; }
Actor* EngineCore::AddActor_RigidBody(const std::string& modelFilePath, float mass) { RigidBodyComponent* rigidComp = AddComponent_RigidBody(modelFilePath, mass); Actor* actor = AddActor(rigidComp); rigidComp->SetUserPointer(actor); return actor; }
FLODCluster::FLODCluster(AActor* Actor1) : Bound(ForceInit) , bValid(true) { AddActor(Actor1); // calculate new filling factor FillingFactor = 1.f; ClusterCost = FMath::Pow(Bound.W, 3) / FillingFactor; }
IActor *AddDynamicObject(XMVECTOR const &xvPos, XMCOLOR const &Color, E_ACTOR_TYPE const eActorType, E_RIGID_BODY_FLAG const eBodyFlag) { IActor *pActor = CreateObject(xvPos, Color, eActorType, eBodyFlag); AddActor(pActor); g_ActorsDynamic.push_back(pActor); return pActor; }
void main(){ typedef itk::Image<signed short, 2> imagetype; typedef itk::ImageFileReader<imagetype> imagereadertype; typedef itk::ImageToVTKImageFilter<imagetype> connerctortypr; imagereadertype::Pointer reader = imagereadertype::New(); reader->SetFileName("e:/IM-0001-0001.dcm"); auto iotype = itk::GDCMImageIO::New(); reader->SetImageIO(iotype); try{ reader->Update(); } catch (itk::ExceptionObject e){ std::cerr << "exception in file reader " << std::endl; std::cerr << e.GetDescription() << std::endl; std::cerr << e.GetLocation() << std::endl; } connerctortypr::Pointer connector = connerctortypr::New(); connector->SetInput(reader->GetOutput()); connector->Update(); auto flip = vtkImageFlip::New(); flip->SetInputData(connector->GetOutput()); flip->SetFilteredAxis(1); flip->Update(); auto actor = vtkImageActor::New(); //actor->GetMapper()->SetInputData(flip->GetOutput()); actor->SetInputData(flip->GetOutput()); actor->InterpolateOff(); actor->Update(); auto render = vtkRenderer::New(); render->AddActor(actor); auto window = vtkRenderWindow::New(); window->SetSize(800, 600); window->AddRenderer(render); auto interactor = vtkRenderWindowInteractor::New(); interactor->SetRenderWindow(window); interactor->Initialize(); interactor->Start(); }
void Game_Party::SetupBattleTestMembers() { data.party.clear(); std::vector<RPG::TestBattler>::const_iterator it; for (it = Data::system.battletest_data.begin(); it != Data::system.battletest_data.end(); ++it) { AddActor(it->actor_id); Game_Actor* actor = Game_Actors::GetActor(it->actor_id); actor->SetEquipment(0, it->weapon_id); actor->SetEquipment(1, it->shield_id); actor->SetEquipment(1, it->armor_id); actor->SetEquipment(1, it->helmet_id); actor->SetEquipment(1, it->accessory_id); actor->ChangeLevel(it->level, false); actor->SetHp(actor->GetMaxHp()); actor->SetSp(actor->GetMaxSp()); } Main_Data::game_player->Refresh(); }
bool Game::UpdateActors() { // Insert Buffered Actors for (int i = 0; i < ReIndexedActorBuffer.size(); i++) { AddActor(ReIndexedActorBuffer[i], ReIndexedActorCoolDown[i]); } // Clear the list now that all Actors are inserted ReIndexedActorBuffer.clear(); ReIndexedActorCoolDown.clear(); std::map<uint32_t, std::vector<Actor*>*>::iterator CoolDownGroupIterator; for (CoolDownGroupIterator = ActorUpdateGroups.begin(); CoolDownGroupIterator != ActorUpdateGroups.end(); CoolDownGroupIterator++) { int CoolDown = CoolDownGroupIterator->first; std::vector<Actor*>* TargetCarosel = CoolDownGroupIterator->second; std::vector<Actor*>* TargetBucket = &TargetCarosel[TickCounter % CoolDown]; for (int i = 0; i < TargetBucket->size(); i++) { int ActorDesiredCoolDown = (*TargetBucket)[i]->Update(); if (ActorDesiredCoolDown != CoolDown) { ReIndexedActorBuffer.push_back((*TargetBucket)[i]); ReIndexedActorCoolDown.push_back(ActorDesiredCoolDown); // Grab the last Actor, update it and replace the moved actor if (TargetBucket->size() > 1) { ((*TargetBucket).back())->Update(); (*TargetBucket)[i] = (*TargetBucket).back(); } (*TargetBucket).pop_back(); } } } return true; }
void GeometryDisplay::connectSTL(QString stlFile) { RemoveActor(STLactor); STLactor = NULL; if(!QFile::exists(stlFile)) return; reader->SetFileName(stlFile.toStdString().c_str()); reader->Update(); // Visualize STLmapper = vtkSmartPointer<vtkPolyDataMapper>::New(); STLmapper->SetInputConnection(reader->GetOutputPort()); STLactor = vtkSmartPointer<vtkActor>::New(); STLactor->SetMapper(STLmapper); STLactor->GetProperty()->SetDiffuseColor(0,0,1); AddActor(STLactor); reset(); }
void GeometryDisplay::drawPoint(double x, double y, double z) { // Create the geometry of a point (the coordinate) vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New(); const double p[3] = {x, y, z}; // Create the topology of the point (a vertex) vtkSmartPointer<vtkCellArray> vertices = vtkSmartPointer<vtkCellArray>::New(); vtkIdType pid[1]; pid[0] = points->InsertNextPoint(p); vertices->InsertNextCell(1,pid); // Create a polydata object vtkSmartPointer<vtkPolyData> point = vtkSmartPointer<vtkPolyData>::New(); // Set the points and vertices we created as the geometry and topology of the polydata point->SetPoints(points); point->SetVerts(vertices); // Visualize vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); mapper->SetInput(point); pointActor = vtkSmartPointer<vtkActor>::New(); pointActor->SetMapper(mapper); pointActor->GetProperty()->SetPointSize(20); pointActor->GetProperty()->SetDiffuseColor(1,0,0); AddActor(pointActor); reset(); }
bool rScene::ParseActors(riSerializationTarget* target){ riSerializationTarget* actorsTarget = target->SubObject("actors"); riSerializationTarget* actorTarget = actorsTarget->SubObject("actor"); if (actorTarget){ rString className, id; do{ actorTarget->String("class", className); actorTarget->String("id", id); rActor3* actor = m_engine->actors->GetActorClass(className, m_engine, id); if (actor){ actor->Load(actorTarget); AddActor(actor); } else{ rLog::Warning("Unable to load actor with class: " + className); } } while (actorTarget->Next()); } return true; }
int main(int, char *[]) { const std::string file = "/home/mathieu/dev/cochleo/share/cochlee.wav"; const audiofile audio(file); filterbank fb(audio.sample_frequency(),100,6000,1000); const auto xaxis = audio.time(); const auto yaxis = fb.center_frequency(); auto cochleo = fb.compute(audio.channel(0)); normalization(cochleo); // Create the color palette auto palette = vtkSmartPointer<vtkLookupTable>::New(); palette->SetTableRange(0.0,1.0); palette->SetHueRange(0.67,0.); palette->SetSaturationRange(0.7,0.3); palette->Build(); // Create a c-style rgb image const std::size_t width = xaxis.size(); const std::size_t height = yaxis.size(); std::vector<unsigned char> cImage(3*width*height); for(std::size_t i=0; i<width; ++i) for(std::size_t j=0; j<height; ++j) { unsigned char* color = palette->MapValue(cochleo[i][j]); cImage[3*(i+width*j)] = color[0]; cImage[3*(i+width*j)+1] = color[1]; cImage[3*(i+width*j)+2] = color[2]; } // Convert the c-style image to a vtkImageData auto imageImport = vtkSmartPointer<vtkImageImport>::New(); imageImport->SetDataSpacing(0.07, 1, 1); imageImport->SetDataOrigin(0, 0, 0); imageImport->SetWholeExtent(0, width-1, 0, height-1, 0, 0); imageImport->SetDataExtentToWholeExtent(); imageImport->SetDataScalarTypeToUnsignedChar(); imageImport->SetNumberOfScalarComponents(3); imageImport->SetImportVoidPointer(cImage.data()); imageImport->Update(); // Create an actor auto actor = vtkSmartPointer<vtkImageActor>::New(); actor->SetInput(imageImport->GetOutput()); // Create a scalar bar auto scalarBar = vtkSmartPointer<vtkScalarBarActor>::New(); scalarBar->SetLookupTable(palette); scalarBar->SetTitle("gain"); scalarBar->SetNumberOfLabels(5); // Configure text of the scalar bar auto textBar = vtkSmartPointer<vtkTextProperty>::New(); textBar->SetFontSize(10); scalarBar->SetTitleTextProperty(textBar); scalarBar->SetLabelTextProperty(textBar); // Setup renderer auto renderer = vtkSmartPointer<vtkRenderer>::New(); renderer->AddActor(actor); renderer->AddActor(scalarBar); renderer->ResetCamera(); // Setup render window auto renderWindow = vtkSmartPointer<vtkRenderWindow>::New(); renderWindow->AddRenderer(renderer); // Setup render window interactor auto renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New(); auto style = vtkSmartPointer<vtkInteractorStyleImage>::New(); renderWindowInteractor->SetInteractorStyle(style); // Render and start interaction renderWindowInteractor->SetRenderWindow(renderWindow); renderWindowInteractor->Initialize(); renderWindowInteractor->Start(); return EXIT_SUCCESS; }
Actor* EngineCore::AddActor_Mesh(const std::string& modelFilePath) { Actor* actor = AddActor(AddComponent_Mesh(modelFilePath)); return actor; }
void MeshDisplay::ShowMesh() { AddActor(actor); }
void MyWorld::Init() { World::Init(); TurnsLeft = 10; TurnsLeftChanged = true; Round = 1; RoundChanged = true; // Generate game grid RegenerateGameGrid(); // Create board Actor* board = new Actor(); board->Init(); board->setModel(g_pResources->Board); board->setTouchable(false); AddActor(board); // Create grid of cubes float offs = CUBE_SIZE / 2.0f; int *gg = GameGrid; for (int y = -GameGridHeight / 2; y < GameGridHeight / 2; y++) { for (int x = -GameGridWidth / 2; x < GameGridWidth / 2; x++) { // Create a game object MyActor* actor = new MyActor(); actor->Init(); // Set model and position actor->setModel(g_pResources->Cube); actor->setPosition(x * CUBE_SIZE + offs, CUBE_SIZE / 2.0f + 2.5f, y * CUBE_SIZE + offs); actor->setRotation(((float)*gg) * 90.0f, 90, 0); actor->setCollisionSphereRadius(CUBE_SIZE / 2.5f); actor->setGridPosition(x + GameGridWidth / 2, y + GameGridHeight / 2); actor->setID(0); // Add to world to be processed and rendered AddActor(actor); gg++; } } // Create turns left label text Label* label = new Label(); label->Init(); label->setColour(200, 200, 80, 255); label->setFont(g_pResources->Font); label->setText("TURNS LEFT"); AddActor(label); // Create turns left label to show how many turns are left TurnsLeftLabel = new Label(); TurnsLeftLabel->Init(); TurnsLeftLabel->setPosition(0, 30, 0); TurnsLeftLabel->setFont(g_pResources->Font); AddActor(TurnsLeftLabel); // Create current round label text label = new Label(); label->Init(); label->setColour(200, 200, 80, 255); label->setFont(g_pResources->Font); label->setText("ROUND"); label->setAligment(IW_GX_FONT_ALIGN_RIGHT, IW_GX_FONT_ALIGN_TOP); AddActor(label); // Create turns left label to show how many turns are left RoundLabel = new Label(); RoundLabel->Init(); RoundLabel->setPosition(0, 30, 0); RoundLabel->setAligment(IW_GX_FONT_ALIGN_RIGHT, IW_GX_FONT_ALIGN_TOP); RoundLabel->setFont(g_pResources->Font); AddActor(RoundLabel); // Create game over label text GameOverLabel = new Label(); GameOverLabel->Init(); GameOverLabel->setPosition(0, 0, 0); GameOverLabel->setScale(2.0f); GameOverLabel->setColour(255, 255, 255, 255); GameOverLabel->setAligment(IW_GX_FONT_ALIGN_CENTRE, IW_GX_FONT_ALIGN_MIDDLE); GameOverLabel->setFont(g_pResources->Font); GameOverLabel->setText("GAME OVER"); GameOverLabel->setVisible(false); AddActor(GameOverLabel); }
void MyWorld::Init() { World::Init(); TurnsLeft = 10; TurnsLeftChanged = true; Round = 1; RoundChanged = true; // Generate game grid //RegenerateGameGrid(); // Create board Actor* board = new Actor(); board->Init(); board->setModel(g_pResources->Board); board->setTouchable(false); board->setPosition(0, -10.f, 0); AddActor(board); // Create grid of cubes const float offs = CUBE_SIZE / 2.0f; for (int i = 0; i < MAX_CUSTOMERS; ++i) { // Create a game object MyActor* actor = new MyActor(); actor->Init(); // Set model and position actor->setModel(g_pResources->Cube); actor->setRotation(((float)(rand() % 4)) * 90.0f, 90, 0); actor->setCollisionSphereRadius(offs * 1.5f); actor->setID(0); actor->setVisible(false); actor->setPosition(0.f, 0.f, 90.f); // Add to world to be processed and rendered AddActor(actor); } for (int i = 0; i < 4; ++ i) { CustomerStore* actor = new CustomerStore(); actor->Init(); // Set model and position actor->setModel(g_pResources->Cube); actor->setRotation(((float)(i)) * 90.0f, 90, 0); actor->setScale(1.75f); actor->setPosition(-45.f + (i * CUBE_SIZE * actor->getScale() * 1.8f), 0.f, -40.f); actor->setCollisionSphereRadius(offs * actor->getScale() * 1.5f); actor->setID(0); // Add to world to be processed and rendered AddActor(actor); } SpawnCustomer(); // Create turns left label text Label* label = new Label(); label->Init(); label->setColour(200, 200, 80, 255); label->setFont(g_pResources->Font); label->setText("SCORE:"); AddActor(label); // Create turns left label to show how many turns are left TurnsLeftLabel = new Label(); TurnsLeftLabel->Init(); TurnsLeftLabel->setPosition(0, 30, 0); TurnsLeftLabel->setFont(g_pResources->Font); AddActor(TurnsLeftLabel); // Create current round label text label = new Label(); label->Init(); label->setColour(200, 200, 80, 255); label->setFont(g_pResources->Font); label->setText("ROUND"); label->setAligment(IW_GX_FONT_ALIGN_RIGHT, IW_GX_FONT_ALIGN_TOP); AddActor(label); // Create turns left label to show how many turns are left RoundLabel = new Label(); RoundLabel->Init(); RoundLabel->setPosition(0, 30, 0); RoundLabel->setAligment(IW_GX_FONT_ALIGN_RIGHT, IW_GX_FONT_ALIGN_TOP); RoundLabel->setFont(g_pResources->Font); AddActor(RoundLabel); // Create game over label text GameOverLabel = new Label(); GameOverLabel->Init(); GameOverLabel->setPosition(0, 0, 0); GameOverLabel->setScale(2.0f); GameOverLabel->setColour(255, 255, 255, 255); GameOverLabel->setAligment(IW_GX_FONT_ALIGN_CENTRE, IW_GX_FONT_ALIGN_MIDDLE); GameOverLabel->setFont(g_pResources->Font); GameOverLabel->setText("GAME OVER"); GameOverLabel->setVisible(false); AddActor(GameOverLabel); }
Level::Level(std::string filename) { entCount = 0; actCount = 0; selectedTile = NULL; targetedTile = NULL; //load XML file std::ifstream inFile; inFile.open(filename); if(!inFile) throw "Could not load level"; std::string xmlContents; std::string line; while(std::getline(inFile, line)) xmlContents += line; //Convert string to RapidXML-readable char pointer std::vector<char> xmlData = std::vector<char>(xmlContents.begin(), xmlContents.end()); xmlData.push_back('\0'); //create parsed document with &XMLDATA[0], which is equialent to char pointer rapidxml::xml_document<> doc; doc.parse<rapidxml::parse_no_data_nodes>(&xmlData[0]); //get root node rapidxml::xml_node<>* root = doc.first_node(); //get level attributes int width = atoi(root->first_attribute("width")->value()); int height = atoi(root->first_attribute("height")->value()); //resize level this->w = width; this->h = height; SetDimensions(width, height); //Load each necessary tileset rapidxml::xml_node<>* tileset = root->first_node("tileset", 0, true); while(tileset) { std::string path = tileset->first_attribute("path", 0, true)->value(); //load tileset textureManager.LoadTileset(path); //go to next tileset tileset = tileset->next_sibling("tileset", 0, true); } //Create selector sprite selectorSprite.setTexture(textureManager.GetTexture(4), true); //Create hover sprite hoverSprite.setTexture(textureManager.GetTexture(6), true); //Create grid sprite gridSprite.setTexture(textureManager.GetTexture(5), true); //Create move sprite moveSprite.setTexture(textureManager.GetTexture(7), true); //Create no-move sprite noMoveSprite.setTexture(textureManager.GetTexture(8), true); //Create target sprite targetSprite.setTexture(textureManager.GetTexture(9), true); //go through each tile rapidxml::xml_node<>* tile = root->first_node("tile", 0, true); while(tile) { //get all attributes int x = atoi(tile->first_attribute("x", 0, true)->value()); int y = atoi(tile->first_attribute("y", 0, true)->value()); int baseid = atoi(tile->first_attribute("baseid", 0, true)->value()); //check if tile is a wall or otherwise impassible bool wall = baseid == 1; //create tile and add to level Tile* newTile = new Tile(textureManager.GetTexture(baseid), wall, x, y); AddTile(x, y, newTile); //next tile tile = tile->next_sibling(); } //load actors rapidxml::xml_node<>* actorXml = root->first_node("actor", 0, true); for( ; actorXml; actorXml = actorXml->next_sibling("actor", 0, true)) { //**************** //Begin XML readin //**************** //get XML filename std::string actorFilename = actorXml->first_attribute("path", 0, true)->value(); //load XML file std::ifstream actorInFile; actorInFile.open(actorFilename); if(!actorInFile) throw "Could not load actor"; std::string actorLine; std::string actorXmlContents; while(std::getline(actorInFile, actorLine)) actorXmlContents += actorLine; //Convert string to RapidXML-readable char pointer std::vector<char> actorXmlData = std::vector<char>(actorXmlContents.begin(), actorXmlContents.end()); actorXmlData.push_back('\0'); //create parsed document with &XMLDATA[0], which is equialent to char pointer rapidxml::xml_document<> actorDoc; actorDoc.parse<rapidxml::parse_no_data_nodes>(&actorXmlData[0]); //get root node rapidxml::xml_node<>* actorRoot = actorDoc.first_node("actor", 0, true); //**************** //End XML readin //**************** if(actorRoot) AddActor(actorRoot); } //load entities rapidxml::xml_node<>* entityXml = root->first_node("entity", 0, true); for( ; entityXml; entityXml = entityXml->next_sibling("entity", 0, true)) { //**************** //Begin XML readin //**************** //get XML filename std::string entityFilename = entityXml->first_attribute("path", 0, true)->value(); //load XML file std::ifstream entityInFile; entityInFile.open(entityFilename); if(!entityInFile) throw "Could not load entity"; std::string entityLine; std::string entityXmlContents; while(std::getline(entityInFile, entityLine)) entityXmlContents += entityLine; //Convert string to RapidXML-readable char pointer std::vector<char> entityXmlData = std::vector<char>(entityXmlContents.begin(), entityXmlContents.end()); entityXmlData.push_back('\0'); //create parsed document with &XMLDATA[0], which is equialent to char pointer rapidxml::xml_document<> entityDoc; entityDoc.parse<rapidxml::parse_no_data_nodes>(&entityXmlData[0]); //get root node rapidxml::xml_node<>* entityRoot = entityDoc.first_node("entity", 0, true); //**************** //End XML readin //**************** if(entityRoot) AddEntity(entityRoot); } }
bool System::mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) { if(!m_bEnableInput){ return true; } if(id==OIS::MB_Left){ Engine::Scene* pScene = GameSystem::GetSingleton()->GetCurrentSection()->GetScene(); switch(m_CM){ case enCM_Select:{ Ray ray = BuildRay(arg.state.X.abs,arg.state.Y.abs); Engine::MovableObject* pObj=NULL; if(pScene->GetStaticSceneNode()->RayCast(ray,pObj)){ m_pRayCastMesh = dynamic_cast<Engine::MeshEntity*>(pObj); S8* pKey = Engine::GetGlobalSetting().m_pInputSystem->m_KeyArray; if( pKey[OIS::KC_LCONTROL] == 0 && pKey[OIS::KC_RCONTROL] == 0) { m_lstSelectObj.clear(); } if(m_pRayCastMesh!=NULL){ m_lstSelectObj.push_back(m_pRayCastMesh); Engine::SceneNode* pNode = m_pRayCastMesh->GetParentSceneNode(); if(pNode!=NULL){ const Float3 vObjPos = pNode->GetGlobalPosition(); m_pObjController->SetPosition(pNode->GetGlobalPosition()); } m_pObjController->SetSelectObjectBoundingBox( m_pRayCastMesh->GetWorldBoundingBox()); }else { Engine::SceneNode* pNode = pObj->GetParentSceneNode(); if(pNode!=NULL){ m_lstSelectObj.push_back(m_pRayCastMesh); m_pObjController->SetPosition(pNode->GetGlobalPosition()); m_pObjController->SetSelectObjectBoundingBox(pObj->GetWorldBoundingBox()); } } } break;} case enCM_SelectList:{ break;} case enCM_Move: case enCM_Rotate: case enCM_Scale:{ m_bIsControl = false; m_MoveType = Engine::eMRCT_None; m_MoveDir = Float2(arg.state.X.abs,arg.state.Y.abs); break;} case enCM_Create:{ Ray ray = BuildRay(arg.state.X.abs,arg.state.Y.abs); Engine::MovableObject* pObj=NULL; float fDis=999999.0f; if(pScene->GetStaticSceneNode()->RayCast(ray,pObj,&fDis)){ m_vRayCastPoint = ray.m_vStart + ray.m_vDirection*fDis; switch(m_CT){ case enCT_Object:{ AddObject(m_strCreateObjectName,m_vRayCastPoint); }break; case enCT_Actor:{ AddActor(m_strCreateObjectName,m_vRayCastPoint); }break; } } break;} } } return true; }
Actor* EngineCore::AddActor_Camera() { return AddActor(AddComponent_Camera()); }
//== Конструктор. SH3DBind::SH3DBind(Log* p_Log, UI uiWidth, UI uiHeight, Iterator<Parser::PNode*>* p_PNode, PhysXBind* p_PhysXBindI, UCH *p_uchResult) { // ПЕРЕМЕННЫЕ. Iterator<Parser::PNode*>* p_I_NActors = NULL; Iterator<Parser::PNode*>* p_I_NJoints = NULL; Iterator<Parser::PNode*>* p_I_NActorDetails = NULL; Iterator<Parser::PNode*>* p_I_NJointDetails = NULL; Iterator<Parser::PNode*>* p_I_N0 = NULL; Iterator<Parser::PNode*>* p_I_N1 = NULL; Iterator<Parser::PNode*>* p_I_NCameraDetails = NULL; // PhysXBind::sActor oActor; PhysXBind::sJoint oJoint; Iterator<Parser::PNode*>* p_I_Categories = NULL; PhysXBind::sAssembly* p_oAssembly = NULL; Iterator<Parser::PNode*>* p_I_Assemblies = NULL; Iterator<PhysXBind::sActor>* p_I_Actors = NULL; // H3DNode gniLight; // PxVec3 vPosition; PxVec3 vRotation; PxVec3 vLinear; PxVec3 vAngular; PxReal fSqrtScale; // PxVec3 vScale; //////////////// this->p_Log = p_Log; if (!h3dInit()) { LOG_HORDE3D_E("Невозможно инициаизировать Horde3D"); if (p_uchResult) *p_uchResult = U_H3D_INIT_ERROR; return; } else { LOG_HORDE3D_I("Horde3D инициализирован"); if (p_uchResult) *p_uchResult = U_OK; } p_PhysXBind = p_PhysXBindI; griPipe = h3dAddResource(H3DResTypes::Pipeline, "pipelines/forward.pipeline.xml", 0); // Инициализация всех ресурсов из итератора. ui00 = p_PNode->FindElementByName("Assemblies", 0, &uchResult); // Ищем сборки. if (uchResult == U_OK) { p_PNodeH00 = *p_PNode->GetValuePtr(ui00); // Разъём сборок. p_I_Assemblies = p_PNodeH00->p_ChildIterator; // Итератор сборок. THRU_ITERATOR(p_I_Assemblies) { p_PNodeH00 = *p_I_Assemblies->GetValuePtr(i); // Разъём конкретной сборки (имя из p_PNodeH00 в сборки). p_oAssembly = p_PhysXBind->p_I_Assemblies->GetValuePtr(AddAssembly(p_PNodeH00->p_NodeName)); p_I_Categories = p_PNodeH00->p_ChildIterator; // Итератор категорий. ui01 = p_I_Categories->FindElementByName("Actors", 0, &uchResult); // Ищем актёров. if (uchResult == U_OK) { p_PNodeH01 = *p_I_Categories->GetValuePtr(ui01); // Разъём актёров. p_I_NActors = p_PNodeH01->p_ChildIterator; // Итератор актёров. THRU_ITERATOR(p_I_NActors) { ZeroMemory(&oActor, sizeof(PhysXBind::sActor)); // Начало заполнения объекта актёра. p_PNodeH01 = *p_I_NActors->GetValuePtr(i); // Разъём конкретного актёра (имя из p_PNodeH01 в актёры). p_I_NActorDetails = p_PNodeH01->p_ChildIterator; // Текущий итератор описания актёра. if (p_I_NActorDetails) { ui02 = p_I_NActorDetails->FindElementByName("Model", 0, &uchResult); // Поиск элемента модели. if (uchResult == U_OK) { // Нашли модель для тела. p_PNodeH02 = *p_I_NActorDetails->GetValuePtr(ui02); // Взяли разъём описания модели. CopyString(p_PNodeH02->p_chData, oActor.mchModelName); // Имя модели из p_PNodeH02 в объект актёра. } ui02 = p_I_NActorDetails->FindElementByName("Position", 0, &uchResult); if (uchResult == U_OK) { oActor.vPos = AToPxVec3((*p_I_NActorDetails->GetValuePtr(ui02))->p_chData); } else oActor.vPos = cvIdent; ui02 = p_I_NActorDetails->FindElementByName("Rotation", 0, &uchResult); if (uchResult == U_OK) { oActor.vRot = AToPxVec3((*p_I_NActorDetails->GetValuePtr(ui02))->p_chData); } else oActor.vRot = cvIdent; ui02 = p_I_NActorDetails->FindElementByName("Scale", 0, &uchResult); if (uchResult == U_OK) { oActor.fScale = AToPxReal((*p_I_NActorDetails->GetValuePtr(ui02))->p_chData); } else oActor.fScale = 1.0f; fSqrtScale = PxSqrt(oActor.fScale); oActor.uchActorType = PX_ACTOR_DYNAMIC; ui02 = p_I_NActorDetails->FindElementByName("Static", 0, &uchResult); if (uchResult == U_OK) { oActor.uchActorType = PX_ACTOR_STATIC; } else { ui02 = p_I_NActorDetails->FindElementByName("L_Velocity", 0, &uchResult); if (uchResult == U_OK) { oActor.vLVel = AToPxVec3((*p_I_NActorDetails->GetValuePtr(ui02))->p_chData); } else oActor.vLVel = cvScIdent; ui02 = p_I_NActorDetails->FindElementByName("A_Velocity", 0, &uchResult); if (uchResult == U_OK) { oActor.vAVel = AToPxVec3((*p_I_NActorDetails->GetValuePtr(ui02))->p_chData); } else oActor.vAVel = cvScIdent; ui02 = p_I_NActorDetails->FindElementByName("Density_Mult", 0, &uchResult); if (uchResult == U_OK) { oActor.fDensMult = AToPxReal((*p_I_NActorDetails->GetValuePtr(ui02))->p_chData); } else oActor.fDensMult = 1.0f; } ui02 = p_I_NActorDetails->FindElementByName("Camera", 0, &uchResult); if (uchResult == U_OK) { p_PNodeH00 = *p_I_NActorDetails->GetValuePtr(ui02); p_I_NCameraDetails = p_PNodeH00->p_ChildIterator; ui02 = p_I_NCameraDetails->FindElementByName("Position", 0, &uchResult); if (uchResult == U_OK) { oActor.oCamera.vPos = AToPxVec3((*p_I_NCameraDetails->GetValuePtr(ui02))->p_chData); } else oActor.oCamera.vPos = cvIdent; ui02 = p_I_NCameraDetails->FindElementByName("Rotation", 0, &uchResult); if (uchResult == U_OK) { oActor.oCamera.vRot = AToPxVec3((*p_I_NCameraDetails->GetValuePtr(ui02))->p_chData); } else oActor.oCamera.vRot = cvIdent; } } // Актёр в итератор, создание актёра. AddActor(p_oAssembly, &oActor, p_PNodeH01->p_NodeName); } THRU_ITERATOR_END; } ui01 = p_I_Categories->FindElementByName("Joints", 0, &uchResult); // Ищем актёров. if (uchResult == U_OK) { p_PNodeH01 = *p_I_Categories->GetValuePtr(ui01); // Разъём суставов. p_I_NJoints = p_PNodeH01->p_ChildIterator; // Итератор суставов. THRU_ITERATOR(p_I_NJoints) { ZeroMemory(&oJoint, sizeof(PhysXBind::sJoint)); // Начало заполнения объекта актёра. p_PNodeH01 = *p_I_NJoints->GetValuePtr(i); // Разъём конкретного актёра (имя из p_PNodeH01 в актёры). p_ch00 = CopyString(p_PNodeH01->p_NodeName, mch0, '/'); CopyString(p_ch00, mch1); oJoint.p_Actor0 = p_oAssembly->p_I_Actors->GetValuePtr(p_oAssembly->p_I_Actors->FindElementByName(mch0)); oJoint.p_Actor1 = p_oAssembly->p_I_Actors->GetValuePtr(p_oAssembly->p_I_Actors->FindElementByName(mch1)); if (oJoint.p_Actor0 && oJoint.p_Actor1) { p_I_NJointDetails = p_PNodeH01->p_ChildIterator; // Текущий итератор описания актёра. if (p_I_NJointDetails) { ui02 = p_I_NJointDetails->FindElementByName("Actor0Initials", 0, &uchResult); if (uchResult == U_OK) { p_I_N0 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator; ui02 = p_I_N0->FindElementByName("Position", 0, &uchResult); if (uchResult == U_OK) { oJoint.vIPos0 = AToPxVec3((*p_I_N0->GetValuePtr(ui02))->p_chData); } ui02 = p_I_N0->FindElementByName("Rotation", 0, &uchResult); if (uchResult == U_OK) { oJoint.vIRot0 = AToPxVec3((*p_I_N0->GetValuePtr(ui02))->p_chData); } } ui02 = p_I_NJointDetails->FindElementByName("Actor1Initials", 0, &uchResult); if (uchResult == U_OK) { p_I_N0 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator; ui02 = p_I_N0->FindElementByName("Position", 0, &uchResult); if (uchResult == U_OK) { oJoint.vIPos1 = AToPxVec3((*p_I_N0->GetValuePtr(ui02))->p_chData); } ui02 = p_I_N0->FindElementByName("Rotation", 0, &uchResult); if (uchResult == U_OK) { oJoint.vIRot1 = AToPxVec3((*p_I_N0->GetValuePtr(ui02))->p_chData); } } ui02 = p_I_NJointDetails->FindElementByName("Motions", 0, &uchResult); if (uchResult == U_OK) { p_I_N0 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator; ui02 = p_I_N0->FindElementByName("AxisX", 0, &uchResult); if (uchResult == U_OK) { oJoint.mMotions[0] = PxD6Motion::Enum::eFREE; } ui02 = p_I_N0->FindElementByName("AxisY", 0, &uchResult); if (uchResult == U_OK) { oJoint.mMotions[1] = PxD6Motion::Enum::eFREE; } ui02 = p_I_N0->FindElementByName("AxisZ", 0, &uchResult); if (uchResult == U_OK) { oJoint.mMotions[2] = PxD6Motion::Enum::eFREE; } ui02 = p_I_N0->FindElementByName("Twist", 0, &uchResult); if (uchResult == U_OK) { oJoint.mMotions[3] = PxD6Motion::Enum::eFREE; } ui02 = p_I_N0->FindElementByName("Swing0", 0, &uchResult); if (uchResult == U_OK) { oJoint.mMotions[4] = PxD6Motion::Enum::eFREE; } ui02 = p_I_N0->FindElementByName("Swing1", 0, &uchResult); if (uchResult == U_OK) { oJoint.mMotions[5] = PxD6Motion::Enum::eFREE; } } ui02 = p_I_NJointDetails->FindElementByName("LinearLimit", 0, &uchResult); if (uchResult == U_OK) { oJoint.oLinearLimit.bIsOn = true; if (oJoint.mMotions[0] == PxD6Motion::Enum::eFREE) oJoint.mMotions[0] = PxD6Motion::Enum::eLIMITED; if (oJoint.mMotions[1] == PxD6Motion::Enum::eFREE) oJoint.mMotions[1] = PxD6Motion::Enum::eLIMITED; if (oJoint.mMotions[2] == PxD6Motion::Enum::eFREE) oJoint.mMotions[2] = PxD6Motion::Enum::eLIMITED; p_I_N1 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator; ui02 = p_I_N1->FindElementByName("Extend", 0, &uchResult); if (uchResult == U_OK) { oJoint.oLinearLimit.fExtend = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } ui02 = p_I_N1->FindElementByName("Spring", 0, &uchResult); if (uchResult == U_OK) { vt00 = AToPxVec2((*p_I_N1->GetValuePtr(ui02))->p_chData); oJoint.oLinearLimit.oSpring.bIsOn = true; oJoint.oLinearLimit.oSpring.fStiffness = vt00.x; oJoint.oLinearLimit.oSpring.fDamping = vt00.y; } } ui02 = p_I_NJointDetails->FindElementByName("TwistLimit", 0, &uchResult); if (uchResult == U_OK) { oJoint.oAngularLimitPair.bIsOn = true; oJoint.mMotions[3] = PxD6Motion::Enum::eLIMITED; p_I_N0 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator; ui02 = p_I_N0->FindElementByName("Bounds", 0, &uchResult); if (uchResult == U_OK) { vt00 = AToPxVec2((*p_I_N0->GetValuePtr(ui02))->p_chData); oJoint.oAngularLimitPair.fLowerLimit = vt00.x; oJoint.oAngularLimitPair.fLowerLimit = vt00.y; } ui02 = p_I_N0->FindElementByName("Spring", 0, &uchResult); if (uchResult == U_OK) { vt00 = AToPxVec2((*p_I_N0->GetValuePtr(ui02))->p_chData); oJoint.oAngularLimitPair.oSpring.bIsOn = true; oJoint.oAngularLimitPair.oSpring.fStiffness = vt00.x; oJoint.oAngularLimitPair.oSpring.fDamping = vt00.y; } } ui02 = p_I_NJointDetails->FindElementByName("SwingLimit", 0, &uchResult); if (uchResult == U_OK) { oJoint.oLimitCone.bIsOn = true; p_I_N0 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator; ui02 = p_I_N0->FindElementByName("ZLimit", 0, &uchResult); if (uchResult == U_OK) { oJoint.mMotions[4] = PxD6Motion::Enum::eLIMITED; oJoint.oLimitCone.fYLimitAngle = AToPxReal((*p_I_N0->GetValuePtr(ui02))->p_chData) / p_PhysXBind->cfQuaterCircle; } ui02 = p_I_N0->FindElementByName("YLimit", 0, &uchResult); if (uchResult == U_OK) { oJoint.mMotions[5] = PxD6Motion::Enum::eLIMITED; oJoint.oLimitCone.fZLimitAngle = AToPxReal((*p_I_N0->GetValuePtr(ui02))->p_chData) / p_PhysXBind->cfQuaterCircle; } ui02 = p_I_N0->FindElementByName("Spring", 0, &uchResult); if (uchResult == U_OK) { vt00 = AToPxVec2((*p_I_N0->GetValuePtr(ui02))->p_chData); oJoint.oLimitCone.oSpring.bIsOn = true; oJoint.oLimitCone.oSpring.fStiffness = vt00.x; oJoint.oLimitCone.oSpring.fDamping = vt00.y; } } ui02 = p_I_NJointDetails->FindElementByName("LinearDriveGoal", 0, &uchResult); if (uchResult == U_OK) { oJoint.vLinearDriveGoal = AToPxVec3((*p_I_NJointDetails->GetValuePtr(ui02))->p_chData); } ui02 = p_I_NJointDetails->FindElementByName("AngularDriveGoal", 0, &uchResult); if (uchResult == U_OK) { oJoint.vAngularDriveGoal = AToPxVec3((*p_I_NJointDetails->GetValuePtr(ui02))->p_chData); } ui02 = p_I_NJointDetails->FindElementByName("Drives", 0, &uchResult); if (uchResult == U_OK) { p_I_N0 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator; ui02 = p_I_N0->FindElementByName("AxisX", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[0].bIsOn = true; p_I_N1 = (*p_I_N0->GetValuePtr(ui02))->p_ChildIterator; ui02 = p_I_N1->FindElementByName("Stiffness", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[0].fDriveStiffness = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } ui02 = p_I_N1->FindElementByName("Сlutch", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[0].fDriveDamping = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } ui02 = p_I_N1->FindElementByName("Limit", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[0].fForceLimit = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } } ui02 = p_I_N0->FindElementByName("AxisY", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[1].bIsOn = true; p_I_N1 = (*p_I_N0->GetValuePtr(ui02))->p_ChildIterator; ui02 = p_I_N1->FindElementByName("Stiffness", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[1].fDriveStiffness = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } ui02 = p_I_N1->FindElementByName("Сlutch", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[1].fDriveDamping = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } ui02 = p_I_N1->FindElementByName("Limit", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[1].fForceLimit = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } } ui02 = p_I_N0->FindElementByName("AxisZ", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[2].bIsOn = true; p_I_N1 = (*p_I_N0->GetValuePtr(ui02))->p_ChildIterator; ui02 = p_I_N1->FindElementByName("Stiffness", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[2].fDriveStiffness = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } ui02 = p_I_N1->FindElementByName("Сlutch", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[2].fDriveDamping = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } ui02 = p_I_N1->FindElementByName("Limit", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[2].fForceLimit = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } } ui02 = p_I_N0->FindElementByName("Swing", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[3].bIsOn = true; p_I_N1 = (*p_I_N0->GetValuePtr(ui02))->p_ChildIterator; ui02 = p_I_N1->FindElementByName("Stiffness", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[3].fDriveStiffness = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } ui02 = p_I_N1->FindElementByName("Сlutch", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[3].fDriveDamping = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } ui02 = p_I_N1->FindElementByName("Limit", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[3].fForceLimit = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } } ui02 = p_I_N0->FindElementByName("Twist", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[4].bIsOn = true; p_I_N1 = (*p_I_N0->GetValuePtr(ui02))->p_ChildIterator; ui02 = p_I_N1->FindElementByName("Stiffness", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[4].fDriveStiffness = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } ui02 = p_I_N1->FindElementByName("Сlutch", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[4].fDriveDamping = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } ui02 = p_I_N1->FindElementByName("Limit", 0, &uchResult); if (uchResult == U_OK) { oJoint.mDriveInfos[4].fForceLimit = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData); } } } } AddJoint(p_oAssembly, oJoint); } } THRU_ITERATOR_END; }