new DotScene loader

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
SXtheOne
Gnoblar
Posts: 4
Joined: Mon Aug 31, 2009 9:32 pm

Re: new DotScene loader

Post by SXtheOne »

Hi!

I just tried RapidXML with jacmoe-s dotSceneLoader and it works great. But..
The RapidXML is quiet compicated for my taste and to be honest I don't have time to understand it well (a job, lot of travelling, etc..). The memory leak detector (Visual C++ detector) says that RapidXML leaves it's things (the whole XML) in the memory after I exit from my program. Can anyone tell me for sure if RapidXML is perfectly safe to use (so no leaking and other hidden traps)? Because I see that it's freeing the memory in a unique way (at least it's not simple free() or delete()), so maybe it's causing the memory leak detector to say bullshit..

What the memory leak detector says:

Code: Select all

Detected memory leaks!
Dumping objects ->
{177239} normal block at 0x00DD6978, 2194 bytes long.
 Data: <<scene formatVer> 3C 73 63 65 6E 65 00 66 6F 72 6D 61 74 56 65 72 
Object dump complete.
Thanx for the help in advance!
User avatar
archangel92
Kobold
Posts: 35
Joined: Tue Jan 05, 2010 3:48 pm
Location: Russia

Re: new DotScene loader

Post by archangel92 »

i have an expresssion when i run my project(file rapidxml.hpp line 694):

Code: Select all

 Ch *value() const
        {
           ----> return m_value ? m_value : nullstr();
        }
What is this? I made scene in ogitor 0.4.1, RapidXml 1,13
And jacmoe, Have you got a loader for TinyXml?
Image
Image
SXtheOne
Gnoblar
Posts: 4
Joined: Mon Aug 31, 2009 9:32 pm

Re: new DotScene loader

Post by SXtheOne »

I found a solution how to make disapper this memory leak.
In jacmoe's dotSceneLoader.cpp there is the parseDotScene function. A char* scene local variable is declared and used to store the .scene file. If you delete this variable after processScene(XMLRoot); there is no more memory leak.


SXtheOne wrote:Hi!

I just tried RapidXML with jacmoe-s dotSceneLoader and it works great. But..
The RapidXML is quiet compicated for my taste and to be honest I don't have time to understand it well (a job, lot of travelling, etc..). The memory leak detector (Visual C++ detector) says that RapidXML leaves it's things (the whole XML) in the memory after I exit from my program. Can anyone tell me for sure if RapidXML is perfectly safe to use (so no leaking and other hidden traps)? Because I see that it's freeing the memory in a unique way (at least it's not simple free() or delete()), so maybe it's causing the memory leak detector to say bullshit..

What the memory leak detector says:

Code: Select all

Detected memory leaks!
Dumping objects ->
{177239} normal block at 0x00DD6978, 2194 bytes long.
 Data: <<scene formatVer> 3C 73 63 65 6E 65 00 66 6F 72 6D 61 74 56 65 72 
Object dump complete.
Thanx for the help in advance!
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: new DotScene loader

Post by jacmoe »

SXtheOne wrote:The RapidXML is quiet compicated for my taste and to be honest I don't have time to understand it well
It's as simple as it gets. :)
Very close to TinyXML in usage, and then it's only one single header.
SXtheOne wrote:Can anyone tell me for sure if RapidXML is perfectly safe to use (so no leaking and other hidden traps)? Because I see that it's freeing the memory in a unique way (at least it's not simple free() or delete()), so maybe it's causing the memory leak detector to say bullshit..
RapidXML is used by lots of people since 2006:
RapidXml has been around since 2006, and is being used by lots of people. HTC uses it in some of its mobile phones.
And Boost.PropertyTree uses it as the default back-end.
So, nothing wrong with it. :)

Could you point me towards where you've got my DotsceneLoader so that I can fix it?
It's fixed in my local copy (ie the one in Ogitor sample app) ->

Code: Select all

void DotSceneLoader::parseDotScene(const Ogre::String &SceneName, const Ogre::String &groupName, Ogre::SceneManager *yourSceneMgr, Ogre::SceneNode *pAttachNode, const Ogre::String &sPrependNode)
{
    // set up shared object values
    m_sGroupName = groupName;
    mSceneMgr = yourSceneMgr;
    m_sPrependNode = sPrependNode;
    staticObjects.clear();
    dynamicObjects.clear();

    rapidxml::xml_document<> XMLDoc;    // character type defaults to char

    rapidxml::xml_node<>* XMLRoot;

    Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(SceneName, groupName );
    char* scene = strdup(stream->getAsString().c_str());
    XMLDoc.parse<0>(scene);

    // Grab the scene node
    XMLRoot = XMLDoc.first_node("scene");

    // Validate the File
    if( getAttrib(XMLRoot, "formatVersion", "") == "")
    {
        Ogre::LogManager::getSingleton().logMessage( "[DotSceneLoader] Error: Invalid .scene File. Missing <scene>" );
        delete scene;
        return;
    }

    // figure out where to attach any nodes we create
    mAttachNode = pAttachNode;
    if(!mAttachNode)
        mAttachNode = mSceneMgr->getRootSceneNode();

    // Process the scene
    processScene(XMLRoot);

    delete scene;
}
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
stealth977
Gnoll
Posts: 638
Joined: Mon Dec 15, 2008 6:14 pm
Location: Istanbul, Turkey
x 42

Re: new DotScene loader

Post by stealth977 »

@jacob:

i fixed it in Ogitor AFTER I saw the post here, at the time of the post, it was leaking in Ogitor's sample too :)
Ismail TARIM
Ogitor - Ogre Scene Editor
WWW:http://www.ogitor.org
Repository: https://bitbucket.org/ogitor
SXtheOne
Gnoblar
Posts: 4
Joined: Mon Aug 31, 2009 9:32 pm

Re: new DotScene loader

Post by SXtheOne »

Hi,

@Jacmoe: I got it from here: http://hg.ogitor.org/
I think it is the main repository for Ogitor, but as stealth977 said it is corrected since my last comment :)
BTW I'm getting well with RapidXML and your sceneLoader so thanx for them! :D
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: new DotScene loader

Post by jacmoe »

Great. :)
I was being sloppy..

I plan to rewrite it to make it more generic.
And put it on the Ogre Wiki.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
mvb
Gnoblar
Posts: 1
Joined: Fri Jul 02, 2010 8:57 am

[HELP] DotSceneLoader - problem with scene reloading

Post by mvb »

I need to reload scenes from .scene files. First scene loads well, but when I delete old scene and try to load next, it doesn't render.

Loader and cleaner code:

Code: Select all

void LoadScene(const String &SceneFile, SceneManager* ScMngr)
{
	SceneNode* attach;
	if(ScMngr->hasSceneNode("LoadedScene"))
	{
		attach = ScMngr->getSceneNode("LoadedScene");
		ClearScene(ScMngr, attach);
	}
	else
	{
		attach = ScMngr->getRootSceneNode()->createChildSceneNode("LoadedScene");
	}
	DotSceneLoader *loader = new DotSceneLoader();
	loader->parseDotScene(SceneFile, "General", ScMngr, attach);
}

void ClearScene(SceneManager* ScMngr, Node* rootNode)
{
	while(rootNode->numChildren()>0)
	{
		if(rootNode->getChild(0)->numChildren()>0)
			ClearScene(ScMngr, rootNode->getChild(0));
		Node* node = rootNode->getChild(0);
		rootNode->removeChild((unsigned short int)0);
		ScMngr->destroySceneNode((SceneNode*)node);		
	}
}
It's seem to new scene has been loaded, but it doesn't appear.
Where I'm wrong?

Cheers
hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Re: new DotScene loader

Post by hedphelym »

hi,

I'm writing my own 3dsmax .scene exporter. (which I want to release when it's mature).
in the process I wanted to learn more c++, so I decided to start by making a quick project that loads my exported models.
(I've done this with mogre in the past (since I'm originally a c# coder).

I now try to include the loader in my project and make it work, but now I'm stuck.

I put the files in my include dir, then
I set up the following code:

Code: Select all

//Top of project:
#include "DotSceneLoader.h"
later on in my code:

Code: Select all

Ogre::DotSceneLoader *loader; 
loader->parseDotScene("ogrescene.scene","General", mSceneMgr);
It gives the following error:

Code: Select all

Error	2	error LNK2019: unresolved external symbol "public: void __thiscall Ogre::DotSceneLoader::parseDotScene(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class Ogre::SceneManager *,class Ogre::SceneNode *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?parseDotScene@DotSceneLoader@Ogre@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0PAVSceneManager@2@PAVSceneNode@2@0@Z) referenced in function "protected: virtual void __thiscall OgreSceneLoader::createScene(void)" (?createScene@OgreSceneLoader@@MAEXXZ)	c:\Users\hedphelym\documents\visual studio 2010\Projects\OgreSceneLoader\OgreSceneLoader\OgreSceneLoader.obj	OgreSceneLoader
And I do not know what to do (or what I do wrong).

Any help would be appreciated.
conallmmcg
Kobold
Posts: 29
Joined: Fri Jan 02, 2009 1:50 am

Re: new DotScene loader

Post by conallmmcg »

that looks like a linking error?
are your libs/dependencies setup correctly in your project? (correct names and paths etc)
hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Re: new DotScene loader

Post by hedphelym »

Everything compiles fine when I remove the code for parsing the scene.
this:

Code: Select all

loader->parseDotScene("scene.scene","General", mSceneMgr,NULL,NULL);
Like stated above, all I did was to copy the file to where the other ogre files are located ( \include\OGRE ).
then I have a "#include "DotSceneLoader.h"" on top of my OgreSceneLoader.cpp.
and then I run the function mentioned above.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: new DotScene loader

Post by jacmoe »

You have to add DotSceneLoader.cpp to the project. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Re: new DotScene loader

Post by hedphelym »

Added it now, but now I get this error:

Code: Select all

Error	9	error C2664: 'const char *TiXmlElement::Attribute(const char *) const' : cannot convert parameter 1 from 'const Ogre::String' to 'const char *'	c:\ogresdk_vc10_v1-7-3\include\ogre\dotsceneloader.cpp	781	1	OgreSceneLoader
(I use latest TinyXML)
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4302
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 131
Contact:

Re: new DotScene loader

Post by spacegaier »

Well you have to convert it:

Code: Select all

myOgreString.c_str()
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Re: new DotScene loader

Post by hedphelym »

thanks again, sorry if I'm missing what you try to say, but it appears in the dotsceneloader.cpp file. in the functions there.

example:
sceneloader_error.jpg
hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23
Contact:

Re: new DotScene loader

Post by hedphelym »

Everything works fine now.
It was me not adding the tinyxml.cpp files to my solution (in the cpp folder in solution explorer).
incaIB
Gnoblar
Posts: 15
Joined: Wed Aug 17, 2011 1:41 pm
x 2

Re: new DotScene loader

Post by incaIB »

I can't compile the sample sceneloader are in OgitorFolders that use new DotScene loader i am reading more days over my problem but i can't find any solution and not advance in my exercises. Can help me to solve this errors?. Thank's all.

Code: Select all

1>------ Operación Volver a generar todo iniciada: proyecto: OgreApp3, configuración: Debug Win32 ------
1>  SampleApp.cpp
1>  DotSceneLoader.cpp
1>c:\ogresdk\include\pagedgeometry\pagedgeometry.h(1584): warning C4244: '=' : conversión de 'Ogre::Real' a 'int'; posible pérdida de datos
1>          c:\ogresdk\include\pagedgeometry\pagedgeometry.h(1569) : vea la referencia a la creación de instancias de plantilla de función 'void Forests::GeometryPageManager::initPages<PageType>(const Forests::TBounds &,const Ogre::Any &,Ogre::uint32)' que se está compilando
1>          with
1>          [
1>              PageType=Forests::BatchPage
1>          ]
1>          c:\users\incaib\desktop\sceneloader\src\dotsceneloader.cpp(809) : vea la referencia a la creación de instancias de plantilla de función 'Forests::GeometryPageManager *Forests::PagedGeometry::addDetailLevel<Forests::BatchPage>(Ogre::Real,Ogre::Real,const Ogre::Any &,Ogre::uint32)' que se está compilando
1>c:\ogresdk\include\pagedgeometry\pagedgeometry.h(1601): warning C4244: '=' : conversión de 'float' a 'int'; posible pérdida de datos
1>c:\ogresdk\include\pagedgeometry\pagedgeometry.h(1609): warning C4244: 'inicializando' : conversión de 'Ogre::Real' a 'int'; posible pérdida de datos
1>c:\ogresdk\include\pagedgeometry\pagedgeometry.h(1610): warning C4244: 'inicializando' : conversión de 'Ogre::Real' a 'int'; posible pérdida de datos
1>c:\ogresdk\include\pagedgeometry\pagedgeometry.h(1584): warning C4244: '=' : conversión de 'Ogre::Real' a 'int'; posible pérdida de datos
1>          c:\ogresdk\include\pagedgeometry\pagedgeometry.h(1569) : vea la referencia a la creación de instancias de plantilla de función 'void Forests::GeometryPageManager::initPages<PageType>(const Forests::TBounds &,const Ogre::Any &,Ogre::uint32)' que se está compilando
1>          with
1>          [
1>              PageType=Forests::ImpostorPage
1>          ]
1>          c:\users\incaib\desktop\sceneloader\src\dotsceneloader.cpp(810) : vea la referencia a la creación de instancias de plantilla de función 'Forests::GeometryPageManager *Forests::PagedGeometry::addDetailLevel<Forests::ImpostorPage>(Ogre::Real,Ogre::Real,const Ogre::Any &,Ogre::uint32)' que se está compilando
1>c:\ogresdk\include\pagedgeometry\pagedgeometry.h(1601): warning C4244: '=' : conversión de 'float' a 'int'; posible pérdida de datos
1>c:\ogresdk\include\pagedgeometry\pagedgeometry.h(1609): warning C4244: 'inicializando' : conversión de 'Ogre::Real' a 'int'; posible pérdida de datos
1>c:\ogresdk\include\pagedgeometry\pagedgeometry.h(1610): warning C4244: 'inicializando' : conversión de 'Ogre::Real' a 'int'; posible pérdida de datos
1>  BaseApplication.cpp
1>  Generando código...
1>  PagedGeometry.lib(TreeLoader3D.obj) : se encontró .netmodule MSIL o un módulo compilado con /GL; reiniciando la vinculación con /LTCG; agregue /LTCG a la línea de comandos de vínculo para mejorar el rendimiento del vinculador
1>LINK : warning LNK4075: se omite '/INCREMENTAL' debido a la especificación '/LTCG'
1>PagedGeometry.lib(TreeLoader3D.obj) : error LNK2038: se detectaron diferencias para '_ITERATOR_DEBUG_LEVEL': el valor '0' no coincide con el valor '2' en BaseApplication.obj
1>PagedGeometry.lib(PagedGeometry.obj) : error LNK2038: se detectaron diferencias para '_ITERATOR_DEBUG_LEVEL': el valor '0' no coincide con el valor '2' en BaseApplication.obj
1>PagedGeometry.lib(BatchPage.obj) : error LNK2038: se detectaron diferencias para '_ITERATOR_DEBUG_LEVEL': el valor '0' no coincide con el valor '2' en BaseApplication.obj
1>PagedGeometry.lib(ImpostorPage.obj) : error LNK2038: se detectaron diferencias para '_ITERATOR_DEBUG_LEVEL': el valor '0' no coincide con el valor '2' en BaseApplication.obj
1>PagedGeometry.lib(PropertyMaps.obj) : error LNK2038: se detectaron diferencias para '_ITERATOR_DEBUG_LEVEL': el valor '0' no coincide con el valor '2' en BaseApplication.obj
1>PagedGeometry.lib(StaticBillboardSet.obj) : error LNK2038: se detectaron diferencias para '_ITERATOR_DEBUG_LEVEL': el valor '0' no coincide con el valor '2' en BaseApplication.obj
1>PagedGeometry.lib(BatchedGeometry.obj) : error LNK2038: se detectaron diferencias para '_ITERATOR_DEBUG_LEVEL': el valor '0' no coincide con el valor '2' en BaseApplication.obj
1>BaseApplication.obj : error LNK2001: símbolo externo __imp___CrtDbgReportW sin resolver
1>DotSceneLoader.obj : error LNK2001: símbolo externo __imp___CrtDbgReportW sin resolver
1>SampleApp.obj : error LNK2001: símbolo externo __imp___CrtDbgReportW sin resolver
1>PagedGeometry.lib(BatchedGeometry.obj) : error LNK2001: símbolo externo "__declspec(dllimport) public: virtual void __thiscall Ogre::MovableObject::removeQueryFlags(unsigned long)" (__imp_?removeQueryFlags@MovableObject@Ogre@@UAEXK@Z) sin resolver
1>bin\Debug\\OgreApp3.exe : fatal error LNK1120: 2 externos sin resolver
========== Volver a generar todo: 0 correctos, 1 incorrectos, 0 omitidos ==========
User avatar
altren
Gnome
Posts: 329
Joined: Tue Oct 24, 2006 9:02 am
Location: Moscow, Russa
x 24
Contact:

Re: new DotScene loader

Post by altren »

I guess you are trying to use Release PagedGeometry lib with Debug build, use debug library build.
Image
Post Reply