Game Development Community

Rotation on a 2D 3D Object and?....

by VcDeveloper · in Technical Issues · 12/06/2008 (11:26 pm) · 4 replies

I have a 3D character in a 2D scene (TBG). The game is in a 3/4 view. Instead of hard coding the rotation into 8 direction I want to be able to rotate at any angle, but maintain the 3/4 angle.

also during the rotation as I have it now. It turns too fast and would like to control this. I need help solving these two problems and would appreciate it vey much!

My game is simulare to a the Adventure Kit, but I'm using 3D characters (t2dShape3D) instead.

#1
12/07/2008 (1:04 am)
Probably the better spot for a question like this is the TGB Public/Private forums (depending on if you have a licenese or not).

The functions to manipulate a 3D shape are as follows:

setShapeAngularVelocity();
function t2dShape3D::setShapeAngularVelocity( x / y / z )
- Sets Shape Angular Velocity. This will control your speed of rotation that you are looking for.


setShapeRotation();
function t2dShape3D::setShapeRotation( x / y / z )
- Sets Shape Rotation. This will give allow you to rotate the object. Once you get the shape set in 3/4 iso, I'm not sure if rotating on 1 axis will be enough. I don't know if axis rotation is relative or static. If it's relative, then this is super easy. If it's static... well then... I'm sure there's resources either here on GG or on the web for doing this math. Any idea if the rotation is static or relative?


setShapeOffset();
function t2dShape3D::setShapeOffset( x / y / z )
- Sets Shape Offset.


setShapeScale();
function t2dShape3D::setShapeScale( x [/ y / z] )
- Sets Shape Scale.

setTimeScale();
function t2dShape3D::setTimeScale(  timeScale  )
- Set the animation time-scale.

All of these have a get function as well.
#2
12/07/2008 (9:10 am)
I'm using those function manaully... I hard coded the the 8 angles... as such:

v_upRotation = "54 0 0";
v_luRotation = "44 54 -44";
h_lfRotation = "0 90 -54";
v_ldRotation = "-44 125 -44";
v_dnRotation = "-54 180 0";
v_rdRotation = "-44 -144 30";
h_rtRotation = "0 -90 54";
v_ruRotation = "44 -54 44";

$posPlayer[0] = $ptrPlayer.v_upRotation;
$posPlayer[1] = $ptrPlayer.v_ruRotation;
$posPlayer[2] = $ptrPlayer.h_rtRotation;
$posPlayer[3] = $ptrPlayer.v_rdRotation;
$posPlayer[4] = $ptrPlayer.v_dnRotation;
$posPlayer[5] = $ptrPlayer.v_ldRotation;
$posPlayer[6] = $ptrPlayer.h_lfRotation;
$posPlayer[7] = $ptrPlayer.v_luRotation;

everything works fine as I have it, but I want to slow down the rotation per fram rate.

I us the left and right arrow keys to set the hard coded rotation during the onUpdate( %this ) as such:

function bluePlayer::onUpdate( %this ){

if($turnRt == false && $turnLf == true){
$ptrPlayer.curRotation -= 1;
if($ptrPlayer.curRotation < 0)
$ptrPlayer.curRotation = $ptrPlayer.maxRotation - 1;
}
else
if($turnRt == true && $turnLf == false)
{
$ptrPlayer.curRotation += 1;
if($ptrPlayer.curRotation > $ptrPlayer.maxRotation - 1)
$ptrPlayer.curRotation = 0;
}

if(%this.lastRotation !$= $posPlayer[%this.curRotation]){
%this.setShapeRotation( $posPlayer[%this.curRotation] );
%this.lastRotation = $posPlayer[%this.curRotation];
}
}

but it turns to fast, so I would like to slow that down, by using some kind of time function since last turn.

but, for the hard coded 3D Vectors, I want to us a 3D transform instead and apply it to the 3D Vectors. The same way it's done in TGE or 3D space. Maybe some kind of yaw and pich function(s)...

I'm not sure about how TGB handles the 3D space in a 2D Object... I will link this post from TGB forum regarding this.
#3
12/09/2008 (12:29 pm)
What if you divided the velocity by the time. Like DT/1000.0
#4
12/10/2008 (2:14 pm)
I'll try that, but this is what I did for now and it work pretty good:

function bluePlayer::updateAnimation( %this )
{
if($turnRt || $turnLf)
%this.DoTurnRotation();
else
$turnSince = 0;

other stuff................
..........................
}

function bluePlayer::DoTurnRotation(%this)
{
$turnOk = getRealTime() - $turnSince;
if($turnOk < $turnNow (=500ms))
return;

$turnSince = getRealTime();
............
do the rotation stuff......
............
}

what do you think?