3D Camera + Object Rotation

Graphic based area of development (Graphics Processing Unit), including the Geometry Transform Engine (GTE), TIM, STR (MDEC), etc.
Post Reply
Orion_
Verified
Legendary Programmer
Legendary Programmer
Posts: 240
Joined: Aug 13, 2012
I am a: Programmer
PlayStation Model: Net Yaroze
Location: France
Contact:

3D Camera + Object Rotation

Post by Orion_ » August 12th, 2013, 9:32 am

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 !
Retro game development on Playstation and other consoles http://orionsoft.free.fr/

User avatar
Shadow
Verified
Admin / PSXDEV
Admin / PSXDEV
Posts: 2670
Joined: Dec 31, 2012
PlayStation Model: H2000/5502
Discord: Shadow^PSXDEV

Post by Shadow » August 12th, 2013, 10:31 am

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.
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

Orion_
Verified
Legendary Programmer
Legendary Programmer
Posts: 240
Joined: Aug 13, 2012
I am a: Programmer
PlayStation Model: Net Yaroze
Location: France
Contact:

Post by Orion_ » August 12th, 2013, 11:45 am

the 3D studio max is for a very old version of 3Ds for DOS.
Retro game development on Playstation and other consoles http://orionsoft.free.fr/

User avatar
inc^lightforce
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 248
Joined: Mar 07, 2013
I am a: Programmer Windows+PS1, GFX Artist
PlayStation Model: Black
Location: Germany

Post by inc^lightforce » August 12th, 2013, 1:54 pm

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

Orion_
Verified
Legendary Programmer
Legendary Programmer
Posts: 240
Joined: Aug 13, 2012
I am a: Programmer
PlayStation Model: Net Yaroze
Location: France
Contact:

Post by Orion_ » August 12th, 2013, 7:32 pm

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.
Retro game development on Playstation and other consoles http://orionsoft.free.fr/

User avatar
inc^lightforce
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 248
Joined: Mar 07, 2013
I am a: Programmer Windows+PS1, GFX Artist
PlayStation Model: Black
Location: Germany

Post by inc^lightforce » August 12th, 2013, 11:03 pm

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.

Tommy
Active PSXDEV User
Active PSXDEV User
Posts: 48
Joined: Apr 19, 2014

Post by Tommy » April 22nd, 2014, 8:21 am

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests