First off, let me just state that C++ is *not* a problem for me, so if you feel you can contribute, feel free to do so - I\'m not a beginner in that regard...
Next, let me explain the scenario:
I\'m planning on submitting an entry into the competition thread that\'s due by April 30th (
http://forum.thegamecreators.com/?m=forum_view&t=167521&b=22). My approach is to use 3D (mainly to help me understand 3D) as a 2D platform for the side-scroller effect.
I plan on using characters from the Dark-Matter media installed as a part of GDK (i believe they\'re a part of GDK anyways - I bought the DarkGame Studio package so I\'m not sure if it includes the same media or not). In fact, all of my characters in the game come from Dark-Matter (except for the main character - as I\'ve yet to find a blob of ooze that can transform into a shield, boot, glove or spring [or any animated blob of ooze for that matter] online, I\'ve got to substitute concept drawings for the main-character).
But, I digress...
Anywho... I want to place all characters on one z-plane (to aide in collisions - I can handle collisions btw), back drop props on other z-planes and the camera on a z-plane parallel to the action. The camera will focus on a point and only move to another *if* the main character breaches the radius of a pre-determined circle of view (note this will be an inner-circle of view to allow the character to move freely within the screen-space). I do understand the math involved in determining when the camera should move (simple sphere/circle intersection tests (or circle/circle tests in 2D parlance) would suffice - i think) and so that\'s not the problem...
Instead, my problem is this...
How do I place objects, all on the same z-plane, on the screen? Note, this is a scroller so I expect the camera to move from time to time. However, my thinking is (and maybe this is where I\'m wrong) since everything should be parallel on z-planes, all equations should degrade to 2D calculations. Am I wrong about this?
In short, I am asking this...
If all *objects* are to be located on the same Z-plane (or further from the camera), how do I place them on the screen? That is, assuming for instance the z-plane is -100, with a screen dimension of 1024 x 768 (60-degree field of view); where do I place an object x so that the camera can see it plus the proverbial radius of the far end of the view cone? Additionally, where do I place the camera? More importantly, how do I determine these locations?
The Old Proverb: \"Give a man a meal, and you\'ve fed him for a day; teach the man to fish, and you feed him for a life-time\" comes to play here. I\'m not looking for the meal, I\'m looking to learn how to fish!
Please, help me understand 3D, I\'ve been trying for going on 8-years now and everyone says \"imagine the camera is fixed, the world revolves around the camera\". Ok! I get it, everything else moves, not the camera; I understand that; but I don\'t understand *why* that\'s so - nor do I understand *how* to make everything else move...
As everyone here, including myslelf, would prefer to see code; here\'s some code that don\'t work for me... Why? What am I missing?
void DarkGDK ( void )
{
// in this application we are going to create some 3D objects
// and position them on screen
// when starting a Dark GDK program it is useful to set global
// application properties, we begin by turning the sync rate on,
// this means we control when the screen is updated, we also set
// the maximum rate to 60 which means the maximum frame rate will
// be set at 60 frames per second
dbSyncOn();
dbSyncRate(60);
dbSetDisplayMode( 1280, 800, 32 );
//dbSetWindowOff();
// move our camera back so we can view the objects
dbPositionCamera ( 0,0,100 );
dbPointCamera( 512, 384, 0 );
dbRandomize(dbTimer());
CKeyboard keyboard;
CMouse mouse;
CLitterBug_Babe mObject[10];
for (int a=0;a<10;a++) {
float x,y,z;
x=(float)dbRnd(1024);
y=(float)dbRnd(768);
z=0.0f;
mObject[a].SetPosition( x, y, z );
mObject[a].SetAnimationSpeed(40);
mObject[a].SetScale(40,40,40);
mObject[a].RotateY((float) dbRnd(359));
mObject[a].LoopAnimation();
mObject[a].Show();
mObject[a].SetCurrentObject(dbRND(IMPACT)+1);
}
while ( LoopGDK ( ) ) {
{
keyboard.Poll();
mouse.Poll();
// here we make a call to update the contents of the screen
dbSync ( );
}
}
Why does this not work since the calls to mObject[x].XXXXXX essentially calls the GDK equivalents? I\'ve narrowed it down to my understanding of 3D... Remove the x,y,z variables and SetPosition() and it works fine!
Again, I plead, please help me!
JTK