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.
Guest
Post
by Guest » Mon Jun 21, 2004 6:12 am
I want to be able to load a mesh and texture from a variable named meshFile. So if I name the files accordingly, how can I make this work:
Code: Select all
scene::IAnimatedMesh* weaponMesh = CIrrlichtManager::smgr->getMesh("models/meshFile.obj");
scene::IAnimatedMeshSceneNode* weaponNode = smgr->addAnimatedMeshSceneNode( weaponMesh, camera, 0, irr::core::vector3df(40.0f, -40.0f, 40.0f), irr::core::vector3df(0.0f, 0.0f, 30.0f) );
weaponNode->setMaterialTexture( 0, driver->getTexture("textures/meshFile.jpg") );
So where you see meshFile, it is actually replaced with a string variable called meshFile. In PHP you do ".var." But..I am unsure how to do it here.
Thanks.
Endar
Posts: 145 Joined: Mon Jun 14, 2004 7:59 am
Post
by Endar » Mon Jun 21, 2004 8:22 am
Code: Select all
scene::IAnimatedMesh* weaponMesh = CIrrlichtManager::smgr->getMesh("models/meshFile.obj");
weaponNode->setMaterialTexture( 0, driver->getTexture("textures/meshFile.jpg") );
So, where the strings "models/meshFile.obj" and "textures/meshFile.jpg" are they will be replaced by string variables, eg. string1[] = "models/meshFile.obj" and string2[] = "textures/meshFile.jpg" (not exact C code) ??
Is that right?? You're using C++, right? If this is the case, you just replace the string literals (the strings you typed in the code) with the variables. So, instead of the code above, you would have:
Code: Select all
scene::IAnimatedMesh* weaponMesh = CIrrlichtManager::smgr->getMesh(string1);
weaponNode->setMaterialTexture( 0, driver->getTexture(string2 ) );
"The reputation of a thousand years may be determined by the conduct of one hour."
-Japanese Proverb
Guest
Post
by Guest » Mon Jun 21, 2004 10:50 pm
meshFile is a stringw, when I use that code I get this error:
error C2664: 'irr::scene::ISceneManager::getMesh' : cannot convert parameter 1 from 'irr::core::stringw' to 'const irr::c8 *'
Tyn
Posts: 932 Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:
Post
by Tyn » Mon Jun 21, 2004 11:22 pm
If you are using a string file you have to convert it to c8. To do that, replace:
smgr->getMesh( string1 );
With:
smgr->getMesh( string1.c_str() );
Guest
Post
by Guest » Mon Jun 21, 2004 11:48 pm
I thought so, even when I add that it gives me THIS..
: error C2664: 'irr::scene::ISceneManager::getMesh' : cannot convert parameter 1 from 'const wchar_t *' to 'const irr::c8 *'
are you sure that function is correct for the c8 type?
Thanks.