The ship now rotates well to the right direction so i can implement a "seek and destroy" behaviour: the enemy ship follows me and tries to reach me despite of my movements.
It's not perfect but.. it works
Wednesday, December 14, 2011
Monday, December 5, 2011
Alignment
In my few spare time i've tried to consolidate one big task that i wasn't able to finish in the previous years: a way to align, softly, an object to any direction.
I need this for a lot of different situation: my ship has to align to the station, when i activate the autopilot, an enemy ship has to align to my position for reach me, an homing missile has to follow my target, and so on.
Previously i tried to solve it using normal euler rotations but it was a mess, and i've left this way.
The solution is: quaternions and SLERP.
It's not my intention to boring you with maths details (but you can ask me if you want), i prefer to show you the result: a ship floating into space try to align with my position:
you can notice that when i move, the ship follows me, in all positions.. also when i go up or down.
..and you can see also (for a brief moment) my ship firing a laser :)
I need this for a lot of different situation: my ship has to align to the station, when i activate the autopilot, an enemy ship has to align to my position for reach me, an homing missile has to follow my target, and so on.
Previously i tried to solve it using normal euler rotations but it was a mess, and i've left this way.
The solution is: quaternions and SLERP.
It's not my intention to boring you with maths details (but you can ask me if you want), i prefer to show you the result: a ship floating into space try to align with my position:
you can notice that when i move, the ship follows me, in all positions.. also when i go up or down.
..and you can see also (for a brief moment) my ship firing a laser :)
Thursday, October 6, 2011
Slowly...
Work, healt and other things are against me & tau ceti so no more news since june.
But no news is not no progress...
In these periods i've worked for improve the consistency of the engine.
Here the most important news
- Now coordinates of the universe are the same of the 3d engine. This means that i cannot use anymore realistic large scale for the universe, but i've seen that the "real thing" is for now too big (and boring). To reach a planet from another you needs lots of minutes, and i'm developing a game, not a simulator. The pros are that now shadows are more accurate.
- The internal structure of the object now is totally hierarchical, so Sun has 9 child, one of this is Earth. Earth has one child, Moon. Moon has one child: Space station (i.e.). If i move the Sun, i move also earth/moon/station automatically.
- I've started to update the look'n'feel of the gui.
- Now your starship can shoot, and i've implemented the collision detection. So if you hit another ship with your beam, the program can tell you "boom" and give the distance of the collision. It works also with complex object, and not unsing only AABB (bounding box) but with geometry.. so if you shoot at the center of a torus, the function return "false".
- You can attach a camera to any ship, so in future you'll be able to say the point of view of a enemy.
- Space station now has a (primitive) tunnel to help you in landing operations.
- LOTS of cleaning up.
But no news is not no progress...
In these periods i've worked for improve the consistency of the engine.
Here the most important news
- Now coordinates of the universe are the same of the 3d engine. This means that i cannot use anymore realistic large scale for the universe, but i've seen that the "real thing" is for now too big (and boring). To reach a planet from another you needs lots of minutes, and i'm developing a game, not a simulator. The pros are that now shadows are more accurate.
- The internal structure of the object now is totally hierarchical, so Sun has 9 child, one of this is Earth. Earth has one child, Moon. Moon has one child: Space station (i.e.). If i move the Sun, i move also earth/moon/station automatically.
- I've started to update the look'n'feel of the gui.
- Now your starship can shoot, and i've implemented the collision detection. So if you hit another ship with your beam, the program can tell you "boom" and give the distance of the collision. It works also with complex object, and not unsing only AABB (bounding box) but with geometry.. so if you shoot at the center of a torus, the function return "false".
- You can attach a camera to any ship, so in future you'll be able to say the point of view of a enemy.
- Space station now has a (primitive) tunnel to help you in landing operations.
- LOTS of cleaning up.
Tuesday, June 14, 2011
System Map again
I've work a little inside the map's code and now the system map is more usable.
- You can see the Sun! In the previous video it was missing ;)
- Every moon now is displayed with it's own orbit (in the video, you can see our moon)
- Now there's also your ship position showed.
- With the mouse wheel you can zoom in/out the map, with the right button you can rotate it, and with the left button you can translate your view position inside the map.
- The map has his own GUI, for now only + and - button. When you switch from cockpit view to map view, also the GUI switches.
- Planets are smaller than into the previous video.
Next step is to made the map interactive: when you left click on a planet, the camera points on it and the target for autopilot is setted.
Monday, June 6, 2011
June 2011
Ok dude, i'm starting to work to the system map. Solar system is huge, and it's easy to lost in. I cannot display on hud all the planets because tere's a lot (moons, asteroids and so on..) so it will be a mess.
Solution: if you want to drive until "Callisto" (i.e.): open the map, select it and then activate the autopilot!
It's just the beginning but you can see now the orbits, the planets, and a different background. You can switch from map to cockpit with a gui button.
Solution: if you want to drive until "Callisto" (i.e.): open the map, select it and then activate the autopilot!
It's just the beginning but you can see now the orbits, the planets, and a different background. You can switch from map to cockpit with a gui button.
Thursday, May 26, 2011
May 2011
A messy month for me: work, home and so on, so not too much time to develop my hobby.
But "not too much" != "no" so, something was done.
- A less raw stardust effect: the dust now are made by sprite, not by pixel, so there's transparency and the result is pretty. (see the previous video...)
- I've started to work to some classes for handle the "other ships" (enemy, friend and so on). But it's just the beginning
- I was (finally!!) able to use a bitmap font for the text on the hud. So, now we have a outlined font, more readable when text overlaps with another text.
- Worked a lot into shadow code. Now self shadowing seems to works: here a short video
- last, but not least, now the gui has also images, so i can make icons and not only text button.
Stay tuned for news.
Friday, April 22, 2011
Autopilot and Stardust.
Now the autopilot works well: you select your destination with the mouse, then the autopilot aligns your ship with the target, thrust the engine until you've made an half of the voyage, and finally brake near the destination... there's something to refine but it works!
I've also added "stardust" to give more depth to the starship speed.. the dust is white for now: i've choose this colour so you can see it into the low-resolution video :). Now it looks like the old Braben's game "Frontier"
I'm thinking how to brake the ship.. using the inertial behaviour is a bit annoying: you've to align the ship to the current speed direction and brake.. if you brake too much the ship moves backward (you can see it at the end of the video), and if you do not align well you create some side movement. In one phrase: it's very difficult to stop a ship manually using an inertial engine.
So it should be less realistic but more usable a brake that doesn't changes the speed direction but his lenght. If i divide the x,y,z component of speed by i.e. 1.01, i don't need to align the ship to brake and i can make some more complex maneuvers...
Happy easter to everybody.
Monday, April 18, 2011
Time to improve (and rewrite) the autopilot.. now i can select an object using the mouse, the next step is to move my ship to the selected destination.
The autopilot is a state-machine that has a lot of step, but you can summarize it into two big "macros":
- align the ship to a selected direction
- move the ship (or stop it).
I need a function that give me the thrust power of the engine from the angle between direction and final orientation: the more distant i am, more power the engine should provide. Otherwise, when the angle is small, the engine should provide less energy.
A good solution is to use the dot product between destination vector and right/up vector. The dot product between u and v is defined like |u||v|cos(angle) where angle is angle between u and v. If u and v are unitary, the cross product give me the angle.
For yaw, the cross product between destination and right is a function that is = 0 when right is normal to direction (and it's true when direction is equal to destination..), is > 0 when direction lies left to the destination, <0 when direction lies right. Perfect for my needs!
Finally, i've to normalize for angles > 90 degrees:
if (angle > 90) { if (dotproduct > 0) dotproduct=1; else dotproduct=-1; }
For pitch is the same, but i use the up vector instead right.
The result is shown in the video.
There's some "freeze": is an issue of my laptop (i've some problem with vista and the hard disk drivers..), not of the game :)
Monday, April 11, 2011
Camera roll and mouse gesture
At least the camera control is almost finished: now you can pitch, yaw and roll, so you can do almost all movement into space.
So i've started to work to the mouse gesture: i've a GUI, and now is time to create some interaction between the mouse and the 3d world.
In this video you can see the ineractions between pointer and mesh.. when you left click in any mesh, its bounding box is displayed. Notice: when two mesh are aligned (i.e. the station and the planet) when you click on both, the engine selects the nearest.
So i've started to work to the mouse gesture: i've a GUI, and now is time to create some interaction between the mouse and the 3d world.
In this video you can see the ineractions between pointer and mesh.. when you left click in any mesh, its bounding box is displayed. Notice: when two mesh are aligned (i.e. the station and the planet) when you click on both, the engine selects the nearest.
Wednesday, March 23, 2011
A message for Yombo (but also for all who can help me)
I write here because i've no way to put all into twitter :) and because i haven't your email address.
I'll talk about my issue with quaternions.
So, i've changed a lot the code, hoping that it solves my problem but nothing changes.
Now the "lookAt" function doesn't receive a vector, but two angles: pitch and yaw. First i compute the pitch rotation (Quaternion q), then the yaw rotation (Quaternion r), and last multiply the two quaternions and rotate the camera using the result.
void MyCamera::lookAt(Ogre::Real pitch, Ogre::Real yaw) {
Quaternion q(Degree(pitch), Vector3::NEGATIVE_UNIT_X);
Quaternion r(Degree(yaw), Vector3::NEGATIVE_UNIT_Y);
q=q*r;
mCamera->rotate(q);
}
This is what happens.
in the upper-left panel now i display the "right" vector of the camera. Ok?
My questions now are: WHY!?!? What's wrong? And what is the correct way?
Thank you for the patience. I'm a noob about rotation.
I'll talk about my issue with quaternions.
So, i've changed a lot the code, hoping that it solves my problem but nothing changes.
Now the "lookAt" function doesn't receive a vector, but two angles: pitch and yaw. First i compute the pitch rotation (Quaternion q), then the yaw rotation (Quaternion r), and last multiply the two quaternions and rotate the camera using the result.
void MyCamera::lookAt(Ogre::Real pitch, Ogre::Real yaw) {
Quaternion q(Degree(pitch), Vector3::NEGATIVE_UNIT_X);
Quaternion r(Degree(yaw), Vector3::NEGATIVE_UNIT_Y);
q=q*r;
mCamera->rotate(q);
}
This is what happens.
in the upper-left panel now i display the "right" vector of the camera. Ok?
- First i rotate around Y axis (yaw), keeping pitch==0 all the time: you can see that right vector has his y coords always = 0. It's correct: the y component of right vector defines the "roll" rotation. If it's always 0, camera does not rolls.
- Next i rotate around X (pitch), keeping yaw==0 al the time. Now the right vector is = (1,0,0), always. In the video you can see not properly (1,0,0) because of the Ogre::Real resolution, but it's something like (1,0.00000001,0.00000001). And it's correct; when i pitch changes the look at, changes the up vector, but the right vector remains normal to plane YZ. Again: the y component of right vector is always = 0, so no "roll" of the camera. Perfect.
- Finally i unlock both rotation and start to combine it: the camera starts to roll, and you can see tha the y component of right vector grows... if it's > 0 camera rolls left, if it's <>
My questions now are: WHY!?!? What's wrong? And what is the correct way?
Thank you for the patience. I'm a noob about rotation.
Tuesday, March 22, 2011
Solution not found :(
Hi guys.
I've follow your suggestion about use quaternions to rotate my camera into the space and the upside/down problem that i had using the lookAt method of the Camera class, seems to be fixed
(here the previous video to show you)
Before i've used the spherical coordinates.. when you move the mouse in x direction i change the yaw angle, and when you move in y direction i change the pitch angle.
After modified the angles, i compute the unitary vector that represent the orientation of the camera:
Finally i use the "lookAt" method to orientate the camera along the "direction" Vector3.
But the side effect is that, when pitch angle go outside the interval (0,PI), the camera flips upside down.
So, i've changed the approach.. no more lookAt but quaternions.
And this is the result:
i've changed the starship mesh with a more clear xyz axis mesh: x is in red, y in green and z in blue.
First i try to do a yaw rotation, around the Y axis... it works fine.
Then pitch rotation and.. well! it works! no more upside-down.
But.. when i combine both and give freedom to camera move something strange happens: moving it cause a side effect: some roll rotations starts to appears and the more i rotate clockwise my mouse, the more the roll appears... and rotating the mouse in other direction changes the roll direction too..
Why??
And how can i remove it?
I've follow your suggestion about use quaternions to rotate my camera into the space and the upside/down problem that i had using the lookAt method of the Camera class, seems to be fixed
(here the previous video to show you)
Before i've used the spherical coordinates.. when you move the mouse in x direction i change the yaw angle, and when you move in y direction i change the pitch angle.
After modified the angles, i compute the unitary vector that represent the orientation of the camera:
direction.x=sin(yaw)*sin(pitch);
direction.y=cos(pitch);
direction.z=sin(pitch)*cos(yaw);
Finally i use the "lookAt" method to orientate the camera along the "direction" Vector3.
But the side effect is that, when pitch angle go outside the interval (0,PI), the camera flips upside down.
So, i've changed the approach.. no more lookAt but quaternions.
void MyCamera::lookAt(Vector3* dir) {
//no more used
//mCamera->lookAt(dir->x,dir->y,dir->z);
Vector3 src = mCamera->getDerivedOrientation() * Vector3::NEGATIVE_UNIT_Z; // Orientation from initial direction. Camera points to (0,0,-1)
Quaternion quat = src.getRotationTo(*dir);
mCamera->rotate(quat);
}
And this is the result:
i've changed the starship mesh with a more clear xyz axis mesh: x is in red, y in green and z in blue.
First i try to do a yaw rotation, around the Y axis... it works fine.
Then pitch rotation and.. well! it works! no more upside-down.
But.. when i combine both and give freedom to camera move something strange happens: moving it cause a side effect: some roll rotations starts to appears and the more i rotate clockwise my mouse, the more the roll appears... and rotating the mouse in other direction changes the roll direction too..
Why??
And how can i remove it?
Monday, March 21, 2011
Saturday, March 19, 2011
I need a little help.
I'm just stucked inside a small but annoying issue and i'm tired and unable to find an elegant solution.
So i'll post here my problem to see if there's someone could help me..
I'm working on orientation of our spaceship.
The ship has two vector (Vector3): the position and the orientation. The first is the position of the ship in space, the second should be a unitary vector that represent the "lookAt" orientation (in local coordinates).
If you're sitted on the cockpit, this represent the direction you're looking to.
To implement this i've used the spherical coords, so, to obtain the vector:
orientation.x=sin(fi)*sin(theta);
orientation.y=cos(theta);
orientation.z=sin(theta)*cos(fi);
where fi is the yaw angle, and theta is the pitch angle.
It works fine for yaw, but.. for pitch, when the angles become less below zero or greather than PI, the screens flips! (look at 0:17)
I think that the issue should be that when theta is outside (0,PI), sin(theta) is <0, and both x and z become negative, and in some ways it invert the up-right vectors.
You can see it into the video: on the upper-left panel there's the ship position and ship orientation (you should use 720p resolution to see the numbers)
For now i've limited the rotation from 0 to PI but it's ugly.. i'd like to pitch and yaw without restricts, i'd like to make loops with my ship without this glitch.
Any idea?
Thank you.
So i'll post here my problem to see if there's someone could help me..
I'm working on orientation of our spaceship.
The ship has two vector (Vector3): the position and the orientation. The first is the position of the ship in space, the second should be a unitary vector that represent the "lookAt" orientation (in local coordinates).
If you're sitted on the cockpit, this represent the direction you're looking to.
To implement this i've used the spherical coords, so, to obtain the vector:
orientation.x=sin(fi)*sin(theta);
orientation.y=cos(theta);
orientation.z=sin(theta)*cos(fi);
where fi is the yaw angle, and theta is the pitch angle.
It works fine for yaw, but.. for pitch, when the angles become less below zero or greather than PI, the screens flips! (look at 0:17)
I think that the issue should be that when theta is outside (0,PI), sin(theta) is <0, and both x and z become negative, and in some ways it invert the up-right vectors.
You can see it into the video: on the upper-left panel there's the ship position and ship orientation (you should use 720p resolution to see the numbers)
For now i've limited the rotation from 0 to PI but it's ugly.. i'd like to pitch and yaw without restricts, i'd like to make loops with my ship without this glitch.
Any idea?
Thank you.
Tuesday, March 15, 2011
Spaceship adrift near the sun
I've taken a mesh from a 3ds model and tried to import it into my game.
Sorry for the glitches: i've some problem with the hard-drive drivers...
Sorry for the glitches: i've some problem with the hard-drive drivers...
Tuesday, March 8, 2011
GUI - updated
GUI
It was a complicated year. My job goes well, but this kill any spare time about Tau Ceti
Anyway, after a long pause, i've restarted (again!) to work on it and i've inserted, finally, a good GUI engine.
It's the CEGUI project, that is a "free library providing windowing and widgets for graphics APIs / engines where such functionality is not natively available, or severely lacking. The library is object orientated, written in C++, and targeted at games developers who should be spending their time creating great games, not building GUI sub-systems!".
There's a visual editor and you can insert LOTS of widgets: buttons, checkbox, dropbox, text area, and so on.. i've integrated it into Tau Ceti and it works.
For now i've added a single button: "QUIT" :) but works well and is very easy to manage, and it integrates perfectly inside the 3d scene.
When i've a more complex scene, i'll show you some examples.
Anyway, after a long pause, i've restarted (again!) to work on it and i've inserted, finally, a good GUI engine.
It's the CEGUI project, that is a "free library providing windowing and widgets for graphics APIs / engines where such functionality is not natively available, or severely lacking. The library is object orientated, written in C++, and targeted at games developers who should be spending their time creating great games, not building GUI sub-systems!".
There's a visual editor and you can insert LOTS of widgets: buttons, checkbox, dropbox, text area, and so on.. i've integrated it into Tau Ceti and it works.
For now i've added a single button: "QUIT" :) but works well and is very easy to manage, and it integrates perfectly inside the 3d scene.
When i've a more complex scene, i'll show you some examples.
Monday, March 7, 2011
Subscribe to:
Posts (Atom)