forked from Mirrors/openclonk
added new turn system for clonk. Now uses MeshTransformation instead of rotations in animations and turn animations
parent
943143cd6b
commit
5a774c543d
Binary file not shown.
Binary file not shown.
|
@ -508,6 +508,28 @@ public func GetHandAction()
|
|||
return false;
|
||||
}
|
||||
|
||||
/* Mesh transformations */
|
||||
|
||||
local mesh_transformation_list;
|
||||
|
||||
func SetMeshTransformation(array transformation, int layer)
|
||||
{
|
||||
if(!mesh_transformation_list) mesh_transformation_list = [];
|
||||
if(GetLength(mesh_transformation_list) < layer)
|
||||
SetLength(mesh_transformation_list, layer+1);
|
||||
mesh_transformation_list[layer] = transformation;
|
||||
var all_transformations = 0;
|
||||
for(var trans in mesh_transformation_list)
|
||||
{
|
||||
if(!trans) continue;
|
||||
if(all_transformations)
|
||||
all_transformations = Trans_Mul(trans, all_transformations);
|
||||
else
|
||||
all_transformations = trans;
|
||||
}
|
||||
SetProperty("MeshTransformation", all_transformations);
|
||||
}
|
||||
|
||||
/* Turn */
|
||||
local iTurnAction;
|
||||
local iTurnAction2;
|
||||
|
@ -535,18 +557,56 @@ func FxIntTurnStart(pTarget, iNumber, fTmp)
|
|||
var iTurnPos = 0;
|
||||
if(EffectVar(0, pTarget, iNumber) == COMD_Right) iTurnPos = 1;
|
||||
|
||||
EffectVar(3, pTarget, iNumber) = 25;
|
||||
// SetProperty("MeshTransformation", Trans_Rotate(EffectVar(3, pTarget, iNumber), 0, 1, 0));
|
||||
/*
|
||||
iTurnAction = PlayAnimation("TurnRoot120", 1, Anim_Const(iTurnPos*GetAnimationLength("TurnRoot120")), Anim_Const(1000));
|
||||
iTurnAction2 = PlayAnimation("TurnRoot180", 1, Anim_Const(iTurnPos*GetAnimationLength("TurnRoot180")), Anim_Const(1000), iTurnAction);
|
||||
iTurnKnot1 = iTurnAction2+1;
|
||||
iTurnAction3 = PlayAnimation("TurnRoot240", 1, Anim_Const(iTurnPos*GetAnimationLength("TurnRoot240")), Anim_Const(1000), iTurnAction2);
|
||||
iTurnKnot2 = iTurnAction3+1;
|
||||
|
||||
*/
|
||||
EffectVar(1, pTarget, iNumber) = 0;
|
||||
EffectVar(4, pTarget, iNumber) = 25;
|
||||
EffectVar(5, pTarget, iNumber) = -1;
|
||||
SetTurnType(0);
|
||||
}
|
||||
|
||||
func FxIntTurnTimer(pTarget, iNumber, iTime)
|
||||
{
|
||||
// Check wether the clonk wants to turn (Not when he wants to stop)
|
||||
var iRot = EffectVar(4, pTarget, iNumber);
|
||||
if(EffectVar(0, pTarget, iNumber) != GetDirection() || EffectVar(5, pTarget, iNumber) != iLastTurn)
|
||||
{
|
||||
EffectVar(0, pTarget, iNumber) = GetDirection();
|
||||
if(EffectVar(0, pTarget, iNumber) == COMD_Right)
|
||||
{
|
||||
if(iLastTurn == 0)
|
||||
iRot = 180-25;
|
||||
if(iLastTurn == 1)
|
||||
iRot = 180;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(iLastTurn == 0)
|
||||
iRot = 25;
|
||||
if(iLastTurn == 1)
|
||||
iRot = 0;
|
||||
}
|
||||
// Save new ComDir
|
||||
EffectVar(0, pTarget, iNumber) = GetDirection();
|
||||
EffectVar(5, pTarget, iNumber) = iLastTurn;
|
||||
// Notify effects
|
||||
ResetAnimationEffects();
|
||||
}
|
||||
if(iRot != EffectVar(3, pTarget, iNumber))
|
||||
{
|
||||
EffectVar(3, pTarget, iNumber) += BoundBy(iRot-EffectVar(3, pTarget, iNumber), -18, 18);
|
||||
SetMeshTransformation(Trans_Rotate(EffectVar(3, pTarget, iNumber), 0, 1, 0), 0);
|
||||
// SetProperty("MeshTransformation", Trans_Rotate(EffectVar(3, pTarget, iNumber), 0, 1, 0));
|
||||
}
|
||||
EffectVar(4, pTarget, iNumber) = iRot;
|
||||
return;
|
||||
// Check wether the clonk wants to turn (Not when he wants to stop)
|
||||
if(EffectVar(0, pTarget, iNumber) != GetDirection())
|
||||
{
|
||||
|
@ -583,6 +643,12 @@ func FxIntTurnTimer(pTarget, iNumber, iTime)
|
|||
|
||||
public func GetTurnPhase()
|
||||
{
|
||||
var iEff = GetEffect("IntTurn", this);
|
||||
var iRot = EffectVar(3, this, iEff);
|
||||
if(iLastTurn == 0)
|
||||
return (iRot-25)*100/130;
|
||||
if(iLastTurn == 1)
|
||||
return iRot*100/180;
|
||||
return GetAnimationPosition(iTurnAction)*100/GetAnimationLength("TurnRoot120");
|
||||
}
|
||||
|
||||
|
@ -604,10 +670,12 @@ func SetTurnType(iIndex, iSpecial)
|
|||
}
|
||||
else
|
||||
{
|
||||
// Standart turn? Save and do nothin if we are blocked
|
||||
// Standart turn? Save and do nothing if we are blocked
|
||||
iLastTurn = iIndex;
|
||||
if(iTurnSpecial) return;
|
||||
}
|
||||
// EffectVar(0, this, GetEffect("IntTurn", this)) = -1;
|
||||
return;
|
||||
if(iIndex == 0)
|
||||
{
|
||||
SetAnimationWeight(iTurnKnot1, Anim_Linear(GetAnimationWeight(iTurnKnot1),1000,0,10,ANIM_Hold));
|
||||
|
|
|
@ -264,11 +264,11 @@ public func FxIntGrappleControlTimer(object target, int fxnum, int time)
|
|||
}
|
||||
var angle = rope->GetClonkAngle();
|
||||
var off = rope->GetClonkOff();
|
||||
target->SetProperty("MeshTransformation", Trans_Mul(Trans_Translate(0, -10000), Trans_Rotate(angle,0,0,1), Trans_Translate(-off[0],-off[1]+10000)));
|
||||
target->SetMeshTransformation(Trans_Mul(Trans_Translate(0, -10000), Trans_Rotate(angle,0,0,1), Trans_Translate(-off[0],-off[1]+10000)), 2);
|
||||
}
|
||||
else if(EffectVar(4, target, fxnum))
|
||||
{
|
||||
target->SetProperty("MeshTransformation");
|
||||
target->SetMeshTransformation(0, 2);
|
||||
target->SetObjDrawTransform(1000, 0, 0, 0, 1000);
|
||||
target->StopAnimation(target->GetRootAnimation(10));
|
||||
if(!target->GetHandAction())
|
||||
|
@ -285,7 +285,7 @@ public func FxIntGrappleControlStop(object target, int fxnum, int reason, int tm
|
|||
{
|
||||
if(tmp) return;
|
||||
target->SetTurnType(0);
|
||||
target->SetProperty("MeshTransformation");
|
||||
target->SetMeshTransformation(0, 2);
|
||||
target->StopAnimation(target->GetRootAnimation(10));
|
||||
target->SetObjDrawTransform();
|
||||
if(!target->GetHandAction())
|
||||
|
|
|
@ -343,7 +343,8 @@ func FxIntClimbControlControl(target, number, ctrl, x,y,strength, repeat, releas
|
|||
}
|
||||
|
||||
func SetLadderRotation (int r, int xoff, int yoff) {
|
||||
SetProperty("MeshTransformation", Trans_Mul(Trans_Translate(0, -10000), Trans_Rotate(-r,0,0,1), Trans_Translate(xoff, 10000+yoff)));
|
||||
SetMeshTransformation(Trans_Mul(Trans_Translate(0, -10000), Trans_Rotate(-r,0,0,1), Trans_Translate(xoff, 10000+yoff)), 1);
|
||||
// SetProperty("MeshTransformation", Trans_Mul(Trans_Translate(0, -10000), Trans_Rotate(-r,0,0,1), Trans_Translate(xoff, 10000+yoff)));
|
||||
return;
|
||||
var fsin=Sin(r, 1000), fcos=Cos(r, 1000);
|
||||
// set matrix values
|
||||
|
|
Loading…
Reference in New Issue