load and show Mesh

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
Guest

load and show Mesh

Post by Guest »

I worked now a few days to solve the problem, but it doesn't work. Propably I do something basicly wrong. I try to load an .x file (it is a ball with a wall texture). It loads the mesh!! but no matter what I can't see the object or it throws errors.
Do I need a mesh viewer to see a mesh? Do I need to have a texture to see the the object? What exactly to I have to include?
That is what I have right now:

#include <irrlicht.h>
#include <stdio.h>
#include <wchar.h>
#include <windows.h>

static irr::IrrlichtDevice* s_pDevice = NULL;
//-------------------------------------------------------
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
{
irr::scene::IAnimatedMeshSceneNode *model_node = 0;
s_pDevice = irr::createDevice(irr::video::EDT_SOFTWARE,
irr::core::dimension2d<irr::s32>(1024, 768),
16, false, false);

irr::gui::IGUIEnvironment* GuiEnv = s_pDevice->getGUIEnvironment();
irr::video::IVideoDriver* Video = GuiEnv->getVideoDriver();
irr::scene::ISceneManager* smgr = s_pDevice->getSceneManager();
//---------------------------------------------------------------------------------
irr::scene::IAnimatedMesh *model = smgr->getMesh("D:\\Irrlicht\\irrlicht-0.6\\Map_Test\\RadiantTest\\ball2.x");
irr::gui::IGUIMeshViewer* mesh_viewer = GuiEnv->addMeshViewer(irr::core::rect<irr::s32>(110,190,370,380), 0, 500, L"Viewer");
mesh_viewer->setMesh(model);
irr::video::SMaterial material;
material.Lighting = false;
material.Flags[irr::video::EMF_GOURAUD_SHADING]=true;
material.AmbientColor = irr::video::SColor(255,255,255,255);
material.MaterialType = irr::video::EMT_SOLID;
mesh_viewer->setMaterial(material);
.
.
.


In the red line I get the error. But if i don't have a meshviewer an just add a node, it doesn't show anything

Please help!!
Guest

Post by Guest »

I am just learning IRlight and found this in a example and it works:

scene::ISceneNode * node = smgr->addAnimatedMeshSceneNode( smgr->getMesh( "Data/test.x" ) );

No mesh viewer (what is it?), just add mesh scene node to scene manager :?
Guest

Post by Guest »

I tried that too. And it gives no error message, but I can't see the object. The screen is still empty. :cry:

irr::scene::IAnimatedMesh *model = smgr->getMesh("D:\\Irrlicht\\irrlicht-0.6\\Map_Test\\RadiantTest\\ball2.x");
model_node = smgr->addAnimatedMeshSceneNode(model);
rincewind
Posts: 35
Joined: Thu Mar 25, 2004 5:28 pm
Location: Germany --> Bonn

Post by rincewind »

To see somthing, you need a camera ;)
Have a look at the tutorials.

greetings, rincw
Guest

Post by Guest »

Terry Pratchett is cool!

Thanks I will try this camera thing :)
But I still don't get it, why the meshviewer crashes.
Guest

Post by Guest »

Mmmh, still doesn't show anything . I added:

irr::scene::ICameraSceneNode* camera = smgr->addCameraSceneNode();
camera->setPosition(irr::core::vector3df(-50,50,-150));

Any new idea?

Oh, it compiles but I see it throws a message in the debug-mode:

Unknown data object in x file: Header
No finishing semicolon in Transformation Matrix found in x file
Loaded mesh: D:\Irrlicht\irrlicht-0.6\Map_Test\RadiantTest\ball2.x
Guest

Post by Guest »

hey !!! It works. My problem wasn't the irrlicht engine but the conversion tool for .x, .obj, .3ds files. Guess it was too old.

I didn't try to add textures yet. So you will hear from me very soon :wink:
Post Reply