Page 1 of 1

3D Camera + Object Rotation

Posted: August 12th, 2013, 9:32 am
by Orion_
Hello,
I've been trying to code a simple flat software rendered 3D engine since 10 years, and somewhat succeed on other retro platform, now I see that the psx avec 3D facilities, matrix routines, and texturing function ready to use !
That is very nice, so I started using the ddoodm tutorial posted here, but this is only for rotating one object.
I would like to have a world, of object rotating individually and a camera.
So I guess I must have one matrix per object, and one matrix for the camera.
What I don't understand is how to combine these matrix, I tried MatrixMul0 but it doesn't work.
Any guess ?
Note: I don't use TMD function here, simply because I can't find any good usable 3D program exporting in TMD format.

I wish there were some leaked psx game source so we could learn from that !

Re: 3D Camera + Object Rotation

Posted: August 12th, 2013, 10:31 am
by Administrator
You export a 3DS file from 3D Studio MAX and then convert to a TMD using 3DS2RSD :)
There is also a 3D Studio MAX plugin available.

Re: 3D Camera + Object Rotation

Posted: August 12th, 2013, 11:45 am
by Orion_
the 3D studio max is for a very old version of 3Ds for DOS.

Re: 3D Camera + Object Rotation

Posted: August 12th, 2013, 1:54 pm
by inc^lightforce
hm. why not exporting from 3dsmax to DXF to TMD? no plugin needed.
i use it in that way very easy.
here is a simple 3d logo used with the matrix code:
http://rghost.net/private/48060251/2d96 ... 2b93c63d27

Re: 3D Camera + Object Rotation

Posted: August 12th, 2013, 7:32 pm
by Orion_
and how do you texture your 3D model ?
DXF doesn't preserve texture info. I'm not talking about spinning a simple 3D object, I want to make a 3D game which is a lot different.

Re: 3D Camera + Object Rotation

Posted: August 12th, 2013, 11:03 pm
by inc^lightforce
ah okay. i'm using RSD Tool for Texturing. i have no Idea if it's working for Game Objects too. But if am i right, i know i have a Game design Tool. I'll check back when i found it.

Re: 3D Camera + Object Rotation

Posted: April 22nd, 2014, 8:21 am
by Tommy
Assuming you're talking about a bunch of different objects that all move individually, one of which is the player, you'd normally retain position and orientation for each individually. In something like Battlezone position may be a 2d vector (it's a 2d battleground) and orientation a single scalar (just for rotation around y). In something more like Elite it's going to be a 3d vector for position and something more complicated than a scalar for orientation — possibly a 3x3 matrix directly, possibly a quaternion, possibly something else.

The generic way to proceed is then to build a 4x4 matrix for each of those objects. One of those matrices is going to represent the position and orientation of the camera. Each model is then going to be transformed by a composition of the two.

But: all other things being equal you want to use the inverse of the camera matrix. I think that follows most intuitively if you think about what the camera is describing. If the camera is at (10, 3) then you want to draw the world as though (10, 3) is the origin. So you want to undo the movement to (10, 3).

The same argument, another way around: imagine you have a model exactly glued to the camera. So both model and camera produce the same 4x4 matrix. Where do you want to draw that model every frame? Always at the origin. So you want the identity transform. So what, by definition, do you multiply a quantity by to produce the identity?

In practice most camera matrices are special orthogonal — they describe three basis vectors that are mutually orthogonal and each is of unit length. The good thing about those is that the inverse is very cheap to computer; just transpose the top left 3x3 and then do some simple arithmetic on the position. Have a quick go on a piece of paper.

Depending on how simple your engine is, you may be able to simplify even further. E.g. in something like Battlezone you can just use the difference between player and object positions and the difference between player and object rotation directly to form the final matrix without any intermediate matrix manipulation steps. Most games also differentiate between the static geometry that forms the world and the moving geometry within it — no need to worry about transformation matrices on the static stuff (unless it's more efficient to for precision reasons), just use the inverted camera matrix directly.