这篇教程C++ GetScene函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetScene函数的典型用法代码示例。如果您正苦于以下问题:C++ GetScene函数的具体用法?C++ GetScene怎么用?C++ GetScene使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetScene函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: GetScenevoid World::RenderAllChunks(){ viewerPosition = GetScene()->m_camera.m_position; // Enable arrays glEnable(GL_VERTEX_ARRAY); glEnable(GL_TEXTURE_COORD_ARRAY); glEnable(GL_NORMAL_ARRAY); for(int x = 0; x < m_chunksInX; x++) for(int y = 0; y < m_chunksInY; y++) for(int z = 0; z < m_chunksInZ; z++) if(!m_chunkMatrix[x][y][z].IsEmpty()) m_chunkMatrix[x][y][z].Draw(); VBO::Unbind(GL_ARRAY_BUFFER); // Disable arrays glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_NORMAL_ARRAY);}
开发者ID:222464,项目名称:EvolvedVirtualCreaturesRepo,代码行数:22,
示例2: GetScenevoid plSimulationMgr::UpdateAvatarInDetector(plKey world, plPXPhysical* detector){ // search thru the actors in a scene looking for avatars that might be in the newly enabled detector region // ... and then send appropiate collision message if needed if ( detector->DoDetectorHullWorkaround() ) { NxScene* scene = GetScene(world); if (scene) { uint32_t numActors = scene->getNbActors(); NxActor** actors = scene->getActors(); for (int i = 0; i < numActors; i++) { if ( actors[i]->userData == nil ) { // we go a controller bool isController; plPXPhysicalControllerCore* controller = plPXPhysicalControllerCore::GetController(*actors[i],&isController); if (controller && controller->IsEnabled()) { plKey avatar = controller->GetOwner(); plSceneObject* avObj = plSceneObject::ConvertNoRef(avatar->ObjectIsLoaded()); const plCoordinateInterface* ci; if ( avObj && ( ci = avObj->GetCoordinateInterface() ) ) { if ( detector->IsObjectInsideHull(ci->GetWorldPos()) ) { detector->SetInsideConvexHull(true); // we are entering this world... say we entered this detector ISendCollisionMsg(detector->GetObjectKey(), avatar, true); } } } } } } }}
开发者ID:cwalther,项目名称:Plasma-nobink-test,代码行数:39,
示例3: GetScene //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void State::OnInit() { GetScene()->SetClearColour(CS::Colour(0.9f, 0.9f, 0.9f, 1.0f)); m_httpRequestSystem = CS::Application::Get()->GetSystem<CS::HttpRequestSystem>(); CS_ASSERT(m_httpRequestSystem, "Cannot complete HttpRequest smoke test as the system could not be created!"); const u32 k_downloadBufferSize = 100 * 1024; m_httpRequestSystem->SetMaxBufferSize(k_downloadBufferSize); Common::OptionsMenuDesc optionsMenuDesc; optionsMenuDesc.AddButton("Test download progress", [=]() { //TODO: This doesn't work on iOS as HTTP requests aren't allowed. We need to find a file that can be downloaded over HTTPS for testing. m_downloadProgressTestSystem->StartDownloadTest("http://download.thinkbroadband.com/5MB.zip", [=](const CS::HttpResponse& in_completeResponse) { PresentHttpResponse(in_completeResponse); }); }); m_optionsMenuPresenter->Present(optionsMenuDesc); }
开发者ID:ChilliWorks,项目名称:CSTest,代码行数:25,
示例4: OnNodeSetvoid UIComponent::OnNodeSet(Node* node){ rootElement_->SetNode(node); if (node) { auto* renderer = GetSubsystem<Renderer>(); auto* model = node->GetComponent<StaticModel>(); rootElement_->SetViewport(renderer->GetViewportForScene(GetScene(), viewportIndex_)); if (model == nullptr) model_ = model = node->CreateComponent<StaticModel>(); model->SetMaterial(material_); rootElement_->SetRenderTexture(texture_); } else { rootElement_->SetRenderTexture(nullptr); if (model_.NotNull()) { model_->Remove(); model_ = nullptr; } }}
开发者ID:weitjong,项目名称:Urho3D,代码行数:23,
示例5: StopFollowingvoid CSyncCoreObjectMediator::IntEndTransferObject(){ if( !IsActive() ) StopFollowing(); //这里无需进行StopMoving,让下面的函数通过基类完成这个事情 if( m_pConn ) GetScene()->DelFromMulticast( m_pConn ); CSyncCoreObjectServer::IntEndTransferObject(); m_bDisbindingConn = false; m_fDirKnownMaxSpeed = 0; if( !m_pConn ) return; AddConnBlockCount(); SetClientMainScene(); CSyncCoreObjectServer::SetEyeSight( m_fZeroDimEyeSight, 0 );}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:23,
示例6: GetScenevoid CollisionShape::OnNodeSet(Node* node){ if (node) { Scene* scene = GetScene(); if (scene) { if (scene == node) LOGWARNING(GetTypeName() + " should not be created to the root scene node"); physicsWorld_ = scene->GetOrCreateComponent<PhysicsWorld>(); physicsWorld_->AddCollisionShape(this); } else LOGERROR("Node is detached from scene, can not create collision shape"); node->AddListener(this); cachedWorldScale_ = node->GetWorldScale(); // Terrain collision shape depends on the terrain component's geometry updates. Subscribe to them SubscribeToEvent(node, E_TERRAINCREATED, HANDLER(CollisionShape, HandleTerrainCreated)); }}
开发者ID:AGreatFish,项目名称:Urho3D,代码行数:23,
示例7: GetScenevoid StaticModelGroup::ApplyAttributes(){ if (!nodeIDsDirty_) return; // Remove all old instance nodes before searching for new. Can not call RemoveAllInstances() as that would modify // the ID list on its own for (unsigned i = 0; i < instanceNodes_.Size(); ++i) { Node* node = instanceNodes_[i]; if (node) node->RemoveListener(this); } instanceNodes_.Clear(); Scene* scene = GetScene(); if (scene) { // The first index stores the number of IDs redundantly. This is for editing for (unsigned i = 1; i < nodeIDsAttr_.Size(); ++i) { Node* node = scene->GetNode(nodeIDsAttr_[i].GetUInt()); if (node) { WeakPtr<Node> instanceWeak(node); node->AddListener(this); instanceNodes_.Push(instanceWeak); } } } worldTransforms_.Resize(instanceNodes_.Size()); nodeIDsDirty_ = false; OnMarkedDirty(GetNode());}
开发者ID:LuisAntonRebollo,项目名称:Urho3D,代码行数:37,
示例8: GetScenevoid StaticModelGroup::ApplyAttributes(){ if (!nodesDirty_) return; // Remove all old instance nodes before searching for new for (unsigned i = 0; i < instanceNodes_.Size(); ++i) { Node* node = instanceNodes_[i]; if (node) node->RemoveListener(this); } instanceNodes_.Clear(); Scene* scene = GetScene(); if (scene) { // The first index stores the number of IDs redundantly. This is for editing for (unsigned i = 1; i < nodeIDsAttr_.Size(); ++i) { Node* node = scene->GetNode(nodeIDsAttr_[i].GetUInt()); if (node) { WeakPtr<Node> instanceWeak(node); node->AddListener(this); instanceNodes_.Push(instanceWeak); } } } worldTransforms_.Resize(instanceNodes_.Size()); numWorldTransforms_ = 0; // Correct amount will be found during world bounding box update nodesDirty_ = false; OnMarkedDirty(GetNode());}
开发者ID:tungsteen,项目名称:Urho3D,代码行数:37,
示例9: GetScenevoid Vehicle::InitWheel(const String& name, const Vector3& offset, WeakPtr<Node>& wheelNode, unsigned& wheelNodeID){ ResourceCache* cache = GetSubsystem<ResourceCache>(); // Note: do not parent the wheel to the hull scene node. Instead create it on the root level and let the physics // constraint keep it together wheelNode = GetScene()->CreateChild(name); wheelNode->SetPosition(node_->LocalToWorld(offset)); wheelNode->SetRotation(node_->GetRotation() * (offset.x_ >= 0.0 ? Quaternion(0.0f, 0.0f, -90.0f) : Quaternion(0.0f, 0.0f, 90.0f))); wheelNode->SetScale(Vector3(0.8f, 0.5f, 0.8f)); // Remember the ID for serialization wheelNodeID = wheelNode->GetID(); StaticModel* wheelObject = wheelNode->CreateComponent<StaticModel>(); RigidBody* wheelBody = wheelNode->CreateComponent<RigidBody>(); CollisionShape* wheelShape = wheelNode->CreateComponent<CollisionShape>(); Constraint* wheelConstraint = wheelNode->CreateComponent<Constraint>(); wheelObject->SetModel(cache->GetResource<Model>("Models/Cylinder.mdl")); wheelObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml")); wheelObject->SetCastShadows(true); wheelShape->SetSphere(1.0f); wheelBody->SetFriction(1.0f); wheelBody->SetMass(1.0f); wheelBody->SetLinearDamping(0.2f); // Some air resistance wheelBody->SetAngularDamping(0.75f); // Could also use rolling friction wheelBody->SetCollisionLayer(1); wheelConstraint->SetConstraintType(CONSTRAINT_HINGE); wheelConstraint->SetOtherBody(GetComponent<RigidBody>()); // Connect to the hull body wheelConstraint->SetWorldPosition(wheelNode->GetPosition()); // Set constraint's both ends at wheel's location wheelConstraint->SetAxis(Vector3::UP); // Wheel rotates around its local Y-axis wheelConstraint->SetOtherAxis(offset.x_ >= 0.0 ? Vector3::RIGHT : Vector3::LEFT); // Wheel's hull axis points either left or right wheelConstraint->SetLowLimit(Vector2(-180.0f, 0.0f)); // Let the wheel rotate freely around the axis wheelConstraint->SetHighLimit(Vector2(180.0f, 0.0f)); wheelConstraint->SetDisableCollision(true); // Let the wheel intersect the vehicle hull}
开发者ID:ClockTeam,项目名称:Clockwork,代码行数:37,
示例10: GetScenevoid Player::Raycast(const GameContext& gameContext){ GameScene* scene = GetScene(); XMFLOAT3 pos = GetTransform()->GetPosition(); XMFLOAT3 fw = GetTransform()->GetForward(); PxVec3 rayOrigin(pos.x,pos.y + 1.f,pos.z), rayDirection(fw.x,fw.y,fw.z); rayOrigin.x += fw.x * 2.5f; rayOrigin.z += fw.z * 2.5f; const PxU32 bufSize = 20; PxRaycastHit hit[bufSize]; PxRaycastBuffer buf(hit, bufSize); // [out] Blocking and touching hits will be stored here if(scene->GetPhysxProxy()->Raycast(rayOrigin, rayDirection, 5000, buf)) { for(PxU32 i = 0; i < buf.nbTouches; ++i) { BaseComponent* component = static_cast<BaseComponent*>(buf.touches[i].actor->userData); GameObject* go = component->GetGameObject(); string name = go->GetName(); cout << "RAYCAST OBJECT: " << name << endl; if(name == "Enemy") { Enemy* enemy = reinterpret_cast<Enemy*>(go); int dmg = 12.5f; enemy->Damage(dmg); } } PxVec3 vel = rayDirection * 1000; auto laser = new Laser(XMFLOAT3(vel.x, vel.y, vel.z)); AddChild(laser); }}
开发者ID:Kwintenvdb,项目名称:DirectX-Turret-Game,代码行数:36,
示例11: GetScenevoid RigidBody2D::OnMarkedDirty(Node* node){ if (physicsWorld_ && physicsWorld_->IsApplyingTransforms()) return; // Physics operations are not safe from worker threads Scene* scene = GetScene(); if (scene && scene->IsThreadedUpdate()) { scene->DelayedMarkedDirty(this); return; } // Check if transform has changed from the last one set in ApplyWorldTransform() b2Vec2 newPosition = ToB2Vec2(node_->GetWorldPosition()); float newAngle = node_->GetWorldRotation().RollAngle() * M_DEGTORAD; if (newPosition != bodyDef_.position || newAngle != bodyDef_.angle) { bodyDef_.position = newPosition; bodyDef_.angle = newAngle; if (body_) body_->SetTransform(newPosition, newAngle); }}
开发者ID:3dicc,项目名称:Urho3D,代码行数:24,
示例12: ViewFamilyvoid FPhATEdPreviewViewportClient::SimMouseMove(float DeltaX, float DeltaY){ DragX = Viewport->GetMouseX() - SharedData->LastClickPos.X; DragY = Viewport->GetMouseY() - SharedData->LastClickPos.Y; if (!SharedData->MouseHandle->GrabbedComponent) { return; } //We need to convert Pixel Delta into Screen position (deal with different viewport sizes) FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues( Viewport, GetScene(), EngineShowFlags )); FSceneView* View = CalcSceneView(&ViewFamily); FVector4 ScreenOldPos = View->PixelToScreen(SharedData->LastClickPos.X, SharedData->LastClickPos.Y, 1.f); FVector4 ScreenNewPos = View->PixelToScreen(DragX + SharedData->LastClickPos.X, DragY + SharedData->LastClickPos.Y, 1.f); FVector4 ScreenDelta = ScreenNewPos - ScreenOldPos; FVector4 ProjectedDelta = View->ScreenToWorld(ScreenDelta); FVector4 WorldDelta; //Now we project new ScreenPos to xy-plane of SimGrabLocation FVector LocalOffset = View->ViewMatrices.ViewMatrix.TransformPosition(SimGrabLocation + SimGrabZ * SimGrabPush); float ZDistance = GetViewportType() == ELevelViewportType::LVT_Perspective ? fabs(LocalOffset.Z) : 1.f; //in the ortho case we don't need to do any fixup because there is no perspective WorldDelta = ProjectedDelta * ZDistance; //Now we convert back into WorldPos FVector WorldPos = SimGrabLocation + WorldDelta + SimGrabZ * SimGrabPush; FVector NewLocation = WorldPos; float QuickRadius = 5 - SimGrabPush / SimHoldDistanceChangeDelta; QuickRadius = QuickRadius < 2 ? 2 : QuickRadius; DrawDebugPoint(GetWorld(), NewLocation, QuickRadius, FColorList::Red, false, 0.3); SharedData->MouseHandle->SetTargetLocation(NewLocation); SharedData->MouseHandle->GrabbedComponent->WakeRigidBody(SharedData->MouseHandle->GrabbedBoneName);}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:36,
示例13: GetSceneEditorbool CubemapGenerator::InitRender(){ sceneEditor_ = GetSceneEditor(); if (sceneEditor_.Null()) { LOGERROR("CubemapGenerator::InitRender - unable to get scene editor"); return false; } if (!InitPaths()) return false; cameraNode_ = node_->CreateChild("CubeMapRenderCamera"); cameraNode_->SetTemporary(true); camera_ = cameraNode_->CreateComponent<Camera>(); camera_->SetTemporary(true); camera_->SetFov(90.0f); camera_->SetNearClip(0.0001f); camera_->SetAspectRatio(1.0f); RenderPath* renderPath = sceneEditor_->GetSceneView3D()->GetViewport()->GetRenderPath(); viewport_ = new Viewport(context_, GetScene(), camera_, renderPath); renderImage_ = new Texture2D(context_); renderImage_->SetSize(imageSize_, imageSize_, Graphics::GetRGBAFormat(), TEXTURE_RENDERTARGET); renderSurface_ = renderImage_->GetRenderSurface(); renderSurface_->SetViewport(0, viewport_); renderSurface_->SetUpdateMode(SURFACE_UPDATEALWAYS); return true;}
开发者ID:GREYFOXRGR,项目名称:AtomicGameEngine,代码行数:36,
示例14: GetScenevoid RigidBody::OnNodeSet(Node* node){ if (node) { Scene* scene = GetScene(); if (scene) { if (scene == node) LOGWARNING(GetTypeName() + " should not be created to the root scene node"); physicsWorld_ = scene->GetComponent<PhysicsWorld>(); if (physicsWorld_) physicsWorld_->AddRigidBody(this); else LOGERROR("No physics world component in scene, can not create rigid body"); AddBodyToWorld(); } else LOGERROR("Node is detached from scene, can not create rigid body"); node->AddListener(this); }}
开发者ID:PeteX,项目名称:Urho3D,代码行数:24,
示例15: GetScenevoid Node::SetNetParentAttr(const PODVector<unsigned char>& value){ Scene* scene = GetScene(); if (!scene) return; MemoryBuffer buf(value); // If nothing in the buffer, parent is the root node if (buf.IsEof()) { scene->AddChild(this); return; } unsigned baseNodeID = buf.ReadNetID(); Node* baseNode = scene->GetNode(baseNodeID); if (!baseNode) { LOGWARNING("Failed to find parent node " + String(baseNodeID)); return; } // If buffer contains just an ID, the parent is replicated and we are done if (buf.IsEof()) baseNode->AddChild(this); else { // Else the parent is local and we must find it recursively by name hash StringHash nameHash = buf.ReadStringHash(); Node* parentNode = baseNode->GetChild(nameHash, true); if (!parentNode) LOGWARNING("Failed to find parent node with name hash " + nameHash.ToString()); else parentNode->AddChild(this); }}
开发者ID:acremean,项目名称:urho3d,代码行数:36,
示例16: CS_ASSERT //------------------------------------------------------------- //------------------------------------------------------------- void Entity::AddComponent(const ComponentSPtr& in_component) { CS_ASSERT(in_component != nullptr, "Cannot add null component"); CS_ASSERT(in_component->GetEntity() == nullptr, "Component cannot be attached to more than 1 entity at a time."); m_components.push_back(in_component); in_component->SetEntity(this); in_component->OnAddedToEntity(); if(GetScene() != nullptr) { in_component->OnAddedToScene(); if (m_appActive == true) { in_component->OnResume(); if (m_appForegrounded == true) { in_component->OnForeground(); } } } }
开发者ID:mclaughlinhugh4,项目名称:ChilliSource,代码行数:26,
示例17: GetScenevoid FPreviewScene::AddComponent(UActorComponent* Component,const FTransform& LocalToWorld){ Components.AddUnique(Component); USceneComponent* SceneComp = Cast<USceneComponent>(Component); if(SceneComp && SceneComp->GetAttachParent() == NULL) { SceneComp->SetRelativeTransform(LocalToWorld); } Component->RegisterComponentWithWorld(GetWorld()); if (bForceAllUsedMipsResident) { // Add a mip streaming override to the new mesh UMeshComponent* pMesh = Cast<UMeshComponent>(Component); if (pMesh != NULL) { pMesh->SetTextureForceResidentFlag(true); } } GetScene()->UpdateSpeedTreeWind(0.0);}
开发者ID:stoneStyle,项目名称:Unreal4,代码行数:24,
示例18: GetScene void Layer::EndDrawing() { m_commonObject->EndDrawing(); if (m_postEffects.size() > 0) { for (auto& p : m_postEffects) { GetScene()->m_coreScene->BeginPostEffect(p->GetCoreObject()); GetScene()->m_coreScene->GetSrcTarget()->AddRef(); GetScene()->m_coreScene->GetDstTarget()->AddRef(); auto src = CreateSharedPtrWithReleaseDLL(GetScene()->m_coreScene->GetSrcTarget()); auto dst = CreateSharedPtrWithReleaseDLL(GetScene()->m_coreScene->GetDstTarget()); p->OnDraw(dst, src); GetScene()->m_coreScene->EndPostEffect(p->GetCoreObject()); } } }
开发者ID:weiron,项目名称:amusement-creators-engine,代码行数:22,
示例19: getNodeIdBabylonCamera::BabylonCamera(BabylonNode& babnode){ auto node = babnode.fbxNode(); std::string ansiName = node->GetName(); name = std::wstring(ansiName.begin(), ansiName.end()); id = getNodeId(node); auto parent = node->GetParent(); if (parent) { parentId = getNodeId(parent); } auto camera = node->GetCamera(); if (!camera) { return; } type = L"FreeCamera"; auto targetNode = node->GetTarget(); if (targetNode) { lockedTargetId = getNodeId(targetNode); } else { target = camera->InterestPosition.Get(); } position = babnode.localTranslate(); rotationQuaternion = babnode.localRotationQuat(); fov = camera->FieldOfViewY * Euler2Rad; minZ = camera->FrontPlaneDistance.Get(); maxZ = camera->BackPlaneDistance.Get(); auto hasAnimStack = node->GetScene()->GetSrcObjectCount<FbxAnimStack>() > 0; if (!hasAnimStack){ return; } auto animStack = node->GetScene()->GetSrcObject<FbxAnimStack>(0); FbxString animStackName = animStack->GetName(); FbxTakeInfo* takeInfo = node->GetScene()->GetTakeInfo(animStackName); auto animTimeMode = GlobalSettings::Current().AnimationsTimeMode; auto animFrameRate = GlobalSettings::Current().AnimationsFrameRate(); auto startFrame = takeInfo->mLocalTimeSpan.GetStart().GetFrameCount(animTimeMode); auto endFrame = takeInfo->mLocalTimeSpan.GetStop().GetFrameCount(animTimeMode); auto animLengthInFrame = endFrame - startFrame + 1; auto posAnim = std::make_shared<BabylonAnimation<babylon_vector3>>(BabylonAnimationBase::loopBehavior_Cycle, animFrameRate, L"position", L"position", true, 0, animLengthInFrame, true); auto rotAnim = std::make_shared<BabylonAnimation<babylon_vector4>>(BabylonAnimationBase::loopBehavior_Cycle, animFrameRate, L"rotation", L"rotation", true, 0, animLengthInFrame, true); auto targetAnim = std::make_shared<BabylonAnimation<babylon_vector3>>(BabylonAnimationBase::loopBehavior_Cycle, animFrameRate, L"target", L"target", true, 0, animLengthInFrame, true); for (auto ix = 0ll; ix < animLengthInFrame; ix++){ FbxTime currTime; currTime.SetFrame(startFrame + ix, animTimeMode); babylon_animation_key<babylon_vector3> poskey; babylon_animation_key<babylon_vector4> rotkey; poskey.frame = ix; rotkey.frame = ix; poskey.values = babnode.localTranslate(currTime); rotkey.values = babnode.localRotationQuat(currTime); posAnim->appendKey(poskey); rotAnim->appendKey(rotkey); if (lockedTargetId.size() == 0){ babylon_animation_key<babylon_vector3> targetKey; targetKey.frame = ix; targetKey.values = camera->InterestPosition.EvaluateValue(currTime); targetAnim->appendKey(targetKey); } } if (!posAnim->isConstant()){ animations.push_back(posAnim); } if (!rotAnim->isConstant()){ quatAnimations.push_back(rotAnim); } if (!targetAnim->isConstant()){ animations.push_back(targetAnim); }}
开发者ID:Gpinchon,项目名称:Babylon.js,代码行数:78,
示例20: assertbool SceneObject_Door::Create(const std::string &doorModelName, const Vec3f &pos, float angle, bool openCW){ assert(!m_created); Scene* pScene = GetScene(); assert(pScene != NULL); Asset* pDoorModelAsset; if(!pScene->GetAssetManager_AutoCreate("modelOBJ", Model_OBJ::Asset_Factory)->GetAsset(doorModelName, pDoorModelAsset)) return false; m_pDoorModel = static_cast<Model_OBJ*>(pDoorModelAsset); m_pDoorModel->SetRenderer(GetScene()); // Default texture setting: nearest filtering for(unsigned int i = 0, size = m_pDoorModel->GetNumMaterials(); i < size; i++) { Model_OBJ::Material* pMat = m_pDoorModel->GetMaterial(i); pMat->m_pDiffuseMap->Bind(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); if(pMat->m_pSpecularMap != NULL) { pMat->m_pSpecularMap->Bind(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } if(pMat->m_pNormalMap != NULL) { pMat->m_pNormalMap->Bind(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } } // Sound effects SoundSystem* pSoundSystem = static_cast<SoundSystem*>(pScene->GetNamed_Effect("sndsys")); assert(pSoundSystem != NULL); Asset* pAsset; if(!pSoundSystem->m_sound_effect_manager.GetAsset("data/sounds/doorOpen.wav", pAsset)) abort(); m_pOpenSoundEffect = static_cast<Sound_Effect*>(pAsset); assert(m_pOpenSoundEffect != NULL); if(!pSoundSystem->m_sound_effect_manager.GetAsset("data/sounds/doorClose.wav", pAsset)) abort(); m_pCloseSoundEffect = static_cast<Sound_Effect*>(pAsset); assert(m_pCloseSoundEffect != NULL); m_pos = pos; m_angle = angle; m_openCW = openCW; RegenAABB(); // Set up sound source m_doorSource.SetPosition(m_pos); m_doorSource.SetVelocity(Vec3f(0.0f, 0.0f, 0.0f)); m_doorSource.SetGain(1.0f); m_doorSource.SetLooping(false); m_created = true; return true;}
开发者ID:222464,项目名称:EvolvedVirtualCreaturesRepo,代码行数:78,
示例21: switchvoid SceneObject_Door::Logic(){ switch(m_action) { case e_opening: if(m_openCW) { float endAngle = m_initAngle - pif_over_2; m_angle -= s_openAndCloseSpeed * GetScene()->m_frameTimer.GetTimeMultiplier(); if(m_angle < endAngle) { m_angle = endAngle; m_action = e_none; m_state = e_open; } RegenAABB(); } else { float endAngle = m_initAngle + pif_over_2; m_angle += s_openAndCloseSpeed * GetScene()->m_frameTimer.GetTimeMultiplier(); if(m_angle > endAngle) { m_angle = endAngle; m_action = e_none; m_state = e_open; } RegenAABB(); } break; case e_closing: if(m_openCW) { m_angle += s_openAndCloseSpeed * GetScene()->m_frameTimer.GetTimeMultiplier(); if(m_angle > m_initAngle) { m_angle = m_initAngle; m_action = e_none; m_state = e_closed; } RegenAABB(); } else { m_angle -= s_openAndCloseSpeed * GetScene()->m_frameTimer.GetTimeMultiplier(); if(m_angle < m_initAngle) { m_angle = m_initAngle; m_action = e_none; m_state = e_closed; } RegenAABB(); } break; }}
开发者ID:222464,项目名称:EvolvedVirtualCreaturesRepo,代码行数:77,
示例22: GetScenevoid RaycastVehicle::Init(){ hullBody_ = node_->GetOrCreateComponent<RigidBody>(); Scene* scene = GetScene(); vehicleData_->Init(scene, hullBody_);}
开发者ID:gogoprog,项目名称:Urho3D,代码行数:6,
示例23: ViewFamilyvoid FJavascriptUMGViewportClient::Draw(FViewport* InViewport, FCanvas* Canvas){ FViewport* ViewportBackup = Viewport; Viewport = InViewport ? InViewport : Viewport; // Determine whether we should use world time or real time based on the scene. float TimeSeconds; float RealTimeSeconds; float DeltaTimeSeconds; const bool bIsRealTime = true; UWorld* World = GWorld; if ((GetScene() != World->Scene) || (bIsRealTime == true)) { // Use time relative to start time to avoid issues with float vs double TimeSeconds = FApp::GetCurrentTime() - GStartTime; RealTimeSeconds = FApp::GetCurrentTime() - GStartTime; DeltaTimeSeconds = FApp::GetDeltaTime(); } else { TimeSeconds = World->GetTimeSeconds(); RealTimeSeconds = World->GetRealTimeSeconds(); DeltaTimeSeconds = World->GetDeltaSeconds(); } // Setup a FSceneViewFamily/FSceneView for the viewport. FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues( Canvas->GetRenderTarget(), GetScene(), EngineShowFlags) .SetWorldTimes(TimeSeconds, DeltaTimeSeconds, RealTimeSeconds) .SetRealtimeUpdate(bIsRealTime)); ViewFamily.EngineShowFlags = EngineShowFlags; //UpdateLightingShowFlags(ViewFamily.EngineShowFlags); //ViewFamily.ExposureSettings = ExposureSettings; //ViewFamily.LandscapeLODOverride = LandscapeLODOverride; FSceneView* View = CalcSceneView(&ViewFamily); //SetupViewForRendering(ViewFamily, *View); FSlateRect SafeFrame; View->CameraConstrainedViewRect = View->UnscaledViewRect; //if ( CalculateEditorConstrainedViewRect(SafeFrame, Viewport) ) //{ // View->CameraConstrainedViewRect = FIntRect(SafeFrame.Left, SafeFrame.Top, SafeFrame.Right, SafeFrame.Bottom); //} if (IsAspectRatioConstrained()) { // Clear the background to black if the aspect ratio is constrained, as the scene view won't write to all pixels. Canvas->Clear(FLinearColor::Black); } Canvas->Clear(BackgroundColor); // workaround for hacky renderer code that uses GFrameNumber to decide whether to resize render targets --GFrameNumber; GetRendererModule().BeginRenderingViewFamily(Canvas, &ViewFamily); Viewport = ViewportBackup;}
开发者ID:Jeezymang,项目名称:Unreal.js-core,代码行数:68,
示例24: HandleWoundedStatevoid Character2D::Update(float timeStep){ // Handle wounded/killed states if (killed_) return; if (wounded_) { HandleWoundedState(timeStep); return; } // Set temporary variables auto* input = GetSubsystem<Input>(); auto* body = GetComponent<RigidBody2D>(); auto* animatedSprite = GetComponent<AnimatedSprite2D>(); bool onGround = false; bool jump = false; // Collision detection (AABB query) Vector2 characterHalfSize = Vector2(0.16f, 0.16f); auto* physicsWorld = GetScene()->GetComponent<PhysicsWorld2D>(); PODVector<RigidBody2D*> collidingBodies; physicsWorld->GetRigidBodies(collidingBodies, Rect(node_->GetWorldPosition2D() - characterHalfSize - Vector2(0.0f, 0.1f), node_->GetWorldPosition2D() + characterHalfSize)); if (collidingBodies.Size() > 1 && !isClimbing_) onGround = true; // Set direction Vector2 moveDir = Vector2::ZERO; // Reset if (input->GetKeyDown(KEY_A) || input->GetKeyDown(KEY_LEFT)) { moveDir = moveDir + Vector2::LEFT; animatedSprite->SetFlipX(false); // Flip sprite (reset to default play on the X axis) } if (input->GetKeyDown(KEY_D) || input->GetKeyDown(KEY_RIGHT)) { moveDir = moveDir + Vector2::RIGHT; animatedSprite->SetFlipX(true); // Flip sprite (flip animation on the X axis) } // Jump if ((onGround || aboveClimbable_) && (input->GetKeyPress(KEY_W) || input->GetKeyPress(KEY_UP))) jump = true; // Climb if (isClimbing_) { if (!aboveClimbable_ && (input->GetKeyDown(KEY_UP) || input->GetKeyDown(KEY_W))) moveDir = moveDir + Vector2(0.0f, 1.0f); if (input->GetKeyDown(KEY_DOWN) || input->GetKeyDown(KEY_S)) moveDir = moveDir + Vector2(0.0f, -1.0f); } // Move if (!moveDir.Equals(Vector2::ZERO) || jump) { if (onSlope_) body->ApplyForceToCenter(moveDir * MOVE_SPEED / 2, true); // When climbing a slope, apply force (todo: replace by setting linear velocity to zero when will work) else node_->Translate(Vector3(moveDir.x_, moveDir.y_, 0) * timeStep * 1.8f); if (jump) body->ApplyLinearImpulse(Vector2(0.0f, 0.17f) * MOVE_SPEED, body->GetMassCenter(), true); } // Animate if (input->GetKeyDown(KEY_SPACE)) { if (animatedSprite->GetAnimation() != "attack") { animatedSprite->SetAnimation("attack", LM_FORCE_LOOPED); animatedSprite->SetSpeed(1.5f); } } else if (!moveDir.Equals(Vector2::ZERO)) { if (animatedSprite->GetAnimation() != "run") animatedSprite->SetAnimation("run"); } else if (animatedSprite->GetAnimation() != "idle") { animatedSprite->SetAnimation("idle"); }}
开发者ID:1vanK,项目名称:Urho3D,代码行数:86,
示例25: BabylonAbstractMeshBabylonMesh::BabylonMesh(BabylonNode* node) : BabylonAbstractMesh(node), _isEnabled(true), _isVisible(true), _billboardMode(0), _visibility(1), _skeletonId(-1), _pickable(true), _hasVertexAlpha(false), _checkCollision(false), _receiveShadows(false), _infiniteDistance(false), _autoAnimate(false), _autoAnimateFrom(0), _autoAnimateTo(0), _autoAnimateLoop(false), _showBoundingBox(false), _showSubMeshesBoundingBox(false), _applyFog(false), _alphaIndex(0){ pivotMatrix.SetIdentity(); auto fbxNode = node->fbxNode(); std::string ansiName = fbxNode->GetName(); name(std::wstring(ansiName.begin(), ansiName.end())); id(getNodeId(fbxNode)); auto parent = fbxNode->GetParent(); if (parent) { parentId(getNodeId(parent)); } pivotMatrix = ConvertToBabylonCoordinateSystem( GetGeometryTransformation(fbxNode)); auto animStack = fbxNode->GetScene()->GetSrcObject<FbxAnimStack>(0); FbxString animStackName = animStack->GetName(); FbxTakeInfo* takeInfo = fbxNode->GetScene()->GetTakeInfo(animStackName); auto animTimeMode = GlobalSettings::Current().AnimationsTimeMode; auto animFrameRate = GlobalSettings::Current().AnimationsFrameRate(); auto startFrame = takeInfo->mLocalTimeSpan.GetStart().GetFrameCount(animTimeMode); auto endFrame = takeInfo->mLocalTimeSpan.GetStop().GetFrameCount(animTimeMode); auto animLengthInFrame = endFrame - startFrame + 1; _visibility = static_cast<float>(node->fbxNode()->Visibility.Get()); auto posAnim = std::make_shared<BabylonAnimation<babylon_vector3>>(BabylonAnimationBase::loopBehavior_Cycle, static_cast<int>(animFrameRate), L"position", L"position", true, 0, static_cast<int>(animLengthInFrame), true); auto rotAnim = std::make_shared<BabylonAnimation<babylon_vector4>>(BabylonAnimationBase::loopBehavior_Cycle, static_cast<int>(animFrameRate), L"rotationQuaternion", L"rotationQuaternion", true, 0, static_cast<int>(animLengthInFrame), true); auto scaleAnim = std::make_shared<BabylonAnimation<babylon_vector3>>(BabylonAnimationBase::loopBehavior_Cycle, static_cast<int>(animFrameRate), L"scaling", L"scaling", true, 0, static_cast<int>(animLengthInFrame), true); auto visibilityAnim = std::make_shared<BabylonAnimation<float>>(BabylonAnimationBase::loopBehavior_Cycle, static_cast<int>(animFrameRate), L"visibility", L"visibility", true, 0, static_cast<int>(animLengthInFrame), true); auto mesh = fbxNode->GetMesh(); _isVisible = fbxNode->Show.Get(); auto rotCurveNode = fbxNode->LclRotation.GetCurveNode(); auto translateCurveNode = fbxNode->LclTranslation.GetCurveNode(); auto scalingCurveNode = fbxNode->LclScaling.GetCurveNode(); auto visibilityCurveNode = fbxNode->Visibility.GetCurveNode(); if (rotCurveNode || translateCurveNode || scalingCurveNode) { for (auto ix = 0; ix < animLengthInFrame; ix++) { FbxTime currTime; currTime.SetFrame(startFrame + ix, animTimeMode); babylon_animation_key<babylon_vector3> poskey; babylon_animation_key<babylon_vector4> rotkey; babylon_animation_key<babylon_vector3> scalekey; poskey.frame = ix; rotkey.frame = ix; scalekey.frame = ix; auto currTransform = node->GetLocal(currTime); poskey.values = currTransform.translation(); rotkey.values = currTransform.rotationQuaternion(); scalekey.values = currTransform.scaling(); posAnim->appendKey(poskey); rotAnim->appendKey(rotkey); scaleAnim->appendKey(scalekey); } } if (visibilityCurveNode) { for (auto ix = 0; ix < animLengthInFrame; ix++) { FbxTime currTime; currTime.SetFrame(startFrame + ix, animTimeMode); babylon_animation_key<float> visibilityKey; visibilityKey.frame = ix; visibilityKey.values = static_cast<float>(node->fbxNode()->Visibility.EvaluateValue(currTime)); visibilityAnim->appendKey(visibilityKey); } } if (!posAnim->isConstant()){ animations.push_back(posAnim); } if (!rotAnim->isConstant()){ animations.push_back(rotAnim); } if (!scaleAnim->isConstant()){//.........这里部分代码省略.........
开发者ID:nickooms,项目名称:Babylon.js,代码行数:101,
示例26: PROFILEvoid CollisionShape::UpdateShape(){ PROFILE(UpdateCollisionShape); ReleaseShape(); if (!physicsWorld_) return; if (node_) { Vector3 newWorldScale = node_->GetWorldScale(); switch (shapeType_) { case SHAPE_BOX: shape_ = new btBoxShape(ToBtVector3(size_ * 0.5f)); shape_->setLocalScaling(ToBtVector3(newWorldScale)); break; case SHAPE_SPHERE: shape_ = new btSphereShape(size_.x_ * 0.5f); shape_->setLocalScaling(ToBtVector3(newWorldScale)); break; case SHAPE_STATICPLANE: shape_ = new btStaticPlaneShape(btVector3(0.0f, 1.0f, 0.0f), 0.0f); break; case SHAPE_CYLINDER: shape_ = new btCylinderShape(btVector3(size_.x_ * 0.5f, size_.y_ * 0.5f, size_.x_ * 0.5f)); shape_->setLocalScaling(ToBtVector3(newWorldScale)); break; case SHAPE_CAPSULE: shape_ = new btCapsuleShape(size_.x_ * 0.5f, Max(size_.y_ - size_.x_, 0.0f)); shape_->setLocalScaling(ToBtVector3(newWorldScale)); break; case SHAPE_CONE: shape_ = new btConeShape(size_.x_ * 0.5f, size_.y_); shape_->setLocalScaling(ToBtVector3(newWorldScale)); break; case SHAPE_TRIANGLEMESH: size_ = size_.Abs(); if (model_) { // Check the geometry cache Pair<Model*, unsigned> id = MakePair(model_.Get(), lodLevel_); HashMap<Pair<Model*, unsigned>, SharedPtr<CollisionGeometryData> >& cache = physicsWorld_->GetTriMeshCache(); HashMap<Pair<Model*, unsigned>, SharedPtr<CollisionGeometryData> >::Iterator j = cache.Find(id); if (j != cache.End()) geometry_ = j->second_; else { geometry_ = new TriangleMeshData(model_, lodLevel_); // Check if model has dynamic buffers, do not cache in that case if (!HasDynamicBuffers(model_, lodLevel_)) cache[id] = geometry_; } TriangleMeshData* triMesh = static_cast<TriangleMeshData*>(geometry_.Get()); shape_ = new btScaledBvhTriangleMeshShape(triMesh->shape_, ToBtVector3(newWorldScale * size_)); // Watch for live reloads of the collision model to reload the geometry if necessary SubscribeToEvent(model_, E_RELOADFINISHED, HANDLER(CollisionShape, HandleModelReloadFinished)); } break; case SHAPE_CONVEXHULL: size_ = size_.Abs(); if (customGeometryID_ && GetScene()) { Node* node = GetScene()->GetNode(customGeometryID_); CustomGeometry* custom = node ? node->GetComponent<CustomGeometry>() : 0; if (custom) { geometry_ = new ConvexData(custom); ConvexData* convex = static_cast<ConvexData*>(geometry_.Get()); shape_ = new btConvexHullShape((btScalar*)convex->vertexData_.Get(), convex->vertexCount_, sizeof(Vector3)); shape_->setLocalScaling(ToBtVector3(newWorldScale * size_)); LOGINFO("Set convexhull from customgeometry"); } else LOGWARNING("Could not find custom geometry component from node ID " + String(customGeometryID_) + " for convex shape creation"); } else if (model_) { // Check the geometry cache Pair<Model*, unsigned> id = MakePair(model_.Get(), lodLevel_); HashMap<Pair<Model*, unsigned>, SharedPtr<CollisionGeometryData> >& cache = physicsWorld_->GetConvexCache(); HashMap<Pair<Model*, unsigned>, SharedPtr<CollisionGeometryData> >::Iterator j = cache.Find(id); if (j != cache.End()) geometry_ = j->second_; else { geometry_ = new ConvexData(model_, lodLevel_); // Check if model has dynamic buffers, do not cache in that case if (!HasDynamicBuffers(model_, lodLevel_)) cache[id] = geometry_;//.........这里部分代码省略.........
开发者ID:gameogre,项目名称:Urho3D,代码行数:101,
示例27: Vector2void HeightmapEditorSystem::UpdateBrushTool(float32 timeElapsed){ if (!toolImage) { DAVA::Logger::Error("Tool image is empty!"); return; } EditorHeightmap* editorHeightmap = drawSystem->GetHeightmapProxy(); int32 scaleSize = toolImage->GetWidth(); Vector2 pos = cursorPosition - Vector2((float32)scaleSize, (float32)scaleSize) / 2.0f; { switch (activeDrawingType) { case HEIGHTMAP_DRAW_RELATIVE: { float32 koef = (strength * timeElapsed); if(inverseDrawingEnabled) { koef = -koef; } if (IsKeyModificatorPressed(DVKEY_ALT)) { koef = -koef; } editorHeightmap->DrawRelativeRGBA(toolImage, (int32)pos.x, (int32)pos.y, scaleSize, scaleSize, koef); break; } case HEIGHTMAP_DRAW_AVERAGE: { float32 koef = (averageStrength * timeElapsed) * 2.0f; editorHeightmap->DrawAverageRGBA(toolImage, (int32)pos.x, (int32)pos.y, scaleSize, scaleSize, koef); break; } case HEIGHTMAP_DRAW_ABSOLUTE: case HEIGHTMAP_DRAW_ABSOLUTE_DROPPER: { float32 maxHeight = drawSystem->GetLandscapeMaxHeight(); float32 height = curHeight / maxHeight * Heightmap::MAX_VALUE; float32 koef = (averageStrength * timeElapsed) * 2.0f; editorHeightmap->DrawAbsoluteRGBA(toolImage, (int32)pos.x, (int32)pos.y, scaleSize, scaleSize, koef, height); break; } case HEIGHTMAP_DROPPER: { float32 curHeight = drawSystem->GetHeightAtPoint(cursorPosition); SceneSignals::Instance()->EmitDropperHeightChanged(dynamic_cast<SceneEditor2*>(GetScene()), curHeight); return; } case HEIGHTMAP_COPY_PASTE: { if (copyPasteFrom == Vector2(-1.f, -1.f) || copyPasteTo == Vector2(-1.f, -1.f)) { return; } Vector2 posTo = pos; Vector2 deltaPos = cursorPosition - copyPasteTo; Vector2 posFrom = copyPasteFrom + deltaPos - Vector2((float32)scaleSize, (float32)scaleSize)/2.f; float32 koef = (averageStrength * timeElapsed) * 2.0f; editorHeightmap->DrawCopypasteRGBA(toolImage, posFrom, posTo, scaleSize, scaleSize, koef); break; } default: DAVA::Logger::Error("Invalid drawing type!"); return; } Rect rect(pos.x, pos.y, (float32)scaleSize, (float32)scaleSize); drawSystem->GetHeightmapProxy()->UpdateRect(rect); AddRectToAccumulator(heightmapUpdatedRect, rect); }}
开发者ID:droidenko,项目名称:dava.framework,代码行数:86,
示例28: UpdateCursorPositionvoid HeightmapEditorSystem::ProcessUIEvent(DAVA::UIEvent *event){ if (!IsLandscapeEditingEnabled()) { return; } UpdateCursorPosition(); if (event->tid == UIEvent::BUTTON_1) { Vector3 point; switch(event->phase) { case UIEvent::PHASE_BEGAN: if (drawingType == HEIGHTMAP_DRAW_ABSOLUTE_DROPPER || drawingType == HEIGHTMAP_DROPPER) { curHeight = drawSystem->GetHeightAtPoint(cursorPosition); SceneSignals::Instance()->EmitDropperHeightChanged(dynamic_cast<SceneEditor2*>(GetScene()), curHeight); } if (isIntersectsLandscape) { if (drawingType == HEIGHTMAP_COPY_PASTE) { int32 curKeyModifiers = QApplication::keyboardModifiers(); if (curKeyModifiers & Qt::AltModifier) { copyPasteFrom = cursorPosition; copyPasteTo = Vector2(-1.f, -1.f); return; } else { if (copyPasteFrom == Vector2(-1.f, -1.f)) { return; } copyPasteTo = cursorPosition; StoreOriginalHeightmap(); } } else { if (drawingType != HEIGHTMAP_DROPPER) { StoreOriginalHeightmap(); } } UpdateToolImage(); editingIsEnabled = true; } activeDrawingType = drawingType; break; case UIEvent::PHASE_DRAG: break; case UIEvent::PHASE_ENDED: FinishEditing(); break; } }}
开发者ID:droidenko,项目名称:dava.framework,代码行数:69,
注:本文中的GetScene函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GetScreen函数代码示例 C++ GetScale函数代码示例 |