Beginner's Irrlicht 1.7.2 Texturing Help?
Beginner's Irrlicht 1.7.2 Texturing Help?
For the past couple of days, i've been trying to follow the codes given in the tutorials. The meshes work just fine and I was able to import my 3ds objects into 3D space. However, when it came to texturing, the given codes just don't seem to cut it. Anybody care to help out a beginner like me?
Thanks in advanced
Thanks in advanced
Re: Beginner's Irrlicht 1.7.2 Texturing Help?
Re-read every single comment on tutorials and I'm sure you'll find your answer.
I won't give you code, just a word explanation of what you should do.
1) set the texture to 0 slot/index.
2) set a lighting material flag to false if you don't have any lights, else it's going to be black.
I won't give you code, just a word explanation of what you should do.
1) set the texture to 0 slot/index.
2) set a lighting material flag to false if you don't have any lights, else it's going to be black.
Working on game: Marrbles (Currently stopped).
Re: Beginner's Irrlicht 1.7.2 Texturing Help?
I've been using the basic format of this one:
node->setMaterialFlag(EMF_LIGHTING,false);
node->setMaterialTexture( 0, driver->getTexture("path_to_my_texture") );
I still get a black object. On the console, it doesn't say that the texture has been loaded either.
Just on a side note, I have two "nodes". One of them textured the Quake3D map and the node2 is the one that's supposed to texture my object.
node->setMaterialFlag(EMF_LIGHTING,false);
node->setMaterialTexture( 0, driver->getTexture("path_to_my_texture") );
I still get a black object. On the console, it doesn't say that the texture has been loaded either.
Just on a side note, I have two "nodes". One of them textured the Quake3D map and the node2 is the one that's supposed to texture my object.
Re: Beginner's Irrlicht 1.7.2 Texturing Help?
could you assign the driver->getTexture call to an object, set a breakpoint, and inspect the object after the call?
Could you post a minimal block of code that reproduces the issue?
Could you post a minimal block of code that reproduces the issue?
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
Re: Beginner's Irrlicht 1.7.2 Texturing Help?
Probably the texture is not in the correct folder then. If you`re loading model that`s not from the examples media (dwarf, ninja, fairy, Sydney etc.) but some made by you you may have messed sth. You can try if your own models are properly loaded in Irrlicht using the 09 example - MeshViewer loading the mesh and then the texture (if not loaded automatically - formats out of .obj or .3ds).
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Re: Beginner's Irrlicht 1.7.2 Texturing Help?
I've used that code above with the same texture path and yes, it found the texture. The only problem is that it still won't apply it to the object.pepeshka wrote:could you assign the driver->getTexture call to an object, set a breakpoint, and inspect the object after the call?
Could you post a minimal block of code that reproduces the issue?
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: Beginner's Irrlicht 1.7.2 Texturing Help?
If the texture is loaded, it is also applied. Maybe your texture coords are not set.
Re: Beginner's Irrlicht 1.7.2 Texturing Help?
Oh cool. Yes, that might fix it. What should i refer to, to learn about setting the texture coords?hybrid wrote:If the texture is loaded, it is also applied. Maybe your texture coords are not set.
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Re: Beginner's Irrlicht 1.7.2 Texturing Help?
You should load back your model in a 3D editor (Blender, 3DSMAx, etc.) and check that it's properly UV mapped. Theses software have tools to create UV maps.
Every model that you use should have been properly UV Mapped so a image based texture can be applied.
Every model that you use should have been properly UV Mapped so a image based texture can be applied.
Re: Beginner's Irrlicht 1.7.2 Texturing Help?
Yea, I tried that not too long ago too. I unwrapped the UV and then put the texture on the map. However, it still won't load properly.christianclavet wrote:You should load back your model in a 3D editor (Blender, 3DSMAx, etc.) and check that it's properly UV mapped. Theses software have tools to create UV maps.
Every model that you use should have been properly UV Mapped so a image based texture can be applied.
Okay, so I hope this helps. Below, I have my entire program code (it's a mess, I know):
Code: Select all
#include <iostream>
#include <irrlicht.h>
using namespace std;
using namespace irr;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
int main()
{
video::E_DRIVER_TYPE driverType;
printf("Please select the driver you want for this example:\n"\
" (a) OpenGL 1.5\n (b) Direct3D 9.0c\n (c) Direct3D 8.1\n"\
" (d) Burning's Software Renderer\n (e) Software Renderer\n"\
" (f) NullDevice\n (otherKey) exit\n\n");
char i;
cin >> i;
switch(i)
{
case 'a': driverType = video::EDT_OPENGL; break;
case 'b': driverType = video::EDT_DIRECT3D9;break;
case 'c': driverType = video::EDT_DIRECT3D8;break;
case 'd': driverType = video::EDT_BURNINGSVIDEO;break;
case 'e': driverType = video::EDT_SOFTWARE; break;
case 'f': driverType = video::EDT_NULL; break;
default: return 1;
}
// create device and exit if creation failed
IrrlichtDevice *device =
createDevice(driverType, core::dimension2d<u32>(640, 480));
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
device->getFileSystem()->addZipFileArchive("../../Quake3Map/media/map-20kdm2.pk3");
device->getFileSystem()->addFileArchive("../../Irrlicht Testing/Clouds.jpg");
scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* node = 0;
if (mesh)
node = smgr->addOctreeSceneNode(mesh->getMesh(0), 0, -1, 1024);
if (node)
node->setPosition(core::vector3df(-1300,-144,-1249));
video::ITexture* texture = driver->getTexture("C:/Users/SgtZeroStar/Desktop/Irrlicht Testing/Clouds.jpg");
scene::IAnimatedMesh* mesh2 = smgr->getMesh("C:/Users/SgtZeroStar/Desktop/Irrlicht Testing/BipedWalkAnim.3ds");
scene::IBillboardSceneNode* node2 = 0;
if(mesh2)
node = smgr->addOctreeSceneNode(mesh2->getMesh(0), 0, -1, 256);
if (node2)
{
node2->setPosition(core::vector3df(-1300,-144,-1300));
node2->setMaterialFlag(video::EMF_LIGHTING,false);
node2->setMaterialTexture(0, driver->getTexture("../../Clouds.jpg"));
node2->setMaterialType(video::EMT_SOLID);
}
smgr->addCameraSceneNodeFPS();
/*
The mouse cursor needs not be visible, so we hide it via the
irr::IrrlichtDevice::ICursorControl.
*/
device->getCursorControl()->setVisible(false);
int lastFPS = -1;
while(device->run())
{
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(255,200,200,200));
smgr->drawAll();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Irrlicht Engine - Quake 3 Map example [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
else
device->yield();
}
device->drop();
return 0;
}
Re: Beginner's Irrlicht 1.7.2 Texturing Help?
I don't know if it is related, but node2 is never set.
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Re: Beginner's Irrlicht 1.7.2 Texturing Help?
Wow! Your surely trying to test the IRRlicht limits here! Your "mesh2" name is "BipedWalkAnim.3ds" Is it really meaning that you have exported a BIPED animation to a 3DS file? If it's the case it will not work. Try to get the Panda Exporter and export it to .X format. (If your using MAX)
I'm also seeing that you defined a QuakeIII level, loaded it as an occtree in node, (OK)-> but then assigned and loaded the mesh2 in it (occtree). I would rather recomment that you load it as an IAnimatedMeshNode. Animated models and levels are really not the same.
If your mesh2 is not a static mesh, then you should try to fix this before.
Also when you defined your node, try to remove the lighting on it the same way it's done on the other nodes:
Your code to load and apply the mesh is this:
If would rather do this:
Since you said you applied a texture on the model, it should load automaticaly when you load the mesh.
If you want to overide the defined texture then you would do this:
Also, Try to comment this out while testing. It may (or not) cause a problem:
Not sure if it would cause a problem, but since you don't see it applied, try to comment it out while your finding out where is the problem.
I'm also seeing that you defined a QuakeIII level, loaded it as an occtree in node, (OK)-> but then assigned and loaded the mesh2 in it (occtree). I would rather recomment that you load it as an IAnimatedMeshNode. Animated models and levels are really not the same.
If your mesh2 is not a static mesh, then you should try to fix this before.
Also when you defined your node, try to remove the lighting on it the same way it's done on the other nodes:
Code: Select all
node->setMaterialFlag(video::EMF_LIGHTING,false);
Code: Select all
video::ITexture* texture = driver->getTexture("C:/Users/SgtZeroStar/Desktop/Irrlicht Testing/Clouds.jpg");
scene::IAnimatedMesh* mesh2 = smgr->getMesh("C:/Users/SgtZeroStar/Desktop/Irrlicht Testing/BipedWalkAnim.3ds");
scene::IBillboardSceneNode* node2 = 0;
if(mesh2)
node = smgr->addOctreeSceneNode(mesh2->getMesh(0), 0, -1, 256);
If would rather do this:
Code: Select all
scene::IAnimatedMeshSceneNode* node_model = 0;
scene::IAnimatedMesh* mesh2 = smgr->getMesh("C:/Users/SgtZeroStar/Desktop/Irrlicht Testing/BipedWalkAnim.x");
if(mesh2)
{
node_model = smgr->addAnimatedMeshSceneNode(mesh2, 0, -1);
node_model->setMaterialFlag(video::EMF_LIGHTING,false);
node_model->setMaterialType(video::EMT_SOLID);
//Uncomment this if you need to override the texture
//node_model->setMaterialTexture(0, driver->getTexture("../../Clouds.jpg"));
}
scene::IBillboardSceneNode* node2 = 0;
If you want to overide the defined texture then you would do this:
Code: Select all
node_model->setMaterialTexture(0, driver->getTexture("../../Clouds.jpg"));
Code: Select all
device->getFileSystem()->addFileArchive("../../Irrlicht Testing/Clouds.jpg");
Re: Beginner's Irrlicht 1.7.2 Texturing Help?
So....I've tried the code you put on top there, but now the mesh is just completely gone. The console says it loaded the mesh and texture, but I can't find it anywhere now.
Perhaps it's something wrong with my texture?
Again, I am thankful for all your time and effort on trying to help.
Perhaps it's something wrong with my texture?
Again, I am thankful for all your time and effort on trying to help.
Re: Beginner's Irrlicht 1.7.2 Texturing Help?
Okay, so after a decent while of searching, I take back what I said before. The object is in Irrlicht and I just put it in the wrong place. However, the problem still exists and this time, the object is white.
Edit: Okay, so once I changed it to a different object of which I had a clearly laid out texture, I was able to get a gray object when the texture failed to load. Once I managed to change the png image to the right name, the texture was applied perfectly onto the object. Thank you for all of those who commented and helped. It was a great learning experience.
Edit: Okay, so once I changed it to a different object of which I had a clearly laid out texture, I was able to get a gray object when the texture failed to load. Once I managed to change the png image to the right name, the texture was applied perfectly onto the object. Thank you for all of those who commented and helped. It was a great learning experience.