Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Matrix Help. - What Tile is the player standing on.

Author
Message
Fusspawn
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 8th Mar 2008 03:33
Hi there,

I was to use a Matrix as a ground base as it allows easy Terrain Manipulation, Now i can make the terrain move around it, Hell i can even raise lower texture certain tiles with ease.


But how the hell would i find a method of translating a players position ( ideally with just an x, y , z Cord of the player
( Just the Default camera atm but would be willing to actually create some form of player if it would help me solve this issue. )

Into the Matrix Tile they are standing above :/

Ive spent a good while pondering this and trying to think how these terrain editors do it, But ill be buggered if i can work out how.

Stuck in the land of the confused! and loving it!
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 8th Mar 2008 06:26
Math. Thinking outside the poly

You likely chose values for the matrix... width (x usually), depth(z usually) tiles... maybe scale. Well... Ok... so you have a clue how big this thing is.

Turn Off Autocam, make a cube (not to big) and place it at 0,0,0. This is just a visual reference so you know where 0,0,0 is...

Make it so you can fly around in your camera. Display to the screen the camera position x,y,z and the angles xa,ya,za. Now you have some sort of bearings.

Make your matrix.. fly around it. Watch those numbers. I forget where 0,0 is on a matrix but think of the math:

Size_of_TileX = MatrixWidth (divided by) TilesX
Size_of_TileZ = MatrixDepth (divided by) TilesZ

(Now if there is scaling invloved, multiply Size_of_Tile? by Scale.)

Forget the Y for your player dude a minute.

Now if your player dudes coordinates (Might as well display those to for debugging) are falling in within the TILES's actual position (point being you should be able to calc it) then you got it.

Doing a ton of


Is probably not the way to go. Something closer to this should be where you want to be.... losing the float.. make the result an integer.

This is to give you an idea on how to make math work for ya - but I'm no math wiz... but see how this could eliminate a whole list of if then statements to check player position tile at a time.



Now this might not be enough of an answer - and it may - but I'm dead tired and I wanted help ya before I crashed... Good Night - Good Luck. Hope this got you thinking.

Fusspawn
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 8th Mar 2008 14:18 Edited at: 8th Mar 2008 14:18
your a star!

It was the maths that was tricking me, i couldnt see any valid way of translating an xyz cord into that or a Grid refrence, you cleared that up perfectly,

Im far from a maths guru ( Infact i left school a few years earlier than i should've and never even sat a maths exam. ) So working out the calculations to perform are beyond me, I can how ever turn maths into code so thanks alot for the help

Edit: for readability

Stuck in the land of the confused! and loving it!
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 8th Mar 2008 14:24
Glad to have helped... and FYI - You don't need to be a math expert - but you do need to think about math in a logical way to solve issues.

Jason's Theory of Relativity: I only learn the relative math I need to get my code working

If the speed of light is so fast... why does it take my monitor so long to warm up?

Good Luck Man - important: Have fun!

Fusspawn
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 8th Mar 2008 15:42
I must Admit one of the reasons ive stuck with DarkGDK instead of finding an easier one ( altho this is quite easy once you get your head round certain things - WTF is the Matrix4 ectra crap >.> )

Is the Community, theres a few that stand out as far above the normal in willingness to help. You being one of them.

Again thanks.

Stuck in the land of the confused! and loving it!
Fusspawn
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 8th Mar 2008 15:51
On another note, ill add the code im using,

i pass these funtions the X and Y coords of the player im using.

the / 100 part is hardcoded to my matrix size, you should be able to work out your own based on Jasons wonderfull post above.





Also can anyone work out why printing these strings to the screen using dbPrint Causes a massive lag fest.


Example code below




Commenting out the DbPrint stuff it runs at an alarming fast rate, but the second those are included in the loop all hell gets let loose ( altho they do calc the value correctly it seems ^_^ )

Stuck in the land of the confused! and loving it!
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 8th Mar 2008 16:35
I dunno - but have you snagged my library? I ask because I have a string class in there that is admittedly not the STDLIB... but its small and easy to use and I don't get that much of a lag and I wonder if its the dbStr() thingy.
http://code.google.com/p/darkgdkoop/

I Know Text is super fast... but you said LAG FEST.

So, perhaps your maths are slowing you down, or what ever. If I WAS YOU.... I Would something like this... so I could experiment where the speed is getting chomped:


Note I didn't compile this and test it but should be cool - maybe a semicolon here or there... a curly bracket or something

Fusspawn
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 8th Mar 2008 21:29 Edited at: 8th Mar 2008 21:30
your OOP libs look intresting, do you intend to release a non DarkPhyics Version ?

Im still strapped for cash to go buy that for a few weeks

Havent had a chance to test whats causing the lag yet btw will post more info once found.

Stuck in the land of the confused! and loving it!
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 8th Mar 2008 22:10
Oh... It works without DarkPhysics. You just need to Comment out the DarkPhyics #Include "DarkPhysics.H" headers anywhere they are... then just comment out any DarkPhysics Calls like dbPhyWhatever.

The demos are tighter woven than the Library.
Basically... do the same thing with those. You just won't bump tanks and watch them get thrown hundreds or thousands of feet.

Fusspawn
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 8th Mar 2008 22:44
Heh will give those ago.

find and replace dbPhy with //DbPhy and nuke the include should do it right ?

Stuck in the land of the confused! and loving it!
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 8th Mar 2008 22:58
Yeah - But keep the DarkPhysics CLASS I MADE in there... just comment out the dbPhyWhatever's... The reason is the HeartBeat Timer you might want later for your own stuff...

Note: In the demo's you may find tanks hovering... in the air... because I "Drop" them onto the terrain LOL

Fusspawn
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 8th Mar 2008 23:26
Alas im getting those Exception errors listed on your bugs page on teh google site crappy vista >.>

Stuck in the land of the confused! and loving it!
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 8th Mar 2008 23:42
In Vista, I wonder if DarkGDK has a MEMBLOCK issue OR... when you compile stuff.. what is your "int" 32bit or 64bit?

Try printing sizeof(int) to the screen. If it says 32... I'm stuck - think maybe TGC thing... if says 64... then its cuz my code is written for 32bit curently.

Fusspawn
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 9th Mar 2008 00:22
32 bit ;/

ive not done anywork with memblock's ( dont really understand them albeit ive hardly tried ) So It could very well be that.

Stuck in the land of the confused! and loving it!
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Mar 2008 01:14
Yeah.. PErhaps - but I'll have you know that code runs fine here... and actually creates the IMAGE I hardcoded in there just fine on XP.

(Its a small test image 32x32 I use all the time debugging and stuff.)

Login to post a reply

Server time is: 2024-11-20 05:36:40
Your offset time is: 2024-11-20 05:36:40