# Convert a vector to hpr?

Sorry for asking about this. I tried to find the source code for this stuff to use as a reference, but Windows’ search proved very unhelpful for searching inside files.

Has anyone played EVE Online ever? I ask only because of their UI, and the fact it’s written in Python (or it used to be anyway?) Well, in EVE Online, you control your own starship, and to alter the direction your ship flies, you double click in 3D space and your ship will fly in that direction. I am modeling a similar gameplay style. I’ve used a CollisionRay with the camera get the 3d coordinates, and then multiplied the destination components by 1000000 to get an extremely far away point in space.

The trouble I am having now is this: I would like to convert these coordinates into yaw and pitch for my ship, but I am not sure how best to accomplish that. Any ideas?

It had occurred to me I could use lookAt() and then use getHpr(), but I would like this piece of code to be as efficient as possible.

What I want to do is take the desired Hpr, the ship’s current Hpr, and interpolate between them to gradually rotate the ship to the desired direction.

I’ve never played EVE Online so I’m not familiar with the exact interface you’re trying to implement, but there may be an easier way to get the effect you want: just map the mouse 2D position to heading and pitch.

although that won’t get you the best result, because you should have roll too. so to make it look better, set up the aircraft simulation model first; from there you should be able to control it by applying forces, which you can get from the direction vector, and which should then produce the rotations.

Probably it is necessary to try to use quaterninos for the direction setup by a vector and interpolate it.

from pandac.PandaModules import *
v1 = Vec3(0,10,0)
v2 = Vec3(0,10,10)
q1 = Quat(0.0,v1)
q2 = Quat(0.0,v2)
for i in xrange(10):
q3 = q1*((i+1)*0.1)+q2*(1-(i+1)*0.1)
print q3.getHpr()

Other way - Hpr Intervals panda3d.org/manual/index.php/P … _Intervals

I do play Eve, hanging out in Providence atm

I would do something different. I would use the hpr of the camera, compute the angle viewable with my camera view, then compute the angle difference of my mouseclick. Take the camera hpr, adjust by your mouseoffset factor, and tada!

small thing to add: if i remember correctly there was no rolling in EVE. Neither for the camera, nor for your ship. The ship only rolled as part of an animation when changing direction.

Beside collision detection, which is most probably the easiest way, you could actually also grab the cursor position every time you recieve a double-click event. Given that r=0, the other rotation angles would be something like this:

_/|    +---------+       h = camera.getH() + camera.getFov()
_/  |    |       * |           / win_width * clickGetX()
CAM <_   | => |         | =>
(hpr) \_ |    |         |       p = camera.getP() + camera.getFov()
\|    +---------+           / win_height * clickGetY()
(fov) (click position)

Probably not the most helpful answer, but I had fun drawing the diagram

we all know from star trek that spaceships are only rolled when in curves or when damaged, usually it crashes into a planet soon after. in some weird cases it can happen that a ship is upside-down, scientists say that this is related to singularities, causing unexplainable effects to space and time.

To keep bandwidth down ships in EVE only have a vector of movement and position, no other rotational attributes. When your ship is standing still it is just a point in space not facing any direction at all, as far as the simulation is concerned. The graphics engine creates the illusion that your ship is facing someplace based on its movement vector. This is why you sometimes see ships warp in sideways when it enters your grid, because the model was set to a 0,0,0 orientation and the graphics engine says “oops, got to rotate it!”

For the record,

This is a perfectly acceptable and efficient way to solve the problem you describe in the OP. In fact, it would be the way I’d recommend solving it.

David

Well it does not fly in that direction .(A proud EVE player since 2006)
I quit a few months ago so cant really check all that i will write below but this is how i remember it.

1.If you target an object in eve and click align to then your ship will turn and fly towards that object.
So nodepath.lookAt(target) should be your best friend like drwr said.

1. If you double click on and object, same should happen. Still nodepath.lookAt(target) is your best friend.

3.Now if you double-click in empty space then no lookat mechanics are used as it would be unwise to use them as you have no target point to turn towards, instead a roughly average distance is used(lets say 10km, a good scram range) for turning your ship. So it happens like you would have a big plane 10km away from you and your mouse cursor is projected on to that plane, now to awoid all these unnecessary calculations
it a lot wise to use your mouses x,y and apply them to your ships H,P,R with the roughly average distance in mind.

In order to check whats the average distance(AD from now on) the guys from eve use you can do this.
Find a target, check its distance and now double click as close as possible to that target(but just outside the small rectangle that appears when you mouse over it). Now if your ship overturned the target, that means the AD is less than the targets range, if it under turned then the AD is further than the targets range. Repeat this with a target that has either a smaller or bigger distance till you get the rough idea what eves AD is.

My personal advice, it’s one of the shittiest ways to navigate a ship in empty space that i have ever seen, do it better.