It's me again :(
This is were I am blocked, the other objects in my scene are "moving"
regarding the position of the camera and not the position of the player
Below I break down how I perform the transformations:
Transformation for the camera:
cameraMat = mat4.translation(vec3(0.0, -3.0, -10.0))
Initial transformation for the player ship:
playerFM = FlightModel(mat4.identity())
The class FlightModel as the name implied allows to define all the
transformation to apply so that the player ship is "moving" correctly.
Initial transformation of the other object of the scene:
redShipMat = mat4.translation(vec3(5.0, 0.0, -10.0))
redShipMat = redShipMat * cameraMat
In the main loop of pygame:
# Rendering of the player ship
# Rendering of the other object
#Capturing input from the user
# Below is the computation of the transformation to be applied to
the other object of the scene
redShipMat = playerFM.getMat4(time_passed) * redShipMat
Here is the code of the method getMat4():
def getMat4(self, time_elapsed):
mat_tmp = mat4.translation(vec3(0.0, 0.0, -self.__thrust *
mat_tmp = mat_tmp.rotate(math.radians(self.__xAngle *
time_elapsed), vec3(1.0, 0.0, 0.0)).inverse()
mat_tmp = mat_tmp.rotate(math.radians(self.__yAngle *
time_elapsed), vec3(0.0, 1.0, 0.0)).inverse()
self.__xAngle = 0.0
self.__yAngle = 0.0
From my point of view, the camera should be located at (0.0, 3.0, 10.0)
and the player ship at the origin, but if I set those coordinates for
the camera matrix, the ship is not visible because its the player ship
that move and not the camera.
What I am missing?
Le 09/14/10 00:18, Matthias Baas a écrit :
> Hi Roland,
> On 11.09.10 21:59, Roland Everaert wrote:
>> I have the feeling that the player ship should be the "center of the
>> universe" and that everything should move around it, but I am not sure
>> it is the way I should think how to move the camera and I don't really
>> know how to do it.
> Well, instead of transforming your ship, you would just apply the
> inverse transformation to the world (if your ship moves up it's as if
> the world around it moves down instead).
>> Now that I can make an object moves using matrix, what would be the
>> advantage of using quaternions?
> If everything works as expected now, I would say, you don't have to
> bother using quaternions for this project.
> In general, quaternions have an advantage when you want to interpolate
> orientations because they allow a smooth interpolation whereas just
> interpolating angles often produces undesirable motions.
>> I have seen one or two typo in the online documentation of cgkit, to
>> whom should I report those errors?
> You can just mail them to me.
>> When I will get a grasp on how to use the package, I was thinking about
>> writing some tutorials showing how to integrate cgkit with pygame, to
>> whom should I submit them and in which format?
> Again, just send them to me. About the format, have a look into the
> source archive, they are written in restructured text and converted
> using the docutils. But actually, I'd like to change that somewhat as
> I'm having some problems recreating them at the moment. I'm not sure if
> I'll either switch to Sphinx (like the manual) or just use the wiki.
> - Matthias -
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> cgkit-user mailing list