Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 Apr 2013
Offline Last Active Yesterday, 07:13 PM

Posts I've Made

In Topic: Basic Jumping and Gravity Implementation

17 April 2013 - 09:47 AM

I don't quite understand why you were bothered...


1) when user hit jump button, you can simply give velocity a positive y value, and everything else remains the same. 


2) I think you don't need to clamp velocity.y, but need to check for position.y so if you hit ground then velocity.y should be set to zero.


Do I understand your question correctly or completely wrong?

In Topic: Texture Mapping

17 April 2013 - 09:34 AM

1. the reason you can't display both texture is the following:

In each frame, you set the model view matrix to identity, which maps the whole viewport to [-1,1]x[-1,1].

And both of your calls to Render() draw the quad covering [-1,1]x[-1,1].

So now you load first texture and draw a quad, the texture will be mapped to whole viewport,

then you load the second texture and draw a quad, which is also mapped to the whole viewport (so the second one overlaps the first one).

Thus you can only see one texture.


2. As for the texture size,

1) because you model view matrix is identity,

2) and you quad covers the whole viewport,

3) your texture coordinates cover the whole image

so you always see the texture as big as your viewport, right?

You can change any of 1)~3), for example, change from Render(1,1,0) to Render(0.5,0.5,0), then the texture would be come 1/4 of the original size

[ if you choose 3), you may also need to change the wrap options ]


Hope this helps

In Topic: Object detection

10 April 2013 - 06:22 AM

You could implement a class defining the type for your object classes like this:

class ObjectType



     ObjectType(const std::string& n)




     const std::string& GetTypeName()const { return name;}



     std::string name;



Then for each of your object class, you do something like this:

// MyObject.h

class MyObject



     const static ObjectType type;



//  MyObject.cpp

const MyObject::ObjectType type("MyObject");


Now you can query your object type and respond to it:

if(myObject.type.GetTypeName() == "MyObject") {

// do something

} else if(...) {

// do something else


In Topic: Problem with Arcball/Trackball implementation using SDL + Opengl

05 April 2013 - 06:28 PM

I haven't known much about quaternions yet, but it seems that something is wrong with your rotation matrix multiplication:


      ball_new = ball_old * ball;

     ball_old = ball;


     ball_new = ball * ball_old;

     ball_old = ball_new; ?


Since we are concatenating the newly constructed rotation to the accumulated rotation so far. 

(Seems ball_new is the accumulative rotation matrix)