Matrices and Java3D

I have been using Java3D for awhile now and I just realized how I have managed to survive without matrices. I have read all articles concerning matrices at Gamedev.net awhile ago when I was doing 3D with c++.

In c++ I thought matrices were quite easy concept to grasp. I mean its not its like rocket science, since everything is like pregenerated for you. While I understood what a matrix is, using a pregenerated matrix api, pretty much cut me off from raw matrix manipulation. I handled creating object space and such. So no raw math for me.

Now I needs to understand what is Java3Ds relationship with matrices. I understand that Transform3D = my buddy, but I can’t see any demos using any raw math.

As I plan to use Matrix4f as my base matrix, what kind of arithmetic progression should I use as the base numbers. I mean the quides gave me understanding of what the these things are and what to do with them, they failed to inform what to store in a matrix. I assume I’m supposed to store cordinates in there. How do I do this? Do I just create a matrix4f(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} like this? Natural light of reason tells me that this is wrong.

Now I need to create object space to interact with my camera so that I can easily rotate things in there and set up my hud.

I might as well stop sounding intelligent, hence WTF.

How the hell am I supposed to create object space and manipulate it with Transform3D? I have a faint clue that Scenegraph and transform group might be something similar to the object space? Could someone who has done some direct3D programming please explaing what equals what?

Its kind of hard to try to guess what something is supposed to do from the docs, I mean as far as java tutorials go is creating universe and adding behaviors. Someone should explain what to use for rotation and what to use for creating the object/camera space interaction.

Thanks for your time.

Damnit, I wrote a much longer reply but it must have been eaten by the power goblins ( http://www.penny-arcade.com/view.php3?date=2002-11-25&res=l ).

Basically, matricies can be thought of as 4 vectors, typically aranged vertically, which are the x, y and z axies and a translation. Thus you perform a rotation/scale/shear by messing with the vectors, and can represent any arbitary transformation in a single matrix. By multiplying two matricies together you form a new matrix with is the result of both transforms. By multiplying a point by a matrix, it is transformed by the operations represented in the matrix. You transform a vector in the same way, except that you don’t perform any translation.

Spaces then… World space is your entire virtual universe, with some arbitrary reference point. This origin may be a corner of your level, middle of your heightmap, center of the earth etc. It contains everything that is ‘physical’ in your game (and a few things that aren’t :o ) Object space is a things personal coordinate system - say when you create your 3d model, this is where the origin is, the center of a ball, the feet of a person, etc. Camera space is that with the origin centered on the camera, usually with the x axis going left/right, the y up and the z into the screen.

Moving from one space to another is (easily?) represented by a matrix transformation. So, object->world will be how your model should be positioned in the world in regard to everything else. World->camera defines how a world is viewed, the world is moved into the camera space at the correct position, and hence the camera appears to move around the world. Then usually you multiply by a projection matrix to collapse the whole scene (still fully 3d and orientated around the camera) into a single flat plane - possibly appying perspective whilst doing so. Now wash, rinse and repeat for every single vertex, and you’re halfway to having a complete frame drawn…

Moving backwards along this chain is done by multiplying by the inverse matrix at each point (note that you can’t usually undo the projection matrix though, you’ll get a line in space, not a point). Finding the inverse of a matrix is something i’ve managed to avoid so far, the maths gets a tad sticky. There may be a function in j3d for this, I can’t remember though.

That may or may not have made no sense at all :-[ Hopefully it gives you some ideas though…

I understand your text and it is quite logical. I just ordered some basic matrice math books that should cover the raw math part for me. I have always liked doing the raw mathematics myself.

Now however, as I’m using Java3D, where do matrices come in? What do I use to create the object space or is it created for me? I have seen many objects and not a single matrix in the demos. Its extremely confusing.

Some people make it sound like rocket science although I find it hard to believe since I have seen a lot harder things in my life.

WHEEE-E!

I’m starting to actually understand this stuff.

I understand how these things work in Java3D, in fact I don’t have to do too much math myself, which is quite disappointting(not really), since java being my buddy handles this.

However, many things are still left unclear. Do I have to create a new matrix every time I want to do rotation, or do I just have basic rotation matrix, which is good for all classes?

BWAHHAHAHAHA

I just figured it all out. I can get the matrix from the transform3D and thats my object space, right? Now I just perform whatever I want, perhaps two matirix multiplications? Or perhaps vertex operation? Invert?

Basically just by understanding java docs I could get by without even the most primitive grasp on the matrix math. This is of course Java3D. I have great hopes for this java addon and btw I love Sun. I still get to do some maths though since I’m building a physics engine ^^.

It would be easier to repy if you explained your problem in full - what exactly is it that you need to perform in object space that requires you delving into matricies?

But yeah, most of j3d you can get by without knowing anything about them, like i did with my j3d stuff (although the geomorphing did need quite a bit of vector math ;D )

There is no problem. I i just got out of the matrix or something and know kung fu(maybe?).

One thing I got. What are the limitations of the matrix acquired from, lets say Transform3D? I mean what kind of form does it come out. I did some testing, but couldn’t really figure out.

Limitations? None really, you can represent any arbitrary combination of transforms in a single 4x4. The upper left will be the rotate/scale/shear, the far right collumn the translation and the very bottom right value the homogeneous coord.

grab this for a good maths read

Complete Maths Engine
http://rucus.ru.ac.za/~xsist10/downloads/