I exported a google sketchup simple cube object and saved it as an obj file (plus mtl file)
I'm trying to draw this cube in a world which contains lights but the cube is drawn black and the lights don't effect it.
( )
from what I know, it is enough (in openGL and in OGRE for insatnce) to set the ambient light and then all of the objects are lit in a certain manner,
and offcourse if put another light it also effect the picture.
I noticed the in the mtl file each time the ambient (Ka) is 0,0,0 it apears black.
What should I do?
Is it good that in the .mtl the "Ka" is 0,0,0?
Should I change it manually to a different value?
Attached is the code,
thanks, Dan
code:
Code: Select all
#include <iostream>
#include <irrlicht.h>
using namespace std;
using namespace irr;
using namespace irr::core;
using namespace irr::scene;
using namespace irr::video;
using namespace irr::io;
using namespace irr::gui;
int main(int argc, char** argv)
{
if ( argc != 2 )
{
cout << "Usage: " << argv[0] << "<file>" << endl;
return -1;
}
IrrlichtDevice *device = createDevice(
//video::EDT_OPENGL,
//video::EDT_SOFTWARE,
//video::EDT_BURNINGSVIDEO,
video::EDT_DIRECT3D9,
dimension2d<s32>(1000, 800), 16, false, false, false, 0);
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
/*
device->getFileSystem()->addZipFileArchive("awesome home.zip");
scene::IAnimatedMesh* mesh = smgr->getMesh("awesome home.dae");
//scene::IAnimatedMesh* mesh = smgr->getMesh("doc.kml");
//*/
scene::IAnimatedMesh* mesh = smgr->getMesh(argv[1]);
//scene::IAnimatedMesh* mesh = smgr->getMesh("dan/stclairhighschool.obj");
//scene::IAnimatedMesh* mesh = smgr->getMesh("stclairhighschool.obj");
//scene::IAnimatedMesh* mesh = smgr->getMesh("stclairhighschool.dae");
//scene::IAnimatedMesh* mesh = smgr->getMesh("stclairhighschool/stclairhighschool.3ds");
scene::ISceneNode* node = 0;
if (!mesh)
{
return -1;
}
node = smgr->addOctTreeSceneNode(mesh->getMesh(0));
//node = smgr->addMeshSceneNode(mesh->getMesh(0));
smgr->setAmbientLight(video::SColorf(1.0f,1.0f,1.0f,1.0f));
/*
ILightSceneNode* light1 = smgr->addLightSceneNode( 0, core::vector3df(0,-10,0));//, video::SColorf(0.7f,0.5f,0.3f), 1.0f, 1 );
SLight l = light1->getLightData( );
//vector3df dir(-0.0f, -10.0f, -0.0f);
//dir.normalize();
//l.Direction = dir;
//light1->setLightData( l );
//light1->setRotation( dir );
light1->setLightType(irr::video::ELT_DIRECTIONAL);
E_LIGHT_TYPE type = light1->getLightType();
l = light1->getLightData();
//*/
if (!node)
{
return -1;
}
for ( size_t i = 0 ; i != node->getMaterialCount() ; ++i )
{
//node->getMaterial(i).Lighting = true;
//node->getMaterial(i).SpecularColor.set(255,255,255,255);
//node->getMaterial(i).AmbientColor.set(255,255,255,255);
//node->getMaterial(i).DiffuseColor.set(255,255,255,255);
//node->getMaterial(i).EmissiveColor.set(255,100,100,100);
//node->getMaterial(i).Shininess = 20.0f;
//node->getMaterial(i).NormalizeNormals = true;
//*/
}
node->setMaterialFlag(EMF_LIGHTING, true);
node->setMaterialFlag(video::EMF_BACK_FACE_CULLING, true);
//node->setMaterialFlag(video::EMF_FRONT_FACE_CULLING, true);
node->setPosition(core::vector3df(0, 0, 1000));
//node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
//smgr->setShadowColor(video::SColor(150,0,255,0));
smgr->addCameraSceneNodeFPS()->setFarValue(3000.0f);
device->getCursorControl()->setVisible(false);
int lastFPS = -1;
while(device->run())
{
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(255,20,20,60));
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;
}