Calculating object's location and rotating along a curve

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
sampie
Posts: 0
Joined: Sat Feb 18, 2012 9:21 pm

Calculating object's location and rotating along a curve

Post by sampie » Fri Mar 02, 2012 3:28 pm

Hi,

I am trying to create moving tank tracks, which can be exported to an external game engines as an animation. It seems blender can't do this.

So, I'll try scripting it with python.

I have a track block (a mesh) and a curve. How can I calculate block's rotation and positions when moving it along the curve?

Thanks

sampie
Posts: 0
Joined: Sat Feb 18, 2012 9:21 pm

Post by sampie » Thu Mar 08, 2012 10:04 pm

What would be right place to ask this question? Another forum?

stiv
Posts: 0
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Post by stiv » Fri Mar 09, 2012 12:37 am

Best place for asking user questions is over at the user forums at blenderartists.org , rather than here on the development forums.

I recall seeing a tank tread tutorial back in the mists of time. No hints as to where, though. Sorry.

Tehrasha
Posts: 0
Joined: Wed Apr 21, 2010 6:21 am
Location: Iowa

Post by Tehrasha » Fri Mar 09, 2012 12:53 am

Something like this ??

Blender Tank Tread Tutorial
Spacemice Wiki -- Input devices for a 3D world.
Spacemice / Blender Compatibility

mb
Posts: 0
Joined: Mon Feb 22, 2010 10:20 am

Re: Calculating object's location and rotating along a curve

Post by mb » Fri Mar 09, 2012 12:12 pm

sampie wrote:...I have a track block (a mesh) and a curve. How can I calculate block's rotation and positions when moving it along the curve?
In blender 2.62 this method worked for me:
- in the editor create the animation where your track-block follows the desired trajectory;
- in the game engine use an action actuator triggered by an always sensor to run the animation;
- use a python script, triggered by the same always sensor, to get trajectory info's, e.g.:

Code: Select all

from bge import logic
from math import degrees

player = logic.getCurrentScene().objects['Cube']
angles = player.worldOrientation.to_euler() # orientation in radians
pos = player.worldPosition # position in blender units

# TEST:
print('Z-rotation=',degrees(angles.z), 'Position=', pos)
)

Post Reply