Jump to content

PlayerActor camera offset


photo

Recommended Posts

We use PlayerActor class, and we need detect camera position and direction. We use next code:

actor.renderVisualizer();

vec3 p0 = actor.getPosition() + vec3(0, 0, actor.getCollisionHeight());
vec3 p1 = actor.getViewDirection();

vec3 p2 = p0 + p1 * 1.6f;

engine.visualizer.renderDirection(actor.getPosition(), actor.getViewDirection(), vec4(1, 1, 1, 1));
engine.visualizer.renderLine3D(p0, p2, vec4(0.5, 1, 1, 1));

 

and see next screen:

post-151-0-67654600-1298298164_thumb.jpg

I need draw line via center of camera view, how to determine offset between collision capsule and player's camera?

Link to comment
  • 2 weeks later...

In screenshot I blend together 3 camera positions: player looks up, center and down.

In all states you can see blue lines, in center look this line pass directly through camera, but in up/down states this blue line shifts... I can not determine camera offset to locate this blue line directly on camera center. I try next:

mat4 offset = actor.getOffset();

engine.visualizer.renderSphere(translate(actor.getPosition()) * offset, 0.4, vec4(1, 0, 1, 1));

 

But this sphere appear in bottom of player's collision capsule, not in camera position. How it can be possible to determine player's camera position? Thanks.

post-151-0-00385700-1299657994_thumb.jpg

Link to comment

This offset is 0.3f in y axis :)

This offset is my fault... To get PlayerActor's camera transform we can use PlayerActor::getIModelview() method

Link to comment
×
×
  • Create New...