Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Transformation Matrix in an Object

Author
Message
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 31st May 2003 19:35
I am gonna create my own shading routine for each of the object in my game. Therefore, I will need to use Vertex and Pixel Shader for this. Due to this, I can't use the DBpro command like:

- ROTATE OBJECT
- POSITION OBJECT
- SCALE OBJECT

All object transformation like rotation, translation, and scaling need to be done in my vertex shader routine.

Is there anyway to access the object's internal transformation matrix so that I can pass them directly to my vertex shader? Right now, the only way I can think of is to create the matrix myself and fill them with the appropriate object's transformation data by calling OBJECT POSITION, OBJECT ROTATION, etc.

Any better ideas? Thanks!
Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 31st May 2003 20:52
Maybe SET VERTEX SHADER STREAM can help?

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_102.zip
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 1st Jun 2003 05:20
Erm.. thanks Rob. But I think you got me wrongly.

SET VERTEX SHADER STREAM is just for setting the properties, i.e. position, normals, diffuse color, etc. that you want them to appear in the vertex shader input registers.

What I meant is, how do I get the transformation matrix (rotation, translation and scale matrix) of a model (or OBJECT in the context of DBpro), so that I can passed them to the vertex shader via SET VERTEX SHADER MATRIX.

Thanks!

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
The Darthster
23
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 1st Jun 2003 14:23
I don't know much about the 3d maths commands, but can you use rotate ypr matrix4, scale matrix4 and translate matrix4 with the properties of the object to get the desired matrix?

Once I was but the learner,
now, I am the Master.
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 1st Jun 2003 16:38
Yes, that's the only way I can think of now. I was just wondering is there any other easier way to do this? Maybe just need a command to get the object transformation matrix?

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
ozak
23
Years of Service
User Offline
Joined: 22nd May 2003
Location: Denmark
Posted: 2nd Jun 2003 16:40
Aren't these passed in constant registers to the vertex shader?
(Just a guess, havent' touched shaders in a while
Check the DirectX SDK docs for this

Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 3rd Jun 2003 16:17
Yes, you got it ozak! Those transformation matrix will be eventually passed into my vertex shader using constant register.

The question is, whether is there any shortcut I can get the transformation matrix of an object? The way that I do now is,

1. Create a matrix
2. Set the position of the object into the matrix.
3. Create another matrix
4. Set the rotation of the object into it.
5. Create another matrix.
6. Set the scale of the object into it.
7. Concatenate all 3 matrices into one single matrix using matrix multiplication.

The concatenated matrix is what I meant by object transformation matrix. The question is, whether is there any shortcut to get this matrix, without going through all those hassles? I believe DBpro will have this matrix store internally, just that whether it is accessible to programmers or not.

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
The Darthster
23
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 3rd Jun 2003 18:52
I assume you're not multiplying those matrices together in the same order as you created them. Can't you just work out the complete matrix on paper first then feed the correct values in afterwards?

Once I was but the learner,
now, I am the Master.
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 4th Jun 2003 05:42
Nope, I can't. The position and rotation of the object will change every frame.

Oh, BTW, the multiplication order of the matrices are
Scaling * Rotation * Translation

Is that correct?

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
The Darthster
23
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 4th Jun 2003 17:26
You can work out the matrix using variables as the position and angles on paper, and then just substitute the numbers in, no?

Yeah that looks right to me. I suppose if you were translating before you rotated you'd probably have noticed by now.

Once I was but the learner,
now, I am the Master.

Login to post a reply

Server time is: 2026-07-11 14:55:37
Your offset time is: 2026-07-11 14:55:37