object orientation

I would like to know how to preserve the orientation of an object?

wrtReparentTo(render) - preserves only the position, I want the same hpr of the actor wich the object was parent.

wrtReparentTo() preserves the complete transform, which includes hpr as well as position, scale, and shear.

I don’t understand what you are asking for.

David

Maybe you are talking about compass effects?
panda3d.org/manual/index.php/Compass_Effects

when I use myBall.wrtReparentTo(render) the rotation of the ball gets the same of the render, the axis X is always to the left and right.

I tried myBall.setH( player.getH() ) but it isn’t solving my problem

I want the ball go away from player in the same direction of the player when I do myBall.setX( myball.getX() - 0.6 )

if I don’t do myBall.wrtReparentTo(render) it’s ok, but the player carries jointly the ball because I did myBall.reparentTo(player), the ball must move independent with respect to the rotation(orientation/direction) of the player.

I hope you can understand me now =)

pro-rsoft I didn’t understand compass effects, how may I use it for solve my problem?

wrtReparentTo keeps a object at the same position and rotation relative to render. while reparentTo keeps the rotation relative to the parent.

so there is most likely a error in your code at some other point.

you can also try:

myBall.setH(render, player.getH(render) )

check if the rotation is modified in the process with:

print myBall.getH( render )

OT:
(hmm i cant add the code tags anymore? is this only my browser?)

Okay… I think I get it. So you want the ball to move in the player’s coordinate space while being parented to render? If so, nothing you do to the ball’s orientation will solve the problem- its position and any position transform will still be applied in its parent coordinate space. If you want to do a move in another object’s space, there’s probably some undocumented permutation of setPos that will do so directly, but what I’d default to is

ball.wrtReparentTo(player)
ball.setPos(ball.getPos()+offset_in_player_coords)
ball.wrtReparentTo(render)

so you apply the move in player space without keeping the ball locked in player space.
Careful about doing too much work in player space, though- I’m assuming that after a certain point you’ll want to let the ball free-fly in render space. In that case, your best bet might be a one-off

point_in_player_space.getPos(render)

set the ball’s velocity based on that, and don’t look at the player again.

to convert a vector from one coodinate space into another use “nodepath.getRelativeVector” ( panda3d.org/apiref.php?page= … tiveVector )

the reparenting probably works fine for you, but when you use the same vector as before (the player forward vector in the player’s parent space) your ball will move as you described. so you eighter make sure the ball is rotated correctly (looking into the same direction as the player) and move it forward “Vec3(1,0,0)” or you convert the player forward vector into a world forward vector “ball.getRelativeVector(player, Vec3(1,0,0)”.