-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|490|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Graphical Engines


 
Tikihead
Created : 04 October 2010
Edited : 04 October 2010
Language : Blitz

2D/3D screen coordinates

Go from 2D screen coordinates to 3D world coordinates and back again

Translate between 2D screen and 3D world coordinates. I found this most useful for my 2D in 3D game that needs to mix 2D and 3D coordinates.

Zoom# = camera zoom level
Set y to True to convert vertical coordinates


 

Comments


Thursday, 14 October 2010, 11:23
dna
I'm curious just how this works.

I understand what you mean by having 2D coordinates and then converting them into 3D, and back, but I cannot see the relation in this code.
Thursday, 14 October 2010, 17:58
Tikihead
If you have a 2D x-coordinate, let's say MouseX(), your sprite camera is at zoom level "zoom", and you want to see where in the 3D scene your mouse is really, you would use "ConvertToLevel(MouseX())".

I understand that it isn't the *most* useful snippet, but I needed it for my 2D in 3D game and it took a while to figure out.

As for how/why it works, I don't know; I just played around with the equation until it worked.
Thursday, 14 October 2010, 18:00
Jayenkai
yeay for Trial and Error coding

This'll probably go all screwy if you added resolution options. I know mine did, in my silly little 3D Puppet Adventure thing.
Thursday, 14 October 2010, 19:58
dna
Ah.

So this is not for B2D since it has no camera function.

How would you use it in your PLat 3D demo jay or in B2D?

I remember Plat 3D being in B2D and running with seemingly 3d blocks.

maybe I'm sliding off the subject.
Sunday, 17 October 2010, 18:33
JL235
B2D doesn't have 3D (hence B2D), so no this wouldn't work.