rotating many objects

Posted By: Hazardos

rotating many objects - 01/02/09 00:07

Good morning everyone,

I've got a problem which won't let me go to sleep!

I create many Cubes and each has got 12 Edges, so I create 12 Edges for every Cube! The Cube has got three skills: rotating, scaling, moving. If a Cube changes its form the edges have to change its form, too. Therefore I've simply written an action which moves, scales and rotates each Edge of a cube.

The Problem: By increasing the number of Cubes (with 12 edges each) the game crashes. Why does this happen?

Thanks for ur help!

Code:
action Edge()
{
	var rot[3]; 
			//the relative vector pointing from the
			// middle of the non-rotated Cube to the Edge

			//First, the edge searches for its cube
			//skill53 = number of the Cube
			//skill54 = number of the edge (1..12)
			//or zero for the Cube
	
	you = ent_next(NULL);
	while (!((you.skill53==my.skill53)&&(you.skill54==0)))
		you = ent_next(you);
	

			//Each frame the Edge calculates its position, rotation and scaling.

	while(1)
	{
		switch (my.skill54)
		{
			case 1:
				{
					rot[0] = 0;
					rot[1] = -you.scale_y/2;
					rot[2] = you.scale_z/2;	
					my.scale_x = you.scale_x + 5;
					my.scale_y = 5;
					my.scale_z = 5;
				}

			[...]

			case 12:
				{
					rot[0] = you.scale_x/2;
					rot[1] = you.scale_y/2;
					rot[2] = 0;
					my.scale_x = 5;
					my.scale_y = 5;
					my.scale_z = you.scale_z-5;
				}
		}
		
		vec_rotate (rot,vector(you.pan, you.tilt, you.roll));
		
		my.x = you.x;
		vec_add(my.x, rot);
		my.roll = you.roll;
		my.tilt = you.tilt;
		my.pan = you.pan;
		wait (1);	
	}			
}


Good night!
Posted By: Quad

Re: rotating many objects - 01/02/09 00:09

check if(you!=null)

any error messages?
Posted By: Hazardos

Re: rotating many objects - 01/02/09 00:19

no, definetely not!
I have to add, that i have written an own function to rotate the edges. But this costs too much performance. perhaps the function of acknex is faster than mine.

[EDIT]
No, it is not!
I just build as much cubes as i could build with the acknex-rotate-function and compared the framerate with the framerate by using my function. The result: mine is faster.

Nevertheless I want to know, where the problem is.

I'd just begun using Gamestudio. Sometimes the manual hides important informations (or it is written somewhere where a newbie would not search for).
© 2024 lite-C Forums