Game Development Reference
In-Depth Information
void CToon3DObject::SetTweenKeys(double targetTime,
CToon3DObject *objList)
{
SetTime(curtime);
//Use RestorePos because we need to store positions before
//AlignToParent
RestorePos();
tpos[0].x=pos.x; tpos[0].y=pos.y; tpos[0].z=pos.z;
trot[0].x=rot.x; trot[0].y=rot.y; trot[0].z=rot.z;
tscale[0].x=scale.x; tscale[0].y=scale.y; tscale[0].z=scale.z;
SetTime(time);
RestorePos();
tpos[1].x=pos.x; tpos[1].y=pos.y; tpos[1].z=pos.z;
trot[1].x=rot.x; trot[1].y=rot.y; trot[1].z=rot.z;
tscale[1].x=scale.x; tscale[1].y=scale.y; tscale[1].z=scale.z;
CToon3DObject *obj=objList;
//Recursively update all child objects
while(obj){
if (obj->parent==this) obj->SetTweenKeys(frame,objList);
obj=obj->next;
}
}
//=============================================================
//Tween
//Use the positions stored by SetTweenKeys in tpos[0] and tpos[1]
//and the tweenTime parameter to create a linear interpolation
//between the position, scale and orientation at tpos[0] and that
//at tpos[1]
//=============================================================
void CToon3DObject::Tween(double tweenTime, double duration,
CToon3DObject *objList,
VECTOR *toonpos, VECTOR *toonrot, VECTOR *toonscale)
{
double time = tweenTime / duration, oneminustime = 1.0 - time;
if (toonpos){
pos.x=tpos[0].x * oneminustime + tpos[1].x * time + toonpos->x;
pos.y=tpos[0].y * oneminustime + tpos[1].y * time + toonpos->y;
pos.z=tpos[0].z * oneminustime + tpos[1].z * time + toonpos->z;
}else{
pos.x=tpos[0].x * oneminustime + tpos[1].x * time;
Search Nedrilad ::




Custom Search