Thread: How Can I draw What I want?

  1. #16
    Registered User
    Join Date
    Sep 2008
    I don't understand why most of c/c++ programmer hates Java.
    Java is actually son of C , isn't it? With their combined strength we can make unbeatable application. Am I right?

    best regards,

  2. #17
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    To be fair, I don't know Java very well. But a lot of programmer thinks that "The language I know is the best, all others are Sh!t". This is similar to all other forms of motivating yourself why you choose something. A lot of people in the UK think that either Ford or Vauxhall is the only car you could ever own - because they have always been buying one of those two. I personally think that both brands produce some excellent cars, and other cars that are a bit not so great.

    Programming languages are often good at some things and not so good at other things.

    Java uses a bit more CPU to do the same work as a C or C++ program, particularly for non-library code (library code that is found to be really inefficient is often translated to C++ in the implementation).

    Both Java and C++ have similar concepts, but Java normally compiles to bytecode, rather than pure machine code. This is often less efficient, but you can also have Just-In-Time compilation that allows the code to be translated to pure machine code for that machine.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #18
    Registered User
    Join Date
    Sep 2008
    Excellent explanation

  4. #19
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    I don't understand why most of c/c++ programmer hates Java.
    The only time people get upset about a language is when another makes the claim that it will replace another. While this is true in some instances in most it is not. Each language usually has it's specific purpose and is exceptionally good at fulfilling it. For instance I would not want to do a pure Win32 GUI in C/C++. It's not that I don't know how but rather I don't want to when there is C#. One could argue for MFC and other libs but I personally use C# specifically for GUIs.

    Java has its place and although I've never used it I may in the future. However I would not make the claim, as some have tried, that Java is just as good at C/C++ for games. That is a load of hogwash. It's that type of mindset I think that sets people off on the wrong foot when it comes to this or that language.

    I think language debates are useless b/c if my company uses language A or B then I'm going to be using language A or B if I want to eat. I may prefer language C (no pun intended) but at work I will use A or B.

    And now back on track.

    I highly recommend Blender for 3D creating 3D models but be warned it is not a standard GUI. In fact it's a nightmare GUI for a very powerful program that is surprisingly easy to use and get good at. Blender is not nearly as good as 3D Studio Max but if you don't have a couple grand to spend on 3DS, Blender will do just fine. As has been mentioned Milkshape is also a good tool for modelling and I'll mention another called Wings 3D. I believe we have links to free 3D modelling software packages in one of our stickies.

    Math is important in 3D and 2D but not as important as it used to be since most of it is done for you. It is still important to understand what is going on albeit not as important to know how to derive the formulas you are using. No one derives a rotation matrix anymore, we just know that the Y rotation matrix works. Most of 3D is like that. IMO, the most important thing to study for 2D or 3D is vector mathematics and linear algebra. Calculus is also handy but again most of the hardcore calculus derivations have already been integrated into functions in just about every 3D and physics API available.

  5. #20
    Registered User
    Join Date
    Sep 2008
    I appreciate your thoughts about programming languages.
    thanks for information about maths and 3d softwares.
    Although Matrix and Vector are interesting to learn.I know some extent of them.

    But Should I need to know Trigonometry too? I doubt that as you said most of the mathemactics
    is done for us.

    best regards,

  6. #21
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Trig is important but if you remember this you will be ok:




    Arccos(x) = the angle whose cosine is x
    Arcsin(x) = the angle whose sine is x
    Arctan(x) = the angle whose tan is x

    Sin^-1 = Inverse sin (H/O)
    Cos^-1 = Inverse cos (H/A)
    Tan^-1 = Inverse tan (A/O)

    But more importantly these are important to know:

    Vector dot product
    • V1 dot V2 = (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z)
    • If dot < 0 then vectors are facing away from each other
    • If dot > 0 then vectors are facing each other
    • If dot == 0 then vectors are perpendicular to each other
    • Dot product is equal to the cosine of the angle between vectors v1 and v2 provided that v1 and v2 are unit vectors.
    • Used for culling, physics calculation and just about everything you can imagine in 3D graphics. Dot product is one of the most important functions in 3D graphics. It can make a completely inefficient application very efficient when used correctly.
    • Dot product between light incident vector and normal of the triangle determines the brightness/darkness of the triangle surface. Used for cosine lighting equations also known as diffuse lighting.

    Vector cross product of vectors v1 and v2
    • v.x = v1->y * v2->z - v1->z * v2->y;
    • v.y = v1->z * v2->x - v1->x * v2->z;
    • v.z = v1->x * v2->y - v1->y * v2->x;
    • Cross product returns a vector perpendicular to v1 and v2. v1 and v2 should be unit vectors or the resulting vector v can be normalized after the cross product is performed.
    • Used to compute normals and to orient objects in 3D space
    • Also used to compute different force vectors in physics
    • Cross product of two unit vectors produces a normal which is very useful in lighting equations, collision detection, and collision response (angular response)

    In Direct3D:
    D3DXVECTOR3 v1(1.0f,0.0f,0.0f);
    D3DXVECTOR3 v2(0.0f,1.0f,0.0f);
    //Dot product
    float dot = D3DXVec3Dot(&v1,&v2);
    //Cross product
    D3DXVECTOR3 vecNormal;
    Example of cross product for rotating an object to face another object via an arbitrary axis.
    struct OrientationVectors
       D3DXVECTOR3 vecRight;
       D3DXVECTOR3 vecUp;
       D3DXVECTOR3 vecLook;
       D3DXVECTOR3 vecPos;
    OrientationVectors computeRotateToUpRightLook(const OrientationVectors &inVectors,D3DXVECTOR3 vecTargetPos)
       OrientationVectors returnVectors = inVectors;
       //Create vector to target object and normalize
       D3DXVECTOR3 toTarget = vecTargetPos - inVectors.vecPos;
       //Compute cosine of angle of rotation
       D3DXVECTOR3 normLook;
       float cosine_angle = D3DXVec3Dot(&normLook,&toTarget);
       //Compute rotation axis
       D3DXVECTOR3 vecRotationAxis;
       //Create axis-angle rotation matrix for rotation
       D3DXMATRIX matRot;
       //Transform orientation vectors by computed rotation matrix
       return returnVectors;
    This code will give you the final right, up and look vectors needed to face the target object. The game would then linear interpolate over time between the current right, up, and look vectors of the object and the ones just computed.

    So as you see most of the math is done for you and as long as you have a basic idea of what is going on you should be ok.
    Last edited by VirtualAce; 09-11-2008 at 01:09 AM.

  7. #22
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    I was in the boat of disliking java before I started Uni... I'm doing SE and they teach you java from day 1, and you pretty much use it until the end of your degree (and others!).

    Mainly because they used to use C up until 2 or so years ago, which isn't very good if you're trying to teach OO design with C (infact they don't really even teach classical SE in much depth at my uni anymore...)

    Now after having used Java (by force too!) for almost an entire year, day in day out... I'd say it's rather nice, giving a simple (read: simple) 3D engine a go in Java -- I already did one in C. So far, my research has led me to: The main bottleneck will be calling JNI (Java Native Interface) methods, such as the OpenGL binding, which is a big downside since this will be done a lot.

    If I knew C++, I probably wouldn't be using Java -- I can however read C++. Not sure how well I could write it... as far as templates, namespaces, op overloading etc goes (hard if you don't know the exact syntax). I'm hoping that keeping my hand in C and Java will mean I should be able to pick up C++ fairly easy, while holding onto my knowledge of C & Java...

    Inshort, my rant was: I don't hate Java, I like it infact. Sure it's got it's downfalls, and is a bit too managed at times (there are no class destructors for example). But my goodness, it's sometimes so fast and fun to not worry about memory allocation/deallocation!
    A list of perhaps why Java will never be "better" than C++ for games
    * Late binding (at runtime) = slow
    * JNI calls are always going to be slower than C++ calls to libraries/DLLs
    * The java compiler (at least suns compiler) is poor in optimizing in comparison to say gcc/g++

    But it does offer, jit compiling so it can sometimes be faster than C++ in (very) limited circumstances.
    Last edited by zacs7; 09-11-2008 at 01:22 AM.

  8. #23
    Registered User
    Join Date
    Sep 2008
    Oh! Mine , Bubba you are monster but the good one.
    your last reply worth $100,000 ,I am really ecstatic.

    thanks for your reply zacs.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Which is the better way to draw?
    By g4j31a5 in forum Game Programming
    Replies: 16
    Last Post: 01-22-2007, 11:56 PM
  2. draw function HELP!!!
    By sunoflight77 in forum C++ Programming
    Replies: 1
    Last Post: 05-10-2005, 11:28 PM
  3. ray casting
    By lambs4 in forum Game Programming
    Replies: 62
    Last Post: 01-09-2003, 06:57 PM
  4. draw to a BITMAP* argument - allegro and objects again
    By MadHatter in forum Game Programming
    Replies: 13
    Last Post: 12-13-2002, 06:51 AM
  5. Draw Shapes.
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 08-19-2002, 09:22 AM