Archived

This topic is now archived and is closed to further replies.

jollyjeffers

Rotating a 2D Array so it's Isometric

Recommended Posts

jollyjeffers    1570
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,

Share this post


Link to post
Share on other sites
Dino    172
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.

Share this post


Link to post
Share on other sites
jollyjeffers    1570
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,

Share this post


Link to post
Share on other sites
Dino    172
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.

Share this post


Link to post
Share on other sites
jollyjeffers    1570
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?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
KalvinB    102
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

Share this post


Link to post
Share on other sites
jollyjeffers    1570
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..

Share this post


Link to post
Share on other sites
KalvinB    102
quote:
Original post by jollyjeffers

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..




The 2nd demo does exactly what you''re doing. Minus the fancy stuff. And in 320x240 16 color. Not 16bit. 16.

I started programming in C++ about 2 years ago. Just DirectX. I did one FMV game in VB four years ago but that was it. Now I use VB to do specific apps since I know it better than MFC.

Ben

Share this post


Link to post
Share on other sites
jollyjeffers    1570
I really really hate MFC.
I''ve looked into it, but each time I hate it more and like VB more...

VB is just sooo easy to write a windows application. The only justification for C++ is speed and features IMHO..

which is why it''s so good for games. A word processor really doesn''t need that much speed...

Jack,

Share this post


Link to post
Share on other sites