getMesh problem

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
Whirled Peas
Posts: 47
Joined: Mon Jan 10, 2011 8:01 pm
Location: SoCal

getMesh problem

Post by Whirled Peas »

So, I've been trying to make different classes for different mesh objects within a game. So far it's pretty simple:


Code: Select all

class PlayerMesh {



    public:

        IAnimatedMesh* Mesh;
        IAnimatedMeshSceneNode* MeshNode;
        PlayerMesh (ISceneManager*, IVideoDriver*, string, string);

};

PlayerMesh::PlayerMesh (ISceneManager* manager, IVideoDriver* drvr, string MPath, string TPath) {

    Mesh = manager->getMesh(MPath);
    MeshNode = manager->addAnimatedMeshSceneNode(Mesh);

    MeshNode->setMaterialFlag(EMF_LIGHTING, false);
    MeshNode->setMaterialTexture(0, drvr->getTexture(TPath));


Here is how it was called:

Code: Select all

PlayerMesh PMesh (smgr, driver, "c:/gamemedia/b3dtest.b3d", "c:/gamemedia/UV.jpg");

Whenever I try and run the program, I get this error:

C:\game\gaim.cpp|40|error: no matching function for call to 'irr::scene::ISceneManager::getMesh(std::string&)'|
which is in reference to the getMesh line of code.


Now, I've tried changing the strings into ifstreams in stead, but all I get is this error:
C:\game\gaim.cpp|40|error: invalid conversion from 'void*' to 'irr::io::IReadFile*'|
Also, I use std::string in stead of just string even though I already included the std namespace because if I don't I get this error when I use it:
C:\game\gaim.cpp|34|error: reference to 'string' is ambiguous|

Normally I would ask on a C++ forum about this, however I get the feeling that this has something to do with getMesh itself and how it is supposed to be called, which would make it an irrlicht problem. Can anyone help me with this? I have a feeling it's just a variable format problem, I just need to know the right kind to use. Now, the irrlicht API says that getMesh uses a string variable, but clearly it's not quite that simple, so what's up?


Thanks in advance.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Whirled Peas wrote:the irrlicht API says that getMesh uses a string variable, but clearly it's not quite that simple, so what's up?
that's right, but you're using a string class and not a normal/standard string (char*) !!! ;)
you'll need to get the string from the string class... ;)

try this:

Code: Select all

Mesh = manager->getMesh(MPath.c_str());
and:

Code: Select all

drvr->getTexture(TPath.c_str())
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Whirled Peas
Posts: 47
Joined: Mon Jan 10, 2011 8:01 pm
Location: SoCal

Post by Whirled Peas »

thank you very much, that did it.

you'll need to get the string from the string class... Wink
Now, I think I understand what you mean here. You're saying that you need to tell the compiler to get the actual information stored inside the variable rather than just providing the variable. If that is correct, why the extra step? Why can't you just use the variable? Obviously the compiler knows how to read this information when printing the contents of a string variable to the screen, but why can't it do that here?

Or did I completely misunderstand what you said before?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

well, this is c++ basics... ;)

a string normally means a character array like:

Code: Select all

char myString[1024];
this is a string with 1024 chars...
and this is the string you use for functions like getMesh()...
but such a string is very unhandy, therefore string classes was invented...

std:string and irr::core::stringc are classes !!!
they are not the string variable, but they are containers that store the string !!!
if you want to get the string from such a class you'll have to expicitly tell the class to provide you with the string !!! ;)

remember a string class is not a string, it just stores the string and provides you with functions to manipulate and get the string... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Actually, it's not a problem with calling this method with a string class. You simply used the wrong one. Irrlicht has its own container classes, and no overloads for STL based ones. So instead of using std::string you can use core::stringc in your code, and a call with getMesh(myString) would work as well. Even better would be to use io::path as class, as it correctly recognizes the usage of unicode filenames. Just check the API for proper parameters.
Whirled Peas
Posts: 47
Joined: Mon Jan 10, 2011 8:01 pm
Location: SoCal

Post by Whirled Peas »

Acki wrote:well, this is c++ basics... ;)

a string normally means a character array like:

Code: Select all

char myString[1024];
this is a string with 1024 chars...
and this is the string you use for functions like getMesh()...
but such a string is very unhandy, therefore string classes was invented...

std:string and irr::core::stringc are classes !!!
they are not the string variable, but they are containers that store the string !!!
if you want to get the string from such a class you'll have to expicitly tell the class to provide you with the string !!! ;)

remember a string class is not a string, it just stores the string and provides you with functions to manipulate and get the string... ;)
Well, I'm aware that a string class is technically just an array of chars, but there is a bit of a difference between knowing about a programming concept involved in a specific language, and having the proper mindset for laying out the structure of a program. I"m a bit handicapped by having Python be my primary language which has in my opinion a simpler implementation as far as variables goes. I'd use the new python wrapper for irrlicht, but I gather that it is not the easiest thing to get Python and Bullet working together, also I spent some good time and effort relearning C++ in order to use Irrlicht which makes me apprehensive to going back to python.
Post Reply