[Fixed]How to draw a mesh from a file without the file..
[Fixed]How to draw a mesh from a file without the file..
Yes this sound a bit weird but I couldn't describe better.
I have a text mesh I made with Blender.
I want to make a custom scene node with that text but I don't want to have the mesh file. I understand that if I convert it to irrmesh it becomes a simple xml file or something like that, that if I'll open it with notepad it would be readable.
I want to copy that mesh info so I'll be able to draw manually the mesh..
How can I do that if you understand what I mean?
P.S
I know how to make a custom scene node (well, it would be my first one). I guess it would be similar to the tutorial because there the triangle is drawn without a mesh file.
I have a text mesh I made with Blender.
I want to make a custom scene node with that text but I don't want to have the mesh file. I understand that if I convert it to irrmesh it becomes a simple xml file or something like that, that if I'll open it with notepad it would be readable.
I want to copy that mesh info so I'll be able to draw manually the mesh..
How can I do that if you understand what I mean?
P.S
I know how to make a custom scene node (well, it would be my first one). I guess it would be similar to the tutorial because there the triangle is drawn without a mesh file.
Last edited by MasterGod on Tue Feb 05, 2008 2:37 pm, edited 1 time in total.
Uhm, if I am hearing this correctly, you want to take the data out of the file, and put it into your program so that you no longer need the file? Well then, all you have to do is copy the xml to a string, and then parse it as if it was in a file. (That's if I am understanding you correctly.)
TheQuestion = 2B || !2B
That's exactly what I want and I've checked and the irrmesh is a xml file.Halifax wrote:Uhm, if I am hearing this correctly, you want to take the data out of the file, and put it into your program so that you no longer need the file? Well then, all you have to do is copy the xml to a string, and then parse it as if it was in a file. (That's if I am understanding you correctly.)
So, there must be an easy way to use a built-in method to read the code - string, instead of the file.. Just how can I do that?
I'll look on the IReadFile now but I don't want to read from a file, that's that whole idea, I want to copy the file's data into a string and read everything from that string and then draw the mesh (which's data is in a single string).
I think it kinda like the built-in font if I remember right its implementation.
Edit:
Should I pass read() method the string and the sizeof(st)?
P.S
The docs for the buffer are a bit confusing:
I think it kinda like the built-in font if I remember right its implementation.
Edit:
Should I pass read() method the string and the sizeof(st)?
P.S
The docs for the buffer are a bit confusing:
virtual s32 irr::io::IReadFile::read ( void * buffer,
u32 sizeToRead
) [pure virtual]
Reads an amount of bytes from the file.
Parameters:
buffer,: Pointer to buffer where to read bytes will be written to.
sizeToRead,: Amount of bytes to read from the file.
Returns:
Returns how much bytes were read.
Which of these I need?
And then again getMesh() wants a file not a IReadFile*..virtual IReadFile * createMemoryReadFile (void *memory, s32 len, const c8 *fileName, bool deleteMemoryWhenDropped=false)=0
Creates an IReadFile interface for accessing memory like a file.
virtual IXMLReader * createXMLReader (IReadFile *file)=0
Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*).
virtual IXMLReaderUTF8 * createXMLReaderUTF8 (IReadFile *file)=0
Creates a XML Reader from a file which returns all parsed strings as ASCII/UTF-8 characters (char*).
Looks like the first one that you need, passing it a pointer to the place in memory you have the file stored (as a string).
Personally i use a funky command line program called dattoh which turns a data file into a C header containing a char array of the data. So then you just have to include that file into your project and pass the array to a function that will accept a memory pointer to read from.
Personally i use a funky command line program called dattoh which turns a data file into a C header containing a char array of the data. So then you just have to include that file into your project and pass the array to a function that will accept a memory pointer to read from.
You mean IReadFile::read() or createMemoryReadFile()?JP wrote:Looks like the first one that you need, passing it a pointer to the place in memory you have the file stored (as a string).
I think Anim8tor can do that too but I'm not sure I want such solution..JP wrote:Personally i use a funky command line program called dattoh which turns a data file into a C header containing a char array of the data. So then you just have to include that file into your project and pass the array to a function that will accept a memory pointer to read from.
P.S
The irrmesh is a XML file, can't it help in some way?
i don't know anything about irrmesh but being xml doesn't help loading it from memory in anyway (doesn't make it harder i'm sure but doesn't make it easier).
What you want is to have the file stored in memory some way, a header is the best way to do this and storing it as a string/char-array is the way to do it, there's not really another way.
What you want is to have the file stored in memory some way, a header is the best way to do this and storing it as a string/char-array is the way to do it, there's not really another way.
MasterGod,
What exactly are you trying to do? Your first post made it sound like you were trying to prevent people from looking at your mesh data [which won't work]. Now it looks like you are trying to load mesh data directly into memory, and that isn't going to be very useful either because you would need to get direct access to the mesh loader, which you don't have.
So please, go back a step and tell us exactly what you are trying to do, e.g. what is the problem that you are trying to solve and why.
Travis
What exactly are you trying to do? Your first post made it sound like you were trying to prevent people from looking at your mesh data [which won't work]. Now it looks like you are trying to load mesh data directly into memory, and that isn't going to be very useful either because you would need to get direct access to the mesh loader, which you don't have.
So please, go back a step and tell us exactly what you are trying to do, e.g. what is the problem that you are trying to solve and why.
Travis
Lets say I have this string as the mesh's data:
How can I render it assuming its a static mesh? (example code maybe?)[/code]
P.S
I think maybe I'll use Bin2hfor the conversion though..
Edit: Not maybe, I am gonna use it![Smile :)](./images/smilies/icon_smile.gif)
Code: Select all
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __BUILD_IN_FONT_H_INCLUDED__
#define __BUILD_IN_FONT_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
// header file generated by Bin2H, copyright 2002 by N.Gebhardt.
// Bin2H is Freeware. Download it freely from www.code3d.com.
// for the source bitmap, see builtInFont.bmp
namespace irr
{
namespace gui
{
u8 BuiltInFontData[] =
{
0x42, 0x4d, 0x4a, 0x20, ...
0x23, 0x22
};
u32 BuiltInFontDataSize = sizeof(BuiltInFontData);
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif
P.S
I think maybe I'll use Bin2hfor the conversion though..
Edit: Not maybe, I am gonna use it
![Smile :)](./images/smilies/icon_smile.gif)
I don't try to hide my mesh data, I just don't want it to be an external file but part of the exe file.vitek wrote:MasterGod,
What exactly are you trying to do? Your first post made it sound like you were trying to prevent people from looking at your mesh data [which won't work]. Now it looks like you are trying to load mesh data directly into memory, and that isn't going to be very useful either because you would need to get direct access to the mesh loader, which you don't have.
So please, go back a step and tell us exactly what you are trying to do, e.g. what is the problem that you are trying to solve and why.
Travis
Yes, I do try to load it to memory and pass that data to the mesh loaders..
Is that impossible? (without modifying irrlicht?)
P.S
It seems we were posting at the same time
![Wink :wink:](./images/smilies/icon_wink.gif)
You would need to get a pointer to the mesh loader used to parse the given mesh file format. I don't see any way to do that yet, so this would require a change to the Irrlicht sources [add getMeshLoaderCount() and getMeshLoader(u32) to the scene manager interface and implementation]. This would be a useful addition to the Irrlicht core, so if you decide to do it, you might post a patch.
If you have ascii XML data, you don't need to use any utility, you just paste the xml content into your source and escape some characters [quotes and such]...
Then just write code to create a read file from that data...
The thing that really sucks about this idea is that you need to recompile and relink your application to change the mesh data. You must also remember to keep the source mesh around so you can regenerate the data if it is ever updated.
Travis
If you have ascii XML data, you don't need to use any utility, you just paste the xml content into your source and escape some characters [quotes and such]...
Code: Select all
const char dwarfMeshData[] =
"<?xml version=\"1.0\"?>"
"<mesh xmlns=\"http://irrlicht.sourceforge.net/IRRMESH_09_2007\" version=\"1.0\">"
"<!-- This file contains a static mesh in the Irrlicht Engine format with 3 materials.-->"
" <boundingBox minEdge=\"-34.120579 -3.543222 -49.155174\" maxEdge=\"38.802605 74.407661 19.682945\" />"
" <buffer>"
" <boundingBox minEdge=\"24.496161 15.668485 -46.026169\" maxEdge=\"35.487915 33.405987 16.553940\" />"
" <material>"
" <enum name=\"Type\" value=\"solid\" />"
" <color name=\"Ambient\" value=\"ffffffff\" />"
" <color name=\"Diffuse\" value=\"ffcccccc\" />"
" <enum name=\"TextureWrap4\" value=\"texture_clamp_repeat\" />"
// snip
" </material>"
" <vertices type=\"standard\" vertexCount=\"0\">\n"
" </vertices>"
" <indices indexCount=\"0\">"
" </indices>"
" </buffer>"
"</mesh>";
Code: Select all
io::IReadFile* file = fileSystem->createMemoryReadFile(dwarfMeshData, sizeof(dwarfMeshData), "dwarf.irrmesh");
Travis
1. I've added the methods you said, now which IMeshLoader should I use? (at index 0?)
2. I still prefer to use bin2h
3. "The thing that really sucks about this idea is that you need to recompile and relink your application to change the mesh data. You must also remember to keep the source mesh around so you can regenerate the data if it is ever updated. " That's really ain't a problem for me
Thanks.
2. I still prefer to use bin2h
![Wink :wink:](./images/smilies/icon_wink.gif)
3. "The thing that really sucks about this idea is that you need to recompile and relink your application to change the mesh data. You must also remember to keep the source mesh around so you can regenerate the data if it is ever updated. " That's really ain't a problem for me
![Smile :)](./images/smilies/icon_smile.gif)
Thanks.