Hi, I have been testing the function with big and small origin offsets and did not find any case that the vector length get null. How do you declare the rotation origin vector?

Anyway I realized that the function call alters the length of the computed offset vector because of the innacuracy of the variables so I would save the offset vector of the unrotated state of the entity and rotate it with the absolute rotation of the entity each frame. This way the offset vector mantains its length during the run.

Code:
#include <acknex.h>

#define PRAGMA_PATH "%EXE_DIR%\\templates\\models"

#define vOriginX   skill20
#define vOriginY   skill21
#define vOriginZ   skill22
#define vOffsetX   skill23
#define vOffsetY   skill24
#define vOffsetZ   skill25

void ent_offset_rotateXY ( ENTITY *ent, var angRotation )
{
	ent.pan += angRotation;
	vec_set ( ent.x, ent.vOffsetX );
	vec_rotate ( ent.x, vector ( ent.pan, 0, 0 ) );
	vec_add ( ent.x, ent.vOriginX );
}

void main ()
{
	level_load ( "" );
	camera.x = -500;
	camera.z = 200;
	camera.tilt = -20;
	ENTITY *ent = ent_create ( "buggy.mdl", nullvector, NULL );
	vec_set ( ent.vOriginX, ent.max_x );
	vec_diff ( ent.vOffsetX, ent.x, ent.vOriginX );
	
	while ( !key_esc )
	{
		ent_offset_rotateXY ( ent, time_step * 5 );
		wait(1);
	}
}





Last edited by txesmi; 07/27/14 07:59.