Remove quake map. Add terrain and models.

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
Mircea Popescu
Posts: 26
Joined: Sat Jan 02, 2010 12:48 pm

Remove quake map. Add terrain and models.

Post by Mircea Popescu »

So basically, I've been playing around with the supplied demo, and I've managed to accomplish a few things. However, there's a few things that I can't do and are driving me nuts.

1) Remove the quake map. That's right. The demo loads a bsp file, which is a pre-light terrain+object mesh. I want to remove this from the demo. If I comment out the
quakeLevelMesh = (scene::IQ3LevelMesh*) sm->getMesh("maps/20kdm2.bsp");
line, the demo starts normally, there's no terrain or castle loaded (as you'd expect), but the fireball shooting doesn't work anymore (pressing space or clicking mouse does nothing. No sound, no graphics). I can't for the life of me figure out why.

2) Add coordinates to the infobox. Currently there's a

Code: Select all

			swprintf(tmp, 255, L"%ls fps:%3d triangles:%0.3f mio",
								driver->getName(),
								driver->getFPS(),
								(f32) driver->getPrimitiveCountDrawn( 1 ) * ( 1.f / 1000000.f )
);
that runs just before device->drop, which prints on screen some basic data (driver, fps, triangles). I want to add the coordinates position to this. I try loading it via

Code: Select all

core::vector3df camPosTest = smgr->getActiveCamera()->getAbsolutePosition();
which makes the program crash. I don't comprehend why, but I've tested it extensively.

3) Add a terrain. Like for instance something like this :

Code: Select all

scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(path+"terrain.bmp",
                0,                                      // parent node
                -1,                                     // node id
                core::vector3df(0.f, 0.f, 0.f),         // position
                core::vector3df(0.f, 0.f, 0.f),         // rotation
                core::vector3df(1.f, 1.f, 1.f),      // scale
                video::SColor ( 255, 255, 255, 255 ),   // vertexColor
                5,                                      // maxLOD
                scene::ETPS_17,                         // patchSize
               8                                       // smoothFactor
                );
        terrain->setMaterialFlag(video::EMF_LIGHTING, true);
        terrain->setMaterialTexture(0,
                        driver->getTexture(path+"texture.jpg"));
        terrain->setMaterialTexture(1,
                        driver->getTexture(path+"details.png"));
        terrain->setMaterialType(video::EMT_DETAIL_MAP);
        terrain->scaleTexture(1.0f,20.0f);
        terrain->setMaterialTexture(2,
                        driver->getTexture(path+"lightmap.jpg"));
Nothing too fancy. No matter where I place this (either in the sm or the smgr scene managers, - I still haven't comprehended why there's two of them running) the system crashes. I don't mean the program crashes, I mean the system does, I have to do a cold reboot, obviously I can't read any of the debug stack (not that it does me any good in the other cases) etc. I live in fear of this insane frozen death by now.

4) Add an object. Even if you don't have a terrain, you should be able in principle to load an extra object. Or so I'd think. Something like

Code: Select all

scene::IMesh*           newtowerm;
scene::IMeshSceneNode*          newtower;


newtowerm =smgr->getMesh("newtower.x");
newtower = smgr->addOctTreeSceneNode(newtowerm);
             newtower->setPosition(core::vector3df(70,35,510));
             newtower->setRotation(core::vector3df(0,30,0));
             newtower->setMaterialFlag(video::EMF_LIGHTING, true);
crashes the program.

I've been working for a few days trying to grasp what I'm doing wrong with all these, but I'm not getting very far. I'm pretty well convinced by now it's ridiculously obvious stuff that I'll notice on my own probably in 2011, so if somebody would take the time to point it out it'd be much appreciated. Thanks.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I'd bet some money on a broken memory bank or overheated gfx card. Maybe it's the CPU, who knows. But system freezes are not programatically executable, it just happens because some hardware (or in seldom cases a system driver) is broken. Go fix your system.
Mircea Popescu
Posts: 26
Joined: Sat Jan 02, 2010 12:48 pm

Post by Mircea Popescu »

I would very much like to believe it's the hardware, or the drivers, but the problem is I've been able to reproduce this on three different systems.

It's my "code", if you can call it that.
Mircea Popescu
Posts: 26
Joined: Sat Jan 02, 2010 12:48 pm

Post by Mircea Popescu »

Ok, I'm pleased to report that I've made some headway.

Point 4 above is due to nothing else than the expectation of the executable to actually find tower.x and the other referenced files SOMEWHERE. :oops: All in all not exactly unreasonable on its part.
Mircea Popescu
Posts: 26
Joined: Sat Jan 02, 2010 12:48 pm

Post by Mircea Popescu »

When it starts, it pours. Let me tell you I fixed problem 3 too.

Prepare to be amused :

Code: Select all

scene::ITerrainSceneNode* terrain = sm->addTerrainSceneNode(path+"terrain.bmp",[...]
should really be, at least if we're writing in C,

Code: Select all

terrain = (scene::ITerrainSceneNode*) sm->addTerrainSceneNode(patth+"terrain.bmp",[...]
No, I have no idea what I was thinking, either. But anyway, now it works just fine, and so point 3) is also resolved.

(On a side note, do try the first snippet of code within the cdemo.cpp, I'm curious what it does on your machine. While I fully agree with hybrid that freezes shouldn't, at least in principle, be programatically reproducible, I have like a hunch this one is, at least on XP.)

Cheers. Coding is still fun after all these years.
m3ltd0wn
Posts: 107
Joined: Wed Dec 12, 2007 8:32 am
Location: Romania

reply

Post by m3ltd0wn »

for the cam pos
core::vector3df camPosTest = smgr->getActiveCamera()->getAbsolutePosition();
to display the coords you'll need something like this:

f32 camX,camY,camZ

camX = camera->getAbsolutePosition().X;
camY = camera->getAbsolutePosition().Y;
camZ = camera->getAbsolutePosition().Z;

then use camX, camY, camZ to display the coords ;)

Salut ;)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

example 9 also has this, press F1 when wlaking through the scene with the FPS cam
Mircea Popescu
Posts: 26
Joined: Sat Jan 02, 2010 12:48 pm

Post by Mircea Popescu »

Ahh, that's very helpful, thank you both!

Pretty much the only problem remaining is why does the fireball go away. I'm going to look into it in between hammering on raknet to get it to play nice with irrlicht.

There's a pre-alpha package available if you feel like checking it out, by the way (in signature).

Cheers!
Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you don't get a response from the collision test (which is the case when you have no level mesh) there's no ball being fired. Just look up the code :!:
Mircea Popescu
Posts: 26
Joined: Sat Jan 02, 2010 12:48 pm

Post by Mircea Popescu »

Ahh, right you are! Thanks hybrid :)
Image
Post Reply