Doing 3D math in AGS

Started by eri0o, Wed 16/10/2019 23:11:38

Previous topic - Next topic

eri0o



Recently I've been inclined to learn the math that enables doing 3D stuff. In the long past I guess people have looked into it (I found this thread from 2005!), and more recently a very impressive demo was put here...

So I decided to look into what could be done in similar manner, as a module, to help with such endeavors. From a different unreleased, unfinished, project, I cobbled up some code here in this GitHub repository. The README is barely a sketch, I will try to figure out the concepts and put them there as I learn.

You can get math3d.scm here. You can experiment with it.

I could really use some help understanding this stuff, if you have better ideas for the API and things to have, fire up. If you find a bug, please PR on GitHub if you know how to fix.

I intend to provide a triplet vector (which may have a fourth element), quaternions, matrix and helpful transformation functions.

Also I like discussing this and will try to update this thread as I learn. The gif above links to a video showing me playing with a virtual camera.

Jack


eri0o

#2
Thanks Jack! the AGS project can be downloaded here as .zip. Fair warning, expect bugs and me failing to grasp concepts! XD

One cool addition is being able to create a Matrix like this:

Code: ags
Matrix* m = Matrix.CreateFromString("{{4,8},{2,3}}");

eri0o

I had an error in my code for the projection. I fixed.

There's still something wrong there but I could not tell... I updated the demo with a bit more stuff.

I don't know how to project a point in the screen back into the virtual world, so the block following the mouse is not working yet. Added a lamp to indicate the direction the block is facing. hold W to swim in the mouse direction and S to swim against it






Crimson Wizard

Quote from: eri0o on Wed 07/10/2020 02:21:36
I don't know how to project a point in the screen back into the virtual world

Similarily, only using inverse matrix/formulas in reverse order.

eri0o

AH, it must  be the order then! Thanks! I will try to add this next.

KyriakosCH

Yay, this looks great :)
So, how can I use it with the latest AGS?
This is the Way - A dark allegory. My Twitter!  My Youtube!

SMF spam blocked by CleanTalk