本文整理汇总了C++中SceneContainer类的典型用法代码示例。如果您正苦于以下问题:C++ SceneContainer类的具体用法?C++ SceneContainer怎么用?C++ SceneContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SceneContainer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: PerformPicking
/**
* @brief
* Performs picking by using the given line start and end positions
*/
bool Picking::PerformPicking(PickingResult &cPickingResult, SceneContainer &cContainer, const Vector3 &vLineStartPos, const Vector3 &vLineEndPos, Cull::Enum nCull)
{
// Initialize the picking result
m_pPickingResult = &cPickingResult;
cPickingResult.m_pSceneNode = nullptr;
cPickingResult.m_nGeometry = 0;
cPickingResult.m_nTriangle = 0;
cPickingResult.m_vPoint = Vector3::Zero;
cPickingResult.m_pSceneContainer = &cContainer;
cPickingResult.m_vLineStartPos = vLineStartPos;
cPickingResult.m_fNearestSquaredDistance = -1.0f;
// Trace line
SQLine *pQuery = static_cast<SQLine*>(cContainer.CreateQuery("PLScene::SQLine"));
if (pQuery) {
pQuery->SignalSceneNode.Connect(EventHandlerSceneNode);
pQuery->GetLine().Set(vLineStartPos, vLineEndPos);
pQuery->SetCull(nCull);
pQuery->PerformQuery();
cContainer.DestroyQuery(*pQuery);
}
// Was something picked?
if (cPickingResult.m_pSceneNode) {
// Ensure that the picking distance is not greater than the possible maximum
if ((vLineEndPos-vLineStartPos).GetSquaredLength() >= cPickingResult.m_fNearestSquaredDistance)
return (cPickingResult.m_pSceneNode != nullptr);
}
// Nothing (in range) was picked
return false;
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:36,代码来源:Picking.cpp
示例2: GetSceneNode
/**
* @brief
* Loads/reloads the sound
*/
void SNMSound::Load()
{
// Destroy currently used sound source
Source *pSS = static_cast<Source*>(m_pSoundSourceHandler->GetResource());
if (pSS)
delete pSS;
// Get the PL sound container this scene node is in
SceneContainer *pContainer = GetSceneNode().GetContainer();
while (pContainer && !pContainer->IsInstanceOf("PLSound::SCSound"))
pContainer = pContainer->GetContainer();
if (pContainer) {
SoundManager *pSoundManager = static_cast<SCSound*>(pContainer)->GetSoundManager();
if (pSoundManager) {
Source *pSoundSource = pSoundManager->CreateSoundSource(pSoundManager->CreateSoundBuffer(m_sSound, (GetFlags() & Stream) != 0));
m_pSoundSourceHandler->SetResource(pSoundSource);
pSoundSource->SetAttribute(Source::Position, GetSceneNode().GetTransform().GetPosition());
pSoundSource->SetVolume(m_fVolume);
pSoundSource->Set2D((GetFlags() & No3D) != 0);
pSoundSource->SetLooping(!(GetFlags() & NoLoop));
pSoundSource->SetPitch(m_fPitch);
pSoundSource->SetReferenceDistance(m_fReferenceDistance);
pSoundSource->SetMaxDistance(m_fMaxDistance);
pSoundSource->SetRolloffFactor(m_fRolloffFactor);
OnPosition();
if (!(GetFlags() & NoStartPlayback))
pSoundSource->Play();
}
}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:34,代码来源:SNMSound.cpp
示例3: GetScene
/**
* @brief
* Restarts the game
*/
void Application67::Restart()
{
// Get the scene container
SceneContainer *pSceneContainer = GetScene();
if (pSceneContainer) {
// Clean up your scene container
pSceneContainer->Clear();
// Create the camera (we need the camera to control the post processing)
SceneNode *pCamera = pSceneContainer->Create("PLScene::SNCamera", "FixedCamera");
if (pCamera && pCamera->IsInstanceOf("PLScene::SNCamera")) {
// Add a post process scene node modifier from the 'PLPostProcessEffects'-plugin
pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessOldFilm", "Flags='Inactive'");
// Make this to our main scene camera
SetCamera(reinterpret_cast<SNCamera*>(pCamera));
}
// Create an UFO from mars attacking the earth :D
pSceneContainer->Create("SNUFO", "Ufo");
// Create the gun (the player)
pSceneContainer->Create("SNGun", "Gun", "Position=\"157 155\"");
}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:29,代码来源:Application67.cpp
示例4:
//[-------------------------------------------------------]
//[ Private virtual PLEngine::EngineApplication functions ]
//[-------------------------------------------------------]
void Application60::OnCreateScene(SceneContainer &cContainer)
{
// Create a camera scene node
SceneNode *pCameraSceneNode = cContainer.Create("PLScene::SNCamera", "FreeCamera", "Position=\"1 2 -3\" Rotation=\"25 210 0\"");
if (pCameraSceneNode && pCameraSceneNode->IsInstanceOf("PLScene::SNCamera")) {
// Make this to our main scene camera
SetCamera(reinterpret_cast<SNCamera*>(pCameraSceneNode));
}
// Create a scene node with the soldier mesh which can produce a shadow
SceneNode *pSoldierSceneNode = cContainer.Create("PLScene::SNMesh", "Soldier", "Flags=\"CastShadow|ReceiveShadow\" Position=\"0.0 0.1 -5.0\" Scale=\"0.008 0.008 0.008\" Mesh=\"Data/Meshes/Soldier.mesh\"");
if (pSoldierSceneNode) {
// Add a scene node modifier which will constantly rotate the soldier
pSoldierSceneNode->AddModifier("PLScene::SNMRotationLinearAnimation", "Velocity=\"0 10 0\"");
// Add a scene node modifier which will playback the animation named "walk_0" letting the soldier walk
pSoldierSceneNode->AddModifier("PLScene::SNMMeshAnimation", "Name=\"walk_0\"");
// Add a scene node modifier which will animate the morph target named "blink" letting the soldier blink from time to time
pSoldierSceneNode->AddModifier("PLScene::SNMMeshMorphBlink", "Name=\"blink\"");
}
// Create a light source scene node to illuminate the scene - this light can cast shadows
cContainer.Create("PLScene::SNPointLight", "Light", "Flags=\"CastShadow|Flares|Corona\" Range=\"4\"");
// Create the floor scene node
cContainer.Create("PLScene::SNMesh", "Floor", "Flags=\"CastShadow|ReceiveShadow\" Position=\"0.0 0.0 -5.0\" Rotation=\"0.0 180.0 0.0\" Scale=\"4.0 0.1 4.0\" Mesh=\"Default\"");
// Set scene container
SetScene(&cContainer);
}
开发者ID:Tank-D,项目名称:potential-octo-dubstep,代码行数:34,代码来源:Application60.cpp
示例5: OnCreateScene
//[-------------------------------------------------------]
//[ Protected virtual PLFrontendQt::QPLSceneContext functions ]
//[-------------------------------------------------------]
void MySceneContext::OnCreateScene(SceneContainer &cContainer)
{
// Create a camera
SceneNode *pCamera = cContainer.Create("PLScene::SNCamera", "FreeCamera", "Position=\"1 2 -3\" Rotation=\"25 0 0\"");
if (pCamera && pCamera->IsInstanceOf("PLScene::SNCamera"))
SetCamera(reinterpret_cast<SNCamera*>(pCamera));
// Create the floor
cContainer.Create("PLScene::SNMesh", "Floor", "Position=\"0.0 0.0 5.0\" Rotation=\"0.0 180.0 0.0\" Scale=\"4.0 0.1 4.0\" Mesh=\"Default\"");
// Set scene container
SetScene(&cContainer);
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:16,代码来源:MySceneContext.cpp
示例6: GetPainter
//[-------------------------------------------------------]
//[ Private virtual PLEngine::EngineApplication functions ]
//[-------------------------------------------------------]
void Application67::OnCreateScene(SceneContainer &cContainer)
{
// Create a scene container with our 'concrete sound scene' using the default sound API
SceneNode *pSceneContainerNode = cContainer.Create("PLSound::SCSound", "SoundScene");
if (pSceneContainerNode && pSceneContainerNode->IsInstanceOf("PLScene::SceneContainer")) {
SceneContainer *pSceneContainer = static_cast<SceneContainer*>(pSceneContainerNode);
// Protect this important container!
pSceneContainer->SetProtected(true);
// Populate the scene container
// Setup scene surface painter
SurfacePainter *pPainter = GetPainter();
if (pPainter && pPainter->IsInstanceOf("PLScene::SPScene")) {
SPScene *pSPScene = static_cast<SPScene*>(pPainter);
pSPScene->SetRootContainer(cContainer.GetContainer());
pSPScene->SetSceneContainer(pSceneContainer);
// Get the scene context
SceneContext *pSceneContext = GetSceneContext();
if (pSceneContext) {
// Create us a scene renderer
SceneRenderer *pSceneRenderer = pSceneContext->GetSceneRendererManager().Create("2DGame");
if (pSceneRenderer) {
// Add begin scene renderer pass
pSceneRenderer->Create("PLCompositing::SRPBegin", "Begin", "TextureFormat=\"R8G8B8A8\" Flags=\"Inactive\"");
// Add our own scene renderer pass
pSceneRenderer->Create("SRP2DGame", "2DGame");
// Add post processing scene renderer pass
pSceneRenderer->Create("PLCompositing::SRPPostProcessing", "PostProcessing");
// Add end scene renderer pass
pSceneRenderer->Create("PLCompositing::SRPEnd", "End");
// Make this scene renderer to the default scene renderer of our scene surface painter
pSPScene->SetDefaultSceneRenderer(pSceneRenderer->GetName());
}
}
}
// Set scene container
SetScene(pSceneContainer);
// Start the game
Restart();
}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:52,代码来源:Application67.cpp
示例7: GetScene
/**
* @brief
* Updates the text of the time scale text node
*/
void Application61::UpdateTimeScaleTextNode()
{
// Get the scene
SceneContainer *pSceneContainer = GetScene();
if (pSceneContainer) {
// Get the scene info text container
SceneContainer *pInfoTextContainer = static_cast<SceneContainer*>(pSceneContainer->GetByName("Parent.InfoText"));
if (pInfoTextContainer) {
// Get the time scale text scene node
SceneNode *pInfoTextNode = pInfoTextContainer->GetByName("TimeScale");
if (pInfoTextNode)
pInfoTextNode->SetAttribute("Text", PLT("1/2/0=Decrease/increase/reset timescale (current: ") + Timing::GetInstance()->GetTimeScaleFactor() + ')');
}
}
}
开发者ID:Tank-D,项目名称:potential-octo-dubstep,代码行数:19,代码来源:Application61.cpp
示例8: GetSceneNode
/**
* @brief
* Returns the target position within the container space of the owner node
*/
bool SNMRotationTarget::GetTargetPosition(Vector3 &vPos) const
{
// Target scene node given?
if (Target.Get().GetLength()) {
// Get the target scene node
const SceneNode *pTarget;
if (GetSceneNode().GetContainer())
pTarget = GetSceneNode().GetContainer()->GetByName(Target.Get());
else {
// This must be the root :()
pTarget = static_cast<const SceneContainer&>(GetSceneNode()).GetByName(Target.Get());
}
if (pTarget) {
// Set the position of the attached node
vPos = pTarget->GetTransform().GetPosition();
// Are we in luck and the target is within the same container as the owner node?
if (GetSceneNode().GetContainer() != pTarget->GetContainer()) {
// Nope, we have to translate the position into the correct space :(
SceneContainer *pContainer = pTarget->GetContainer();
while (pContainer) {
vPos *= pContainer->GetTransform().GetMatrix();
pContainer = pContainer->GetContainer();
}
// To container space of the owner node
pContainer = GetSceneNode().GetContainer();
Stack<SceneContainer*> lstStack;
while (pContainer) {
lstStack.Push(pContainer);
pContainer = pContainer->GetContainer();
}
while (lstStack.GetNumOfElements()) {
pContainer = lstStack.Top();
lstStack.Pop();
vPos *= pContainer->GetTransform().GetInverseMatrix();
}
}
// Done
return true;
}
}
// Error - no valid target scene node, no target rotation :(
return false;
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:51,代码来源:SNMRotationTarget.cpp
示例9: GetScene
/**
* @brief
* Clears the scene, after calling this method the scene is empty
*/
void EngineApplication::ClearScene()
{
// Get the scene container holding our scene
SceneContainer *pContainer = GetScene();
if (pContainer) {
// Clear the old scene
pContainer->Clear();
// Cleanup the scene context right now to ensure that all 'delete this'-marked scene nodes are really gone!
// If this is not done, we may get problems with for example the names of dynamic textures because there may
// occur name conflicts if multiple render-to-texture scene containers want to render into a same named texture...
// Topics like 'the new scene is using resources that are already loaded in' must be handled on another level, e.g.
// by delaying the unloading of currently unreferenced resources.
if (m_pSceneContext)
m_pSceneContext->Cleanup();
}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:21,代码来源:EngineApplication.cpp
示例10: GetContainer
/**
* @brief
* Returns the gravity vector
*/
Vector3 PGPhysics::GetGravity() const
{
// Get the PL physics world this scene node is in
SceneContainer *pContainer = GetContainer();
while (pContainer && !pContainer->IsInstanceOf("PLPhysics::SCPhysicsWorld"))
pContainer = pContainer->GetContainer();
// Get the gravity vector
Vector3 vGravity;
if (pContainer && static_cast<SCPhysicsWorld*>(pContainer)->GetWorld())
static_cast<SCPhysicsWorld*>(pContainer)->GetWorld()->GetGravity(vGravity);
else
vGravity.SetXYZ(0.0f, -9.81f, 0.0f);
// Return the gravity vector
return vGravity;
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:21,代码来源:PGPhysics.cpp
示例11: GetPainter
//[-------------------------------------------------------]
//[ Private virtual PLEngine::EngineApplication functions ]
//[-------------------------------------------------------]
void Application66::OnCreateScene(SceneContainer &cContainer)
{
// Set scene container flags
cContainer.SetFlags(SceneNode::NoCulling);
// Setup scene surface painter
SurfacePainter *pPainter = GetPainter();
if (pPainter && pPainter->IsInstanceOf("PLScene::SPScene")) {
SPScene *pSPScene = static_cast<SPScene*>(pPainter);
pSPScene->SetRootContainer(cContainer.GetContainer());
pSPScene->SetSceneContainer(&cContainer);
}
// Within the parent container...
SceneContainer *pContainer = cContainer.GetContainer();
if (pContainer) {
// Create a 'ingame'-GUI scene node
const SNGui *pGuiSceneNode = static_cast<SNGui*>(pContainer->Create("PLFrontendPLGui::SNGui", "GUI"));
if (pGuiSceneNode) {
// Setup the GUI
Gui *pGui = pGuiSceneNode->GetGui();
if (pGui) {
// Create the GUI font
if (!GuiFont) {
GuiFont = new Font(*pGui);
GuiFont->LoadFromFile("Data/Fonts/LinLibertine_Re-2.7.9.9.otf", 18);
}
// Set GUI options
pGui->SetMouseVisible(false);
// Create ingame GUI container
m_pIngameGui = new IngameGui(*this, pGui->GetRootWidget());
m_pIngameGui->SetSize(Vector2i(1024, 768));
m_pIngameGui->SetBackgroundColor(PLGraphics::Color4::Transparent);
m_pIngameGui->SetFocus();
m_pIngameGui->SetVisible(true);
}
}
}
// Set scene container
SetScene(&cContainer);
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:47,代码来源:Application66.cpp
示例12: Exit
/**
* @brief
* Called when a control event has occurred
*/
void Application61::OnControl(Control &cControl)
{
// Is it a button?
if (cControl.GetType() == ControlButton && static_cast<Button&>(cControl).IsPressed()) {
// Check whether the escape key was pressed
if (cControl.GetName() == "KeyboardEscape") {
// Shut down the application
Exit(0);
} else {
// Get current time difference
Timing *pTimer = Timing::GetInstance();
const float fTimeScaleFactor = pTimer->GetTimeScaleFactor();
// Check button
if (cControl.GetName() == "Keyboard1") {
// Decrease timescale
pTimer->SetTimeScaleFactor(fTimeScaleFactor - 0.1f);
if (pTimer->GetTimeScaleFactor() < 0.1f)
pTimer->SetTimeScaleFactor(0.1f);
} else if (cControl.GetName() == "Keyboard2") {
// Increase timescale
pTimer->SetTimeScaleFactor(fTimeScaleFactor + 0.1f);
if (pTimer->GetTimeScaleFactor() > 4.0f)
pTimer->SetTimeScaleFactor(4.0f);
} else if (cControl.GetName() == "Keyboard3") {
// Reset timescale
pTimer->SetTimeScaleFactor();
}
// Time scale factor changed?
if (fTimeScaleFactor != pTimer->GetTimeScaleFactor()) {
// Update the time scale text node
UpdateTimeScaleTextNode();
// Update the pitch variable of the sound container using the time scale factor
SceneContainer *pSceneContainer = GetScene();
if (pSceneContainer)
pSceneContainer->SetAttribute("Pitch", pTimer->GetTimeScaleFactor());
}
}
}
}
开发者ID:Tank-D,项目名称:potential-octo-dubstep,代码行数:46,代码来源:Application61.cpp
示例13: GetSceneContainer
/**
* @brief
* Post draw all scene nodes recursive
*/
void SPScene::DrawPost(Renderer &cRenderer, SceneContainer &cContainer)
{
// Get the scene container (can be a null pointer)
SceneContainer *pContainer = GetSceneContainer();
// Draw parent container
if (&cContainer != pContainer)
cContainer.DrawPost(cRenderer);
// Loop through all nodes
for (uint32 i=0; i<cContainer.GetNumOfElements(); i++) {
SceneNode *pNode = cContainer.GetByIndex(i);
if (pNode != pContainer && pNode->IsVisible() && (pNode->GetDrawFunctionFlags() & SceneNode::UseDrawPost)) {
if (pNode->IsContainer())
DrawPost(cRenderer, static_cast<SceneContainer&>(*pNode));
else
pNode->DrawPost(cRenderer);
}
}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:24,代码来源:SPScene.cpp
示例14: GetRootContainer
/**
* @brief
* Returns the default scene renderer
*/
SceneRenderer *SPScene::GetDefaultSceneRenderer() const
{
// Get/load the scene renderer
SceneRenderer *pSceneRenderer = m_pDefaultSceneRendererHandler->GetResource();
if (!pSceneRenderer && m_sDefaultSceneRenderer.GetLength()) {
// Get the root scene container
SceneContainer *pRootContainer = GetRootContainer();
if (pRootContainer) {
// Get the scene context
SceneContext *pSceneContext = pRootContainer->GetSceneContext();
if (pSceneContext) {
pSceneRenderer = pSceneContext->GetSceneRendererManager().LoadResource(m_sDefaultSceneRenderer);
m_pDefaultSceneRendererHandler->SetResource(pSceneRenderer);
}
}
}
// Return the scene renderer
return pSceneRenderer;
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:24,代码来源:SPScene.cpp
示例15: GetPainter
/**
* @brief
* Function that is called to create the application's scene container
*/
void EngineApplication::OnCreateScene(SceneContainer &cContainer)
{
// [TODO] Load 'm_sSceneFilename' if provided
// Set scene container flags
cContainer.SetFlags(SceneNode::NoCulling);
// Setup scene surface painter
SurfacePainter *pPainter = GetPainter();
if (pPainter && pPainter->IsInstanceOf("PLScene::SPScene")) {
SPScene *pSPScene = static_cast<SPScene*>(pPainter);
pSPScene->SetRootContainer(cContainer.GetContainer());
pSPScene->SetSceneContainer(&cContainer);
}
// Configure scene and set the currently used application camera
SetCamera(SceneCreator::ConfigureScene(cContainer, "PLEngine::SceneCreatorDefault"));
// Set scene container
SetScene(&cContainer);
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:25,代码来源:EngineApplication.cpp
示例16: SetCamera
//[-------------------------------------------------------]
//[ Private virtual PLEngine::EngineApplication functions ]
//[-------------------------------------------------------]
void Application64::OnCreateScene(SceneContainer &cContainer)
{
// Create a camera
SceneNode *pCamera = cContainer.Create("PLScene::SNCamera", "FreeCamera", "Position=\"1 2 -3\" Rotation=\"25 210 0\"");
if (pCamera && pCamera->IsInstanceOf("PLScene::SNCamera")) {
// Make this to our main scene camera
SetCamera(reinterpret_cast<SNCamera*>(pCamera));
}
// Create a scene node with the soldier mesh - in debug mode, show some fancy technical visualizations
SceneNode *pSceneNode = cContainer.Create("PLScene::SNMesh", "Soldier", "Position=\"0.0 0.1 -5.0\" Scale=\"0.008 0.008 0.008\" Mesh=\"Data/Meshes/Soldier.mesh\" DebugFlags=\"DebugShowWireframe|DebugShowJoints|DebugShowJointNames|DebugShowSkeleton\"");
if (pSceneNode) {
// Rotate the soldier
pSceneNode->AddModifier("PLScene::SNMRotationLinearAnimation", "Velocity=\"0 10 0\"");
// Playback the animation named "walk_0" letting the soldier walk
pSceneNode->AddModifier("PLScene::SNMMeshAnimation", "Name=\"walk_0\"");
// Animate the morph target named "blink" letting the soldier blink from time to time
pSceneNode->AddModifier("PLScene::SNMMeshMorphBlink", "Name=\"blink\"");
}
// Create the floor
cContainer.Create("PLScene::SNMesh", "Floor", "Position=\"0.0 0.0 -5.0\" Rotation=\"0.0 180.0 0.0\" Scale=\"4.0 0.1 4.0\" Mesh=\"Default\"");
// Setup scene surface painter
SurfacePainter *pPainter = GetPainter();
if (pPainter && pPainter->IsInstanceOf("PLScene::SPScene")) {
SPScene *pSPScene = static_cast<SPScene*>(pPainter);
pSPScene->SetRootContainer(cContainer.GetContainer());
pSPScene->SetSceneContainer(&cContainer);
}
// Set scene container
SetScene(&cContainer);
// Create the picking component
m_pMyPicking = new MyPicking(*this);
}
开发者ID:Tank-D,项目名称:potential-octo-dubstep,代码行数:42,代码来源:Application64.cpp
示例17: GetSceneContext
//[-------------------------------------------------------]
//[ Protected virtual PLScene::SceneApplication functions ]
//[-------------------------------------------------------]
void EngineApplication::OnCreateRootScene()
{
// Get the scene context
SceneContext *pSceneContext = GetSceneContext();
if (pSceneContext) {
// First, create the scene root container which holds the scene container with our 'concrete' scene within it
SceneContainer *pRootContainer = pSceneContext->GetRoot() ? static_cast<SceneContainer*>(pSceneContext->GetRoot()->Create("PLScene::SceneContainer", "RootScene")) : nullptr;
if (pRootContainer) {
// Protect this important container!
pRootContainer->SetProtected(true);
// Create a scene container with our 'concrete scene'
SceneNode *pSceneContainerNode = pRootContainer->Create("PLScene::SceneContainer", "Scene");
if (pSceneContainerNode && pSceneContainerNode->IsInstanceOf("PLScene::SceneContainer")) {
SceneContainer *pSceneContainer = static_cast<SceneContainer*>(pSceneContainerNode);
// Protect this important container!
pSceneContainer->SetProtected(true);
// Connect event handler
if (pSceneContainerNode->IsInstanceOf("PLScene::SceneContainer"))
static_cast<SceneContainer*>(pSceneContainerNode)->SignalLoadProgress.Connect(EventHandlerLoadProgress);
// Create the 'concrete scene'
OnCreateScene(*pSceneContainer);
}
// Create scene node for engine information
SceneNode *pSceneNode = pRootContainer->Create("PLEngine::SNEngineInformation");
if (pSceneNode)
pSceneNode->SetActive(m_bEditModeEnabled);
// Create console scene node - using the console command 'timescale <value>' we
// can change the scene time (slowdown or accelerate)
pSceneNode = pRootContainer->Create("PLEngine::SNConsole");
if (pSceneNode && pSceneNode->GetClass()->IsDerivedFrom("PLEngine::SNConsoleBase")) {
SNConsoleBase *pConsole = static_cast<SNConsoleBase*>(pSceneNode);
// Register default commands
pConsole->RegisterCommand(0, "quit", "", "", Functor<void, ConsoleCommand &>(&EngineApplication::ConsoleCommandQuit, this));
pConsole->RegisterCommand(0, "exit", "", "", Functor<void, ConsoleCommand &>(&EngineApplication::ConsoleCommandQuit, this));
pConsole->RegisterCommand(0, "bye", "", "", Functor<void, ConsoleCommand &>(&EngineApplication::ConsoleCommandQuit, this));
pConsole->RegisterCommand(0, "logout", "", "", Functor<void, ConsoleCommand &>(&EngineApplication::ConsoleCommandQuit, this));
// Set active state
pConsole->SetActive(m_bEditModeEnabled);
}
}
// Set the root scene
SetRootScene(pRootContainer);
}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:56,代码来源:EngineApplication.cpp
示例18: GetRootScene
/**
* @brief
* Sets whether or not edit mode is enabled
*/
void EngineApplication::SetEditModeEnabled(bool bEnabled)
{
// State change?
if (m_bEditModeEnabled != bEnabled) {
// Backup the new state
m_bEditModeEnabled = bEnabled;
// Get the root scene
SceneContainer *pRootScene = GetRootScene();
if (pRootScene) {
// Enable/disable standard edit features from the PixelLight scene graph (if the user hasn't changed anything :)
SceneNode *pSceneNode = pRootScene->GetByName("PLEngine::SNEngineInformation0");
if (pSceneNode)
pSceneNode->SetActive(bEnabled);
pSceneNode = pRootScene->GetByName("PLEngine::SNConsole0");
if (pSceneNode)
pSceneNode->SetActive(bEnabled);
}
// Setup log level
Log::GetInstance()->SetLogLevel(static_cast<uint8>(m_bEditModeEnabled ? Log::Debug : Log::Info));
}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:27,代码来源:EngineApplication.cpp
示例19: GetScene
//[-------------------------------------------------------]
//[ Private virtual PLCore::AbstractFrontend functions ]
//[-------------------------------------------------------]
void Application60::OnUpdate()
{
// One important word at the beginning: DON'T COPYCAT THIS!
// The following is 'just' a simple demonstration how the scene graph 'can' be used. It's
// definitely not good to update your scene nodes in the way you can see within this function.
// Its quite to intricate, inflexible and not performant. Use for example a scene node modifier
// added to your scene node (in this case 'the white light') for this job!
// Call base implementation
EngineApplication::OnUpdate();
// Get the scene container with our 'concrete scene'
SceneContainer *pSceneContainer = GetScene();
if (pSceneContainer) {
// Get the scene node with the name 'Light' (our 'white light')
SceneNode *pLightSceneNode = pSceneContainer->GetByName("Light");
if (pLightSceneNode) {
// This variable is used for the light animation. Its just static you keep the implementation
// for a good sample overview completely within this function.
static float fLightTimer = 0.0f;
// Get a new fancy light position
const Vector3 vPosition(Math::Sin(fLightTimer), Math::Sin(fLightTimer)/2+2, -(Math::Cos(fLightTimer)+5));
// We set the current light position using the RTTI class interface. This is quite comfortable and
// universal because you haven't to care about the concrete class type - just set the variable values.
pLightSceneNode->SetAttribute("Position", Var<Vector3>(vPosition)); // More efficient
// Another way by using strings:
// pLightSceneNode->SetAttribute("Position", vPosition.ToString()); // More generic
// For highly performance critical situations it's recommend to avoid using these RTTI
// functions to set your variables and use the concrete provided class interfaces instead.
// Update the light timer by using the time difference between the last and the current frame
fLightTimer += Timing::GetInstance()->GetTimeDifference();
}
}
}
开发者ID:Tank-D,项目名称:potential-octo-dubstep,代码行数:40,代码来源:Application60.cpp
示例20: OnCreateRootScene
/**
* @brief
* Function that is called to create the application's root scene
*/
void SceneApplication::OnCreateRootScene()
{
// [TODO] Load 'm_sSceneFilename' if provided
// Is there a scene context?
if (m_pSceneContext) {
// First, create the scene root container which holds the scene container with our 'concrete' scene within it
SceneContainer *pRootContainer = m_pSceneContext->GetRoot() ? static_cast<SceneContainer*>(m_pSceneContext->GetRoot()->Create("PLScene::SceneContainer", "RootScene")) : nullptr;
if (pRootContainer) {
// Protect this important container!
pRootContainer->SetProtected(true);
// Create a scene container with our 'concrete scene'
SceneNode *pSceneContainerNode = pRootContainer->Create("PLScene::SceneContainer", "Scene");
if (pSceneContainerNode && pSceneContainerNode->IsContainer()) {
// Protect this important container!
pSceneContainerNode->SetProtected(true);
}
}
// Set the root scene
SetRootScene(pRootContainer);
}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:28,代码来源:SceneApplication.cpp
注:本文中的SceneContainer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论