Magic Numbers? Reading Quake3Map Tutorial and Confused.

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
insidious611
Posts: 5
Joined: Wed Oct 24, 2012 6:23 am

Magic Numbers? Reading Quake3Map Tutorial and Confused.

Post by insidious611 »

So, I'm trying to learn Irrlicht in order to work on a game project me and an artist friend of mine came up with. I'm going through the tutorials, and I find the "Quake3Map" one particularly interesting because its exactly what I need at the moment, in that it will allow me to load a large, predefined map in a popular format and display it along with other objects, skyboxes, etc.

So, I take the tutorial and I code it, then I screw around with it. I've got it displaying a very simple BSP I created with a skydome in the "void" spaces. This was a simple matter of changing some file references around, researching how skydomes worked in Irrlicht, being surprised at how easy that was, and adding in a single line.

So, I have a working scene, yay! But, wait. The point of the tutorial is to familiarize me with what I'm doing, right? And I've figured it all out except for one line.

node->setPosition(core::vector3df(-1300,-144,-1249));

Now, in the tutorial, it says that this line "translates the level because Quake 3 BSPs are not modeled at 0,0,0". Fair enough, except for two things...

One, where do those very specific numbers come from? By which I mean, the vector, -1300 X, -144 Y, -1249 Z? This seems to be a case of what developers call "Magic numbers", where numbers are inserted into code and not explained, and nobody actually knows what they mean.

Two, Quake 3 BSPs are in fact modeled with an origin! And in fact, in my BSP the plane the player is standing on sits literally one "click" (in GTKRadiant) right below said origin.

And yet, somehow, if I remove that line I'm placed far far away from the actual map, in the middle of empty skydome. And if I look around with that line in, I'm right where I should be. Just above and in the center of a mostly flat plane.

So... for my sanity, and for my understanding of how the Irrlicht engine works...

Where the heck are those numbers coming from?
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: Magic Numbers? Reading Quake3Map Tutorial and Confused.

Post by greenya »

You can comment out that line and see the result on your own.
You know, the map is designed with 0,0,0 not in the center of the map where camera starts in the example.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Magic Numbers? Reading Quake3Map Tutorial and Confused.

Post by hybrid »

Yep, I think that at least the bsp we use is not modeled 'around' 0,0,0, but maybe just touching 0,0,0 at one corner. So in order to start somewhere inside the castle, you need to start elsewhere, or move the castle away. Maybe have a look at example 21, which handles the spawn points as well.
insidious611
Posts: 5
Joined: Wed Oct 24, 2012 6:23 am

Re: Magic Numbers? Reading Quake3Map Tutorial and Confused.

Post by insidious611 »

Okay, yeah, figured this one out by taking a quick look at the relevant bits of 21 and seeing that you can pull the origin/angle from a player entity. Useful!

Thanks for your help guys.

Now if only I could figure out how to do directional lighting on a Quake3 BSP without changing it to an EMT_SOLID and thus losing the precalculated point lights as well.

But thats an entirely different topic :P If I can't figure it out, I'll be back.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Magic Numbers? Reading Quake3Map Tutorial and Confused.

Post by hybrid »

We have a light-aware light-mapped material. So you could be able to change materials to that one and combine dynamic and pre-calculated light.
Post Reply