Page 6 of 6

Re: new DotScene loader

Posted: Wed May 12, 2010 6:16 pm
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!

Re: new DotScene loader

Posted: Fri May 14, 2010 6:16 pm
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?

Re: new DotScene loader

Posted: Sat May 15, 2010 1:15 pm
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!

Re: new DotScene loader

Posted: Thu May 20, 2010 2:24 am
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;
}

Re: new DotScene loader

Posted: Thu May 20, 2010 1:35 pm
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 :)

Re: new DotScene loader

Posted: Fri May 21, 2010 7:06 am
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

Re: new DotScene loader

Posted: Mon May 24, 2010 9:32 pm
by jacmoe
Great. :)
I was being sloppy..

I plan to rewrite it to make it more generic.
And put it on the Ogre Wiki.

[HELP] DotSceneLoader - problem with scene reloading

Posted: Fri Jul 02, 2010 12:09 pm
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

Re: new DotScene loader

Posted: Mon Jul 18, 2011 6:21 pm
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.

Re: new DotScene loader

Posted: Mon Jul 18, 2011 6:31 pm
by conallmmcg
that looks like a linking error?
are your libs/dependencies setup correctly in your project? (correct names and paths etc)

Re: new DotScene loader

Posted: Mon Jul 18, 2011 7:09 pm
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.

Re: new DotScene loader

Posted: Mon Jul 18, 2011 9:19 pm
by jacmoe
You have to add DotSceneLoader.cpp to the project. :wink:

Re: new DotScene loader

Posted: Mon Jul 18, 2011 9:27 pm
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)

Re: new DotScene loader

Posted: Mon Jul 18, 2011 9:28 pm
by spacegaier
Well you have to convert it:

Code: Select all

myOgreString.c_str()

Re: new DotScene loader

Posted: Mon Jul 18, 2011 9:35 pm
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

Re: new DotScene loader

Posted: Fri Jul 22, 2011 10:59 am
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).

Re: new DotScene loader

Posted: Wed Aug 17, 2011 9:53 pm
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 ==========

Re: new DotScene loader

Posted: Thu Aug 18, 2011 5:03 pm
by altren
I guess you are trying to use Release PagedGeometry lib with Debug build, use debug library build.