loading models in diffrent way[solved]

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

loading models in diffrent way[solved]

Post by omar shaaban »

well the orginal method is like this:

Code: Select all

node=smgr->addAnimatedMeshSceneNode(smgr->getMesh("model.3ds"));
but what if i have a string that contains the model so i want it to load it rather than the "model.3ds" so i wrote this:

Code: Select all

std::string file;
//by xml loader i import the model data(model.3ds) to it.
node=smgr->addAnimatedMeshSceneNode(smgr->getMesh(file));
but ofcourse it didnt work because the parameter excepts only irr::c8 * .. type so i made this:

Code: Select all

irr::c8 * loader;
loader+=model   //[b]error here cant add them because they are diffrent!!![/b]
node=smgr->addAnimatedMeshSceneNode(smgr->getMesh(loader));

so any idea!?
Last edited by omar shaaban on Fri Jul 06, 2007 6:55 pm, edited 3 times in total.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

to get a pointer to a character array from a std::string or an irr::string, simply use c_str(). for example: file.c_str()
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

well it is not i will post all the needed code here first here is the block.3ds file:

Code: Select all

MMÒ   
      ==  ÿ¯>        None      	            	   ÌÌÌ0     	   ÿÿÿ @~  Cube  As  Aˆ    ‘@è‰@@=‰¼‘@è‰@@=‰¼‘@è‰@@=‰¼‘@v!À@=‰¼‘@v!À@=‰¼‘@v!À@=‰¼ãn Àv!À@=‰¼ãn Àv!À@=‰¼ãn Àv!À@=‰¼Þn Àë‰@@=‰¼Þn Àë‰@@=‰¼Þn Àë‰@@=‰¼‘@ã‰@ÃvŸ@‘@ã‰@ÃvŸ@‘@ã‰@ÃvŸ@‘@v!ÀÃvŸ@‘@v!ÀÃvŸ@‘@v!ÀÃvŸ@èn Àv!ÀÃvŸ@èn Àv!ÀÃvŸ@èn Àv!ÀÃvŸ@ãn Àè‰@ÃvŸ@ãn Àè‰@ÃvŸ@ãn Àè‰@ÃvŸ@‘@ã‰@ÃvŸ@‘@ã‰@ÃvŸ@ãn Àè‰@ÃvŸ@ãn Àè‰@ÃvŸ@èn Àv!ÀÃvŸ@èn Àv!ÀÃvŸ@‘@v!ÀÃvŸ@‘@v!ÀÃvŸ@ AÝ             	                              
   
     
                                                       0A5   None            	 
   
       @A    àg ¿ Ç?€`.¾ ? V¿â͆?¨ª ¿2‡?¨ª ¿=d?¿ô&> ‡?€`.¾ ‡?aU-¾2‡?
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

ist my qustion clear or is it complicated !!?some help here :wink:
death_au
Posts: 38
Joined: Tue Apr 17, 2007 9:48 am
Location: Australia

Post by death_au »

You shouldn't be trying to put the data from the mesh file in the xml. Instead, you should put the filename of the mesh file in the xml, and as long as the program can find that filename, your code should work.
I.e.

Code: Select all

<?xml version="1.0"?>
<main>
    <3dsfile> block.3ds </3dsfile>
</main> 
Image
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

death_au wrote:You shouldn't be trying to put the data from the mesh file in the xml. Instead, you should put the filename of the mesh file in the xml, and as long as the program can find that filename, your code should work.
I.e.

Code: Select all

<?xml version="1.0"?>
<main>
    <3dsfile> block.3ds </3dsfile>
</main> 
ahhhhhh another stupid answer i know but what i am trying to do here if u understood that i am making my own loader like the other topic u guys dont understand so don't answer please :evil:
and don't read from the tutorial and then tell me here
JediTrooper87
Posts: 8
Joined: Sat Jun 16, 2007 6:13 am
Location: Kansas

Post by JediTrooper87 »

First I have a questions:
What do you mean by "it loads perfectly"? Do you mean the application or the model loads?


It might have to do with the Irrlicht model loaders, they all check the file type of the model it's supposed to be loading by checking the ending of the filename (block.3ds) so it knows what loader to use. Since you're file no longer ends in .3ds, Irrlicht may not know which model loader it's supposed to be using.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

When he says it loads perfectly he means that it is loading the data from the xml file into the string correctly.

The problem is this...

Code: Select all

node=smgr->addAnimatedMeshSceneNode(smgr->getMesh(model.c_str()));
You should know by now that the parameter to getMesh() is the name of the file to load, i.e. smgr->getMesh("../../media/dwarf.x"). Unfortunately you are passing a string that represents the file data. That won't work.

If you have the model data [the contents of a model file] in memory, you need to find a way to get that model data into an animated mesh, and then manually add that to the mesh cache. You would need to create an IMemoryReadFile from your data, get access to the scene managers mesh loaders, and then try to load the mesh using the loaders. All that means more mods to the Irrlicht source to get what you want.

I'm curious why using IrrEdit isn't good enough for you. It already does all of this, and it works.

Travis
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

And once more a reminder to keep cool. You are moving into a rather problematic position by attacking people who want to help you. Even your annoying reminders are not really a good idea...
BTW: the ideas presented here are all better than your solution. Moreover, you might face a problem with a bytetream in XML - I'm not sure if the different encodings used for XML all handle byte streams correctly!
JonLT
Posts: 152
Joined: Thu Mar 15, 2007 5:47 pm
Location: Denmark

Post by JonLT »

in stead of using the 3ds format, export the model to a file that holds all the numbers to create the mesh. Anim8tor can do this by exporting to a .h file. When you have all the numbers (coordinates and stuff) you could load the mesh by creating a custom scene node that loads all the data from the exported file, or from passed arrays.

EDIT: I know irrklang can load a file from memory (converting it with bin2h), maybe you can in some way make irrlicht able to load a mesh converted with bin2h?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, the bin2h solution (together with IMemoryReadFile) will do it.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

to flog this some more, you simply can't store binary data inside an xml file or any other text file without encoding it as text. if you need to store binary data, then you should use a binary file. If you want to access this binary file using an IXMLReader, then you'll have to make your own binary implementations of IXMLReader/Writer (which would be very cool indeed). then you can use filesystem->createMemoryReadFile as suggested, and of course add smgr->getMesh(IReadFile*) which would be very easy.

I take it you're trying to make a scene format that loads your game entities from a single file? The best option would be to put an .irr file and all your models and textures inside a zip file, then rename the zip to .dat or something. You can then use an ISceneUserDataSerializer to get any extra data back out as your nodes are loaded. Another option, if you have your own custom nodes that you use as game entities, you could package them up as irrEdit plugins and use irrEdit to edit your entire game.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

will thanks guys u really helped me guys but will u helped me if i didnt make these annoying posts !! well i understand your suggsetion with .irr but ,irr doesnt contain the mesh within it just store the path but what i am trying to do with xml is simply a method to load the model so to protect it by changing some of the data of the mesh in the xml and then make my application return it back so it would protect my model and to make another 3d fromat(ofcourse it will not be another 3d fromat it will be just the same format)
but i think i mustsee the solar model program made by greenya so to see how does it load the models(.dat?)
and thanks guys very much!!! :wink: :)
Perceval
Posts: 158
Joined: Tue May 30, 2006 2:42 pm

Post by Perceval »

He has already told you how it work :
http://irrlicht.sourceforge.net/phpBB2/ ... +model+dat
.dat is just a zip archive, that irrlicht is able to load.
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

Perceval wrote:He has already told you how it work :
http://irrlicht.sourceforge.net/phpBB2/ ... +model+dat
.dat is just a zip archive, that irrlicht is able to load.
ya i know!! thanks :)
Post Reply