How I can start in the center of my 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
Gideon
Posts: 26
Joined: Sat Oct 25, 2008 11:28 am
Location: Russian
Contact:

How I can start in the center of my mesh?

Post by Gideon »

How?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

I think you mean node, not mesh... :lol:
you can try it with:

Code: Select all

vector3df cntr = node->getBoundingBox().getCenter();
but I doubt that is what you want... ;)
it's not that easy though, because a mesh usually is more complex... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Gideon
Posts: 26
Joined: Sat Oct 25, 2008 11:28 am
Location: Russian
Contact:

Post by Gideon »

All good yet, but I have again the problem.
Look:
From above:
Image
From below:
Image
Whay is it?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Gideon wrote:What is it?
I don't know, tell me what you expect and what you get...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Gideon
Posts: 26
Joined: Sat Oct 25, 2008 11:28 am
Location: Russian
Contact:

Post by Gideon »

This is a *.b3d world. It's like good in the Gile[s] and 3ds Max, but when I have load it... i see this.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

It looks to me like the normals are on the wrong sides of the resulting mesh. I don't know if this is a problem in the mesh itself or if it is a problem with the reader code.
Gideon
Posts: 26
Joined: Sat Oct 25, 2008 11:28 am
Location: Russian
Contact:

Post by Gideon »

Code:

Code: Select all

#include <irrlicht.h>
#include <iostream>

using namespace irr;

#pragma comment(lib, "Irrlicht.lib")

int main()
{
        IrrlichtDevice *device =
                createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480));

        if (device == 0)
                return 1; 
        video::IVideoDriver* driver = device->getVideoDriver();
        scene::ISceneManager* smgr = device->getSceneManager();
        device->getFileSystem()->addZipFileArchive("../../media/mapppeZ!.zip");
        scene::IAnimatedMesh* mesh = smgr->getMesh("ee.b3d");
        scene::ISceneNode* node = 0;
        if (mesh)
                node = smgr->addOctTreeSceneNode(mesh->getMesh(0), 0, -11, 12);
        if (node)
                node->setPosition(core::vector3df(0,-1,0));
        smgr->addSkyBoxSceneNode( 
                                  driver->getTexture("../../media/irrlicht2_up.jpg"), 
                                  driver->getTexture("../../media/irrlicht2_dn.jpg"), 
                                  driver->getTexture("../../media/irrlicht2_lf.jpg"), 
                                  driver->getTexture("../../media/irrlicht2_rt.jpg"), 
                                  driver->getTexture("../../media/irrlicht2_ft.jpg"), 
                                  driver->getTexture("../../media/irrlicht2_bk.jpg"));
        scene::ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS(0, 100.0f, 100.0f); 
        cam->setPosition(core::vector3df(0,0,0)); 
        cam->setTarget(core::vector3df(0,0,0));
        smgr->addCameraSceneNodeFPS();
        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"gently caress!!!!!!!!!";
                                str += driver->getName();
                                str += " | FPS:";
                                str += fps;

                                device->setWindowCaption(str.c_str());
                                lastFPS = fps;
                        }
                }
                else
                        device->yield();
        }
        device->drop();
        return 0;
}
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

is that even vaguely like it should look?

it's probably nothing to do with normals as normals are just used for lighting and this clearly isn't a lighting issue.

more likely the triangles are wound the wrong way round so they're facing the opposite direction to where they should be facing. so you've probably got backface culling turned on so you don't see the backs of the triangles which in this case you would want to, you can change this parameter in irredit under the materials section. but of course for efficiency's sake you'd want backface culling on and for the triangles to be wound correctly, which would have to be sorted out in your modelling program.
Image Image Image
Gideon
Posts: 26
Joined: Sat Oct 25, 2008 11:28 am
Location: Russian
Contact:

Post by Gideon »

In the IrrEdit I have seen the same. Where the "face" function in IrrEdit? I did not found it.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Sorry i thought you were using irredit but you're not (or not in the screenshots anyway), it's not necessary to use irredit for this but you can do. it's in the materials tab of the node, bottom left when you have the correct node selected, scroll down a bit and there's a tick box to turn back face culling on or off.

In irrlicht though you can set it like this:

node->setMaterialFlag(video::EMF_BACKFACE_CULL, false);

I think that's the right enum, you might have to check the API if it doesn't compile!
Image Image Image
Gideon
Posts: 26
Joined: Sat Oct 25, 2008 11:28 am
Location: Russian
Contact:

Post by Gideon »

This is not work...
The compiler write me:
`EMF_BACKFACE_CULL' is not a member of `irr::video'
:(
Why?..8(
P.S. May be use in 3ds Max the Modyfi "Normal"?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

It's not working because you didn't read the last line of my post... :roll:
Image Image Image
Gideon
Posts: 26
Joined: Sat Oct 25, 2008 11:28 am
Location: Russian
Contact:

Post by Gideon »

Sorry, man. But I did not find in your post the answer on my qestion... :cry: Don't damage me, please... :roll:
I speak English very-very bad...=( What I must do?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Read the documentation/API to find out the correct enum to use. Maybe it's EMF_BACK_FACE_CULL.
Image Image Image
Gideon
Posts: 26
Joined: Sat Oct 25, 2008 11:28 am
Location: Russian
Contact:

Post by Gideon »

Thank's, man. I can complited my world and I very happy now=) Biiiigggest thank's! :P
Post Reply