Page 1 of 1
DotSceneLoader enviroment colour
Posted: Sun Sep 28, 2025 6:40 pm
by jordiperezarti
I am modifing DotSceneLoader.cpp to load enviroment color, i am doing:
Code: Select all
[code]if (auto pElement = XMLNode.child("colourBackground"))
{
mBackgroundColour = parseColour(pElement);
mSceneMgr->setOption("background-color", new ColourValue(mBackgroundColour));
}[/code]
then in the application, when i capture the option background-color:
Code: Select all
scnMgr->hasOption("background-color");
is returning false.
in my .scene i have:
Code: Select all
<scene formatVersion="1.1">
<environment>
<colourAmbient r="1.0" g="0.1" b="0.1" />
<colourBackground r="0.2" g="0.2" b="0.8" />
</environment>
why the hasOptions seems to dont remember the background-color?
i would like to call
Code: Select all
DotSceneLoader.getBackgroundColour()
when i do
Code: Select all
scnMgr->getRootSceneNode()->loadChildren("myscene.scene");
but how do i get the DotSceneLoader Object when i call loadChildren?
Re: DotSceneLoader enviroment colour
Posted: Sun Sep 28, 2025 7:14 pm
by rpgplayerrobin
I guess you are using C++?
In that case, this code makes no sense at all:
Code: Select all
mSceneMgr->setOption("background-color", new ColourValue(mBackgroundColour));
Why are you using "new ColourValue"?
It should be like this (which might help with your issue, but also help to remove that memory leak that you created):
Code: Select all
mSceneMgr->setOption("background-color", &mBackgroundColour);
Also, in Ogre for me, the default scene manager does nothing with setOption/hasOption, so I guess your own scene manager takes care of these functions?:
Code: Select all
virtual bool setOption( const String& strKey, const void* pValue )
{ (void)strKey; (void)pValue; return false; }
virtual bool hasOption( const String& strKey ) const
{ (void)strKey; return false; }
But it is hard to know for sure what the cause of your issue is other than that. You will have to just debug the functions setOption and hasOption to see what actually happens. For me, in Visual Studio, I can just press F11 to go into those functions when debugging, so I can see exactly what the Ogre code does, which helps with all of these kind of issues. Without it, it would be impossible for me to fix issues.
Re: DotSceneLoader enviroment colour
Posted: Mon Sep 29, 2025 2:21 pm
by jordiperezarti
i suspect the setOption() is virtual and i would need to implement an heritage for the SceneManager, but i will not do.
I really preffer to call:
scnMgr->getRootSceneNode()->loadChildren("myscene.scene");
then something like Ogre::DotSceneLoader.getBackgroundColor()
because the getBackgroundColor is implemented already.
the question is how do i make this call? Ogre::DotSceneLoader.getBackgroundColor()
Re: DotSceneLoader enviroment colour
Posted: Mon Sep 29, 2025 11:37 pm
by rpgplayerrobin
From ChatGPT:
Code: Select all
// Create the loader
Ogre::DotSceneLoader loader;
// Load the scene
Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton()
.openResource("myscene.scene", "General");
loader.load(stream, "General", sceneMgr->getRootSceneNode());
// Now you can access background color or other info
Ogre::ColourValue bgColor = loader.getBackgroundColour();
sceneMgr->setAmbientLight(bgColor);
But if I were you, I would just go into the Ogre source and copy that class completely, then I would alter it to do what you want it to do exactly, not requiring you to even do anything special after it has loaded a scene.
That way you can also add specific stuff yourself to it which can do things that it normally cannot.
Re: DotSceneLoader enviroment colour
Posted: Tue Sep 30, 2025 3:34 pm
by jordiperezarti
This is, exactly.
Now i can do after the scene is loaded:
Code: Select all
viewport = getRenderWindow()->addViewport(cam);
viewport->setBackgroundColour(loaderScene.getBackgroundColour());