Rotating a 2D Array so it's Isometric

Started by
10 comments, last by jollyjeffers 23 years, 6 months ago
hi, say I have an array of points (2D) [9][9] in a standard pattern: 000000000 000000000 000000000 000000000 000000000 000000000 000000000 000000000 000000000 how can I rotate them all about 45 degrees? say I have the origin as the point at [0][9] - and I rotate them all around that.... it''d basically end up looking like an isometric diamond... any help is much appreciated.. Jack,

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Advertisement
You don''t rotate the array. You change the way tiles are displayed by using trig.

Ben
Just a slip of the tongue...

anyway - problems been solved

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

I''d be interested, as would alot of people, in hearing how you did it if you are willing to share.

This type of knowledge could prove useful to alot of people so maybe you should write up an article on it.



Dino M. Gambone
Good judgement is gained through experience. Experience, however, is gained through bad judgement.

Dino M. Gambone
Good judgment is gained through experience. Experience, however, is gained through bad judgment.

Currently working on Rise of Praxis MUD: http://www.riseofpraxis.net/

I could write an article on the subject - I''ve written lots (over 100) before...

I cant [at the moment] transfer UDT''s - I get loads of VB errors, even if the C++ source is correct...
I''m working on it though...

Jack,

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Tell me what the problem is. I''m pretty good with VB.

Dino M. Gambone
Good judgement is gained through experience. Experience, however, is gained through bad judgement.

Dino M. Gambone
Good judgment is gained through experience. Experience, however, is gained through bad judgment.

Currently working on Rise of Praxis MUD: http://www.riseofpraxis.net/

I think I might have solved it - But it''s on the other computer so I cant test it right this second...

I''m pretty sure it''s to do with my prototypes in C++...

I was getting a "Bad Calling Convention" error from Visual Basic...

I had code like:

typedef struct _D3DTLVERTEX
{
float sx;
float sy;
float sz;
float rhw;
float specular
long color;
float tu;
float tv;
}D3DTLVERTEX;

Not necessarily in that order...

and
Private Type D3DTLVERTEX
sx as single
sy as single
sz as single
rhw as single
specular as single
color as long
tu as single
tv as single
end type

They were in the same order in both languages...

and I was using

void _stdcall AlterVertex(D3DTLVERTEX *v)
{
//Stuff here
}

but someone advised me to use a different type of declaration - but I cant remember it off the top of my head

Jack,

PS - anyone ever documented this before?

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

The only other type of declaration I can think of is:
void _stdcall AlterVertex(D3DTLVERTEX &v);

And the function would be declared in VB as:
Declare Sub AlterVertex Lib "DLL" (ByRef Vertex as D3DTLVERTEX)

Also, shouldn''t there be a __declspec(dllexport) on the C++ function. Since functions are bound only when they are called, you wouldn''t get an error until calling the function. If the function isn''t exported from the DLL, then VB won''t be able to find the function in the DLL and thus give you that error message.

Another thing I have noticed is that some compilers will mangle the function name. Check to see if function name isn''t something like _AlterVertex. QuikView will allow you to check if the function is exported and the actual name.
What do your tiles look like? When I first attempted ISO I tried rotating the tiles to fit but it didn''t work.

To move them into alignment I used
XPos=x*a-y*b
YPos=x*c+y*d

(same fomula used to rotate 2-d except without sine and cosine)

where a,b,c and d are caculated based on whatever tile you''re using. They''re usually a muliple of some number.

d is the base number
a=d*4
b=d*2
c=d*3

I also have a QuickBASIC demo of a wire-frame track that you can "drive" around. The car always goes up and the track rotates around it. If that''s sort of what you''re trying to do.

Also a demo with filled squares that you can walk around. The floor rotates and the player can move in four directions if I remember correctly. Been awhile. It''s also in QuickBASIC.

If you''re interested in the source to any of those let me know. I use BASIC for testing things quickly and easily. The source can be easily ported to any language.

Ben
first the DLL thing.

My stooopid mistake - I declared it in VB as "function" when it should be "Sub"... whoops.
Now works fine...

Second, the ISO thing...
All I do is generate a normal 2D grid using TLVertices, then rotate it by 45 degrees... the demo sounds cool, but I''ve never used QBasic, jumped into VB4 about 3 years ago, then VC++5 about 1 year ago..

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement