I'm not sure if this is really a beginner topic or not, but since I'm not really experienced, I thought I'd post in beginners section just to be safe from ridicule.
I'm writing some practice applications and am having a blast. I'm wanting to build some neat game-apps (mostly just experimenting right now) and I do want to get some good game design in whatever I do. These are questions I have, and any answers would be great!
Question 1: Animation
Is it possible to export animations from 3ds Max? Also, how would this work? I've messed around with .obj files, and I can load in an object with textures into my application, but I am unsure how to do animation. Do I need some kind of bone system - or perhaps a bunch of .obj's with difference vertex positions for each frame? I prefer the vertex positions per frame, as the bone stuff seems like it might make the computer do a little more math than I'd like it to.
Question 2: Data Structure(s)
I'd like to make a RTS, which means I need a lot of "Units" (I'd likely make unit objects) and I'd like a lot of these, hundreds, maybe thousands. As you can tell, I have no grasp on what's feasible here, in terms of how it's usually done in games, so I'd like to know if I'm way off, or if there's a special way to do it.
In all honesty, I plan to have all units contained in a <vector> and loop through each one, progressing its state forward a frame (like walking, or attacking)
Question 3: Visual Studio - DLL's and .libs
I'm quite use to having a bunch of .h and .cpp files all in a project, and compiling the whole thing into an exe (with .obj's and png's in the same directory). Should I have bunches of my code put into a seperate file and export as DLL? I haven't done this before, so is there anything I need to know about this? (I think exporting a dll is pretty easy, just have to change a setting)
Question 4: Input to Logic
- Solved
Question 5: Mouse/screen coords to the 3d world
- Solved
Question 6: Mouse/screen projection is off
So I got the program to cast a ray from the mouse into the 3d world - However it's off by a few pixels, and this seems to occur in the actual 3d world.
The cyan-Hlighlighted square should be directly underneath the mouse.
Below I have drawn the mouse position into this screen capture of my program (because printscr doesnt copy the cursor)
As you can see it's off by a fair margain, but it's pretty damn close. I mean, I can use this program and it's quite nice, but the offset doesn't make any sense.
Here's the code to convert mouse coords into 3d world coords
vector3d GetOGLPos(int x, int y, float z)
{
GLint viewport[4]; // contains x, y, width and height
GLdouble modelview[16]; // modelview matrix information
GLdouble projection[16]; // projection matrix information
glGetIntegerv(GL_VIEWPORT, viewport);
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
glGetDoublev(GL_PROJECTION_MATRIX, projection);
GLfloat winX, winY, winZ;
GLdouble posX, posY, posZ;
winX = (GLdouble)x;
winY = (GLdouble)viewport[3] - (GLdouble)y;
winZ = (GLdouble)z;
gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);
return vector3d(posX, posY, posZ);
}
it's used like so:
// mousePosNear and mousePosFar are of type "vector3d"
mousePosNear = GetOGLPos(m_mouseX, m_mouseY, 0.0);
mousePosFar = GetOGLPos(m_mouseX, m_mouseY, 1.0);
I'm not sure if I should provide other details, such as the rayplane function that these values are used in. Let me know if you want that code aswell to help solve this
Question 7: Deciding what tiles to draw
Actually this problem seems like it should be relatively easier Since I already have the rayplane function done, but I can't figure out how to do this in 3d (the 3d math just does my head in)
I figured It would be something like casting a ray from each corner of the screen and getting the returned tile... and then I don't know what to do from there.