Dynamic Rotating Isometric Rectangles

Posted by Kenon on Sept. 9, 2008, 1:05 p.m.

Yep, that's what I'm working on right now in the mind of Kenon.

I'm looking for solutions, and I don't quite know where to look.

I'm going to start it off easy: Dynamic Rotating Rectangles.

That's simple. I think I have a script idea for it off the top of my head.

The idea comes from rotating a line. You use a rotation degree with +cos(rad)*length, blah blah blah.

ANyways, the idea I have off the top of my head works as such.

Assume the variables x for x position, y for y position, rad for radians of the angle, pi is… pi, w is the width of the rectangle, and h is the height.

For a vertex A, the first vertex would be (x+(cos(rad+pi/2)*h/2+cos(rad)*w/2),y-(sin(rad+pi/2)*h/2+sin(rad)*w/2))

Or so in theory.

Going to attempt the first vertice in a 0 degree situation where x=0 and y=0, h=8 and w=16.

(8,4). Correct on the 0 degree test.

Going to attempt the 45 degree test now. A triangle with w=16 and h=8 should in theory produce the median of (8sqrt(2),8sqrt(2))

I'll type more when I get home

Comments

Kenon 17 years, 7 months ago

All of my rotations are in radians. I find it easier to use a value of pi instead of a normal number. It just allows me to have better track of the numbers.

Meow, I've done the multi-layered sprites. They allow for some nice stuff, but I only use them when creating momentary fake 3d sprites for things like buildings. Unfortunately, they aren't defined as isometric. So I need to use primitives to deal with the rotation.

Ok, so I did testing, and my method works perfectly.

Stained Glass 17 years, 7 months ago
SteveKB 17 years, 7 months ago

yeah I know that you aren't using sprites just to help you should in include a global.xd and global.yd that all the vertexes can use depending on the rotation of the view (in case you are going to change it.) else you're fine.