When to start 3D Game Programming?

This is a discussion on When to start 3D Game Programming? within the Game Programming forums, part of the General Programming Boards category; Here's a screenshot of my 3D maze so far. http://img4.imageshack.us/img4/2417/crazykzd.jpg I get confused sometimes creating the wall in 3D. Do ...

  1. #31
    Registered User
    Join Date
    Dec 2008
    Location
    California
    Posts
    37

    screenshot 3D maze

    Here's a screenshot of my 3D maze so far.

    http://img4.imageshack.us/img4/2417/crazykzd.jpg

    I get confused sometimes creating the wall in 3D. Do I need to draw the 3D first in a graph paper? Do graphics programmer do that?

    By the way, I didn't apply any linear algebra here. I don't know how to apply it here in opengl. I hope someone will teach where to use it.

  2. #32
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    I believe it is always good to try to visualize something on paper or such if you can't do it in your head.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #33
    Registered User
    Join Date
    Dec 2008
    Location
    California
    Posts
    37
    I can visualize everything if it's only x and y axis but when the z axis is included, it really burns my brain. rofl. I'll try to draw it on a piece of paper for now. Maybe I'll get used to this someday, I hope.

  4. #34
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Imagine viewing the maze from the top. Then it's quite easy. There is a third axis, being Y, but it's always a wall of the same height.
    But you're coming along well. I'd say, when you're able to render the walls, do this:
    - Collision detection. Not an advanced algorithm, just easily checking whether a move would cross a wall or comet too close to a wall.
    - Lighting. Not even required for this game, but it will teach you a lot when you find out how it works.

  5. #35
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    For giving sound advice?
    It comes down to the age old dilemma of a debate becoming a personal attack. Regardless of our horribly poor examples in society around the world where opposing opinions tend to be squashed, ridiculed, or ignored there is actually a proven sound way to debate an issue and/or give advice without becoming personal.

    If you were wanting to create your own retail game as in the context of an upstart company then you would definitely want to get a license for an existing engine. You would do this so you could get the product done and out the door and start making money on it. However I would imagine that every employee or at least every employee on the core game dev team would understand how to go about creating their own engine. It really would come down to the cost of the engine vs the cost of the development of an internally developed game engine.

    Now if you are a hobbyist programmer and do not ever intend or think it possible to release your game and are only trying to learn then I say roll your own. It is highly probable that those who come here and ask questions about game dev either do not know enough to create the game and/or do not truly understand the concepts behind the graphics engines. Therefore recommending an existing engine to them would only serve to confuse and confound and thus discourage their attempts.

    So in short:

    Hobby and want to learn more: Roll your own.
    Hobby and understand most of the fundamentals: Use an existing engine
    Professional: Based on cost you can either choose to develop an in-house solution or you can use an existing third party solution.

  6. #36
    Registered User
    Join Date
    Dec 2008
    Location
    California
    Posts
    37
    Hello gurus,

    Here's the 3D maze screenshot so far.

    Nothing special
    http://img9.imageshack.us/img9/3136/boredjbp.jpg

    I somehow improve visualizing shapes in 3D now.

    -x = left
    +x = right
    -y = down
    +y = up
    -z = back
    +z = forward

    Cool. I can now create simple shapes. How about a teapot? lol

    Weird Lighting
    http://img6.imageshack.us/img6/6625/lightingh.jpg

    I'm playing around with the glNormal3f for lighting though. I still can't get it work correctly with multiple triangles. I think I did something wrong.

    Blending
    http://img9.imageshack.us/img9/3227/blendk.jpg

    I tried playing around with the glColor4f(); and glBlendFunc(); but still don't get why the ceiling and the floor is not affected. Did I do something wrong?

    For the Collision detection: It just check if the camera is too close the wall. So I somehow make it work on the borders by using few if and else but still can't get it work with multiple maze. But I'm trying... really. lol

  7. #37
    Registered User
    Join Date
    May 2007
    Posts
    147
    Hey m3rk:

    In an earlier post in this thread you asked if programmers put graphics designs on paper.

    No, not in many, many years. We will usually work with art departments.

    However, in the earlier days, even then, one of the first common themes was to use the basic game engine to create simple modeling tools. That way you can place walls, doors and other objects in the scene with much less effort.

    These days, though, I usually use 3DS Studio Max or Blender (the latter can be downloaded while the former is expensive), and Blender is quite good.

    You also said:

    "But I'm trying... really. lol"

    Ok, then you should do yourself a favor and pick up a good text on the subject.

    Frankly, I found that a book published by Morgan Kaufmann called "Mobile 3D Graphics", which is primarily aimed at OpenGL ES, was an excellent ground up discussion of nearly everything important. I think 95% or more of the code examples work in OpenGL 1.5.

    Other books in the Morgan Kaufmann series are good, and many are quite in depth.

    I think you deserve to have the benefit of a well guided path through the study. It will be much smoother, and faster, with better foundations of how things really should be done.

    Even if you're just browsing the subject, instead of serious study, it all makes much more sense from a really good book on the subject, and not an old one, because OpenGL has been through several versions, and there are more than one way to accomplish the same thing, many of which are now no longer used because significantly better methods have been implemented in OpenGL.

    Especially due to the mobile use of OpenGL ES, and it's basis on pre-2.0 versions of OpenGL, it is still worth studying a bit of the old and then the new versions of OpenGL, if your targets may need to be compatible with modest hardware.

  8. #38
    Registered User
    Join Date
    Dec 2008
    Location
    California
    Posts
    37
    @JVene

    I though graphics programmer are like engineers/architect, lol.

    Yeah, I'm creating a md2 loader for my program right now and I don't know what data structure to use. See this link (Data Structure to store unlimited dynamic vectors)

    I didn't finish all the collision for all the maze but it works on the end of the map.

    I dumped the immediate mode(ie glBegin, glEnd and etc) and studying the advance like using buffers to squeeze more frame rate. I think I'll just focus first in advanced 3D concept and later the collision.

    BTW, I bought the book beginning opengl game programming and it's quite good. But I need a more advance book because most of the concept there are immediate mode.

  9. #39
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    I'd say you should start 3D programming the 32/13/1337 ... Not funny xP
    Anyways, try using some 3D engine and see how stuff is done there? I mean a completed game engine, like the Source engine or Unreal Engine (Ain't sure if Unreal Engine starts as a finished product tho...)
    Currently research OpenGL

  10. #40
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by m3rk View Post
    By the way, I didn't apply any linear algebra here. I don't know how to apply it here in opengl. I hope someone will teach where to use it.
    Maybe it could be applied to the program flow, ie. how the game operates, since that actually has nothing to do with GL.

    IMO, w/r/t rendering & such, trying to apply your knowledge of formal math may not be necessary or even helpful. I think this is because the conceptual reality of a 3D engine is different than that of a math lab (not to "denigrate" either one).

    Here's a story to illustrate my point: I'm a total novice with openGL. The other day I was writing a function to create a non-curved cylindrical object with any number of sides (eg, something that might look like a symmetrical skyscraper with 6 or 7 sides). I was using quads to do this and couldn't get the length of a side (pictured orthographically from the top, such a cylinder would be a "regular polygon") to work out, so basically the sides were two long ("length" in relation to the orthographic top view, not the tower height, so in sense the "width" of a side). I was using the diameter of the cylinder as a function parameter, and I figured there must be a formula to determine how long a side should be in relation to the diameter of a regular polygon*. I learned there are actually (at least) several such formulas, only one of which is a straight-forward enough equation to be implemented in one line in a C program. When I did it, however, the sides were still a little bit too long. Finally I gave up on algebra and just figured I should divide 360 by the number of sides, rotate, translate the length of the side (so I changed the function parameter to that, instead of the diameter), and draw the side, which works. You (or at least I) might think after reviewing the algebra of regular polygons that somehow 180*(sides/2) is involved, but even that is not. This is what I mean by the different conceptual setting.

    It could be that using an equation may be more optimized which is super important with 3D games, but since the GL functions should already be optimized, it is not necessarily so. For example, trigonometry is elegant, but I see no reason to believe that a couple of sinf/cosf calls are less expensive than a single glRotate. The only problem is you cannot call glRotate between glEnd and glBegin, whereas you can use math lib functions as much as you want.

    RE: Surface Normals What do you think is weird about the lighting in your "weird lighting"? It looks like the roof maybe "unlit". How are you determining the normals? If you are using a function like this one:
    Code:
    void setnormal (vect P1, vect P2, vect P3) {  /* from openGL wiki pseudo-code */
            vect U,V;
            vectminus(P2,P1,U);    
            vectminus(P3,P1,V);
            Normal[0]=(U[1]*V[2])-(U[2]*V[1]);
            Normal[1]=(U[2]*V[0])-(U[0]*V[2]);
            Normal[2]=(U[0]*V[1])-(U[1]*V[0]);
    }
    which I think is kind of a standard thing that accepts three points on the surface, I've noticed that the order of those three points can reverse the normal, making a supposedly lit surface unlit except for ambiance. ("Normal" in this is just a global variable used with calls to glNormal3fv(), since there is no need to keep more than one at a time anyway).


    *Of course, there are TWO obvious ways to measure the diameter, corner to corner or side to side. That may be where I went wrong....
    Last edited by MK27; 04-22-2009 at 09:45 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  11. #41
    Registered User
    Join Date
    May 2007
    Posts
    147
    Careful mk27

    Please don't take my reply to your points negatively, I hope to advance the discussion from the viewpoint of experience in the field.

    I agree with part of the general thrust of you point, and I would put it this way; as programmers, we're consumers of math, not mathematicians.

    However, the more one understands linear algebra, or the calculus (when it comes to a physics engine), the better of we are at choosing a method.

    Let me take the point about glRotate as an example. A call to glRotate is a simple means of applying a rotation to the current transformation matrix. It is usually implemented in the client, meaning that the math is executed in the CPU, though in theory an implementation could choose to accelerate that in the GPU, I'm not aware of many implementations that do.

    The call is performed by creating a matrix representing the rotation you're performing, the multiplying that matrix by the current matrix (one could think of that as applying that rotation to the matrix).

    The usual implication is that a typical 4x4 matrix by matrix multiplication is performed. However, if you understand that the rotation matrix is 3x3 (upper left portion of the 4x4), and if you know that your rotation is the first one, you can simply drop the appropriate values into the correct positions as part of filling out an identity matrix, making a considerable performance optimization, if this is something performed in a critical interior loop. Whereas a typical OpenGL sequence might be to call glLoadIdentity, then call glRotate, and then likely a glTranslate - implying two 4x4 matrix multiplications - setting up a matrix according to knowledge of linear algebra (that is, knowing how the matrix is layed out) means you can avoid any matrix multiplication of a simple series like this, greatly improving performance.

    ("Normal" in this is just a global variable used with calls to glNormal3fv(), since there is no need to keep more than one at a time anyway).
    I'm not sure what you mean by this, so I'm setting it aside and describing what is typically done with normals, just in case this ends up misleading the OP, or you.

    Generally, at least in modern OpenGL, normals are supplied in interleaved buffers, and there's one per vertex. It is a good choice to prefer this to calling glNormal3fv because the data is sent to the graphics RAM much faster.

    Models usually have a normal per vertex, which is why I'm not sure what you mean by a global variable for use with calls to glNormal3fv.

  12. #42
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Creating a cylinder is not rocket science so I'm not sure how all of that applies to the discussion.

    A cylinder is just two connected approximations of a circle. So if you approximate the caps and then connect the edges of the caps then you have the cylinder.

    It's not a bad thing to understand the math underneath the hood even if most of it is done for you. The optimized approach however can only be found when one understand the mathematical concepts. There are moments in 3D where what is done for you is just not enough or doesn't quite take you far enough. From then on you must synthesize a solution based on what you know and what your research yields. No engine is game maker 101 and people who believe this will find themselves sorely wanting if they try to use an engine without understanding at least the basic math that is involved. As well an engine a game does not make. The engine is the tool that renders and updates all the objects. The game is much more than all that.
    Last edited by VirtualAce; 04-22-2009 at 04:36 PM.

  13. #43
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by JVene View Post
    However, the more one understands linear algebra, or the calculus (when it comes to a physics engine), the better of we are at choosing a method.

    Let me take the point about glRotate as an example.
    Hey, I have no doubt about that, and would never have implied otherwise. Your example and opinion about performance seems sound (thanks). Witness, though, that what you are saying does not mean actually implementing any algebra in code: what it really means is doing some algebra and applying the results. I was just trying to warn the OP against a pitfall: while s/he is there at school learning programming and math, I imagine there's a no end of opportunities to solve the problems of the one with the other. And that's great; but I don't think anyone should de facto assume that to be the best or most optimal solution -- even if it usually is.

    I really really am not interested in being the "anti-math" guy, so I will just leave it at that. I seem to recall from school that these arguments about the "theoretical" vs. the "applied" quickly become tedious if not ridiculous.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Game Of Life 3D
    By blackslither in forum C Programming
    Replies: 8
    Last Post: 11-02-2008, 02:30 PM
  2. Were to Start Your Game Programming Carrer
    By C+noob in forum Game Programming
    Replies: 3
    Last Post: 07-14-2005, 01:33 AM
  3. How to start a game...?
    By TaraTheCasper in forum Game Programming
    Replies: 30
    Last Post: 10-24-2004, 09:20 PM
  4. 3d game
    By cgod in forum C++ Programming
    Replies: 10
    Last Post: 10-21-2004, 06:06 AM
  5. Need some help with a basic tic tac toe game
    By darkshadow in forum C Programming
    Replies: 1
    Last Post: 05-12-2002, 04:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21