gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Libnds World Coords.

#174282 - Jinroh - Wed May 26, 2010 7:25 pm

Hey all,

I have a quick question. Since libnds is setup like OpenGL, you don't have easy access to World Coordinates for things like collision and whatever.

Currently I create my own world matrix and transform my vertices for things like collision myself, anybody do something similar or different?

Just curious,
Jinroh.
_________________
The lone Wolf howls, driven by pride he presses on. Knowing not where he goes, but only where he wants to be.
~Me~

#174293 - relminator - Thu May 27, 2010 12:44 am

Not sure what you mean here but you always have access to your world coords. It's the screenspace coords that you don't have access to.

Collisions on world space could be done via simple spheres or AABB's.

DS 3d engine works like this:

Code:
1. Pass your worldspace vertices/normals/textures to the DS 3d registers (GFX_VERTEX16, etc)
2. Modelview matrix transforms your vertices and normals by multiplying your vertices vectors with it. ie: newvector = mat * origvector.
3. textures are transformed with the texture matrix. Same as #2
4. All transformed coords are projected on screen via the projection matrix.


It's the basic algorithm of doing 3d in both software and hardware.

If you want to get the screenspace coords, you need to "unproject" your vertices.
_________________
http://rel.betterwebber.com

#174296 - Jinroh - Thu May 27, 2010 5:27 am

Thanks for the reply relminator.

I already coded up my collision system before but was under the impression since the libds is so much like OpenGL that my world coordinates were being hidden from me like OGL.

I appreciate the info, that makes things less redundant. ^_^
_________________
The lone Wolf howls, driven by pride he presses on. Knowing not where he goes, but only where he wants to be.
~Me~

#174299 - kusma - Thu May 27, 2010 10:55 am

A world-space definition doesn't even exist in the eyes of OpenGL. Everything OpenGL sees is the model-space coordinates and the model->view transformation (i.e the modelview matrix). The same thing goes for nitroGL.

I'd say that a sane engine would calculate model->world and world->view on the CPU, and use OpenGL to multiply these together. Then you'd have access to everything you need for collisions etc.

#174310 - Jinroh - Fri May 28, 2010 5:40 pm

Working on a solution in OpenGL PC. I'll keep you posted.

EDIT: Solved, the collision detection solution I came up with is quite nice and fast, I'll show off the DS version once I port it over.
_________________
The lone Wolf howls, driven by pride he presses on. Knowing not where he goes, but only where he wants to be.
~Me~