GP32 Transforming, drawing objects..


RobertG

Member
Joined
Apr 15, 2003
Messages
188
I'm writing a wolfenstienish raycasting engine (grids), I've got a DHTML version here: www.elephantsneverforget.co.uk/SKYNET/lighting (GP32 version is the same thing, but looks nicer and is faster :)), but am stuck on transforming world coordinates(x,y) to screen coordinates(x,y) for drawing bad guys, etc.. I've done 3D transformation/projection before but I can't get my head around transforming 2D to 2D.. ;)

I've looked around for some tutorials but none of them seem to get further than drawing walls..

Any help would be greatly appreciated :)
 
Hi RobG

your world 2D is X,Z

and your screen 2d is X,Y

so you need to first transform your Character coords into world coords with a simple 2d rotation and offset
and then transform your world coords into screen coords
with the usual x/z y/z - since it's 2d - your y (camera height) is constant.
 
Thanks Zardoz,

I've made some progress but the X coordinate seems a bit off.. The objects move "correctly" but don't seem to be quite in sync with the walls..

I think the problem is this:
transx = (277*nx/ny)+160;

277 is the distance from the player to projection plane used in the raycasting parts.. Is that the correct value?? The Javascript version is in the same place if you want to have a look through the full code..

Cheers.
 
Back
Top