GL or B3D Coord system, opinions?

BlitzMax Forums/BlitzMax Programming/GL or B3D Coord system, opinions?

Tom(Posted 2005) [#1]
Hi all,

I'm trying to create a 3D engine, or at least, some base functions that work exactly like Blitz3D.

As you may or may not know, OpenGL uses a different coordinate system to Blitz3D, Z is reversed. Like most things, moving to one system after using another for a long time it takes some getting used to!

So, in my engine/functions so far, I've been converting everything to Blitz3Ds coord system, all transparent to the user. But I've got to a point now where I'm unsure if it's a good idea to continue doing this. I mean, it all works fine upto now, but maybe there's something that could come back and haunt me later?

What do you think?

Cheers
Tom

p.s I'd love to hear from anyone else making an engine of sorts, Cy, Antony, Noel....<your name here>


N(Posted 2005) [#2]
Personally, I don't think you'll encounter any problems doing this. I just invert the Z on everything (by that I mean I flip the Z axises and translation) and GL happily complies.

Since I intend to eventually get a DirectX renderer into my engine at some point as well, one way or another I'm gonna have to flip it.


fredborg(Posted 2005) [#3]
Flip it! Or even more cunning...make it optional...a simple flag should allow this.


AdrianT(Posted 2005) [#4]
yeah, blitz uses a left handed coordinate system where GL and most 3D apps are right handed i believe. Something to do with D3D I think. We had the same problem to you with the engine were working on. At the moment working on sorting out matching blemd modes with GL


Drago(Posted 2005) [#5]
DirectX is right handed, OpenGL is left, there are some other differences other then Z coord though.


AaronK(Posted 2005) [#6]
Why do you want to use B3d's coordinate system, if you're making an engine for BlitzMax, is it so you can convert the sources across? BlitzMax uses OpenGl, so I'd have thought the natural way to do coordinate systems would be the OpenGL way. If that requires converting models, either pre load or at load time, then do it.

Also, if you're worried, I'd abstract out a coordinate system into a Type - DO NOT hardcode it, and allow the engine to be setup with a coordinate system. That way, you write your Blitz3d one that works all happily, and then if you change your mind, you can just plug a new one into the engine and away you go. Also this means users of your engine, if there are any, could decide how they doit.

Aaron


marksibly(Posted 2005) [#7]
Hi,

Get GL to do it - premultiply your projection matrix by a scale (1,1,-1) matrix.


smilertoo(Posted 2005) [#8]
i'd stick with what opengl expects, otherwise converted tutorials etc. will all be screwey.


Tom(Posted 2005) [#9]
Agreed, a MODE flag, or a B3D LoaderMatrix type Global sounds like the ticket.


teamonkey(Posted 2005) [#10]
a B3D LoaderMatrix type Global sounds like the ticket.


Global d3dIdentity:Float[] = [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,-1.0,0.0,0.0,0.0,0.0,1.0]
'Global oglIdentity:Float[] = [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0]

' Now, wherever you would use
' glLoadIdentity
' use
glLoadMatrixf d3dIdentity