July 04, 2022, 02:50:50 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!

Transforming a Vertice

Started by RG, May 20, 2008, 07:43:21 PM

0 Members and 1 Guest are viewing this topic.

RG

May 20, 2008, 07:43:21 PM
I've been reading and searching direct3D tutorials but haven't found the answer so thought I'd ask here. I have a program that creates a mesh which I can display, rotate and move without problem. Next I want to be able to move a vertice in the mesh independent of the mesh itself. I need to take the x,y,z coordinates and multiply that by the 4x4 transformation matrix. Is there a simple way in ebasic to multiply a vector (which contain the coordinates) with a matrix? Or how do I retrieve the individual elements from the matrix?

Thanks, Rich

Ionic Wind Support Team

May 20, 2008, 08:13:39 PM #1
Rich,
If I read your question correctly then MatrixTranslation(MATRIX4 mat, FLOAT  x, FLOAT  y, FLOAT  z) is the function your looking for. It's in the users guide.

Paul.
Ionic Wind Support Team

RG

May 21, 2008, 07:40:05 PM #2 Last Edit: May 22, 2008, 08:38:31 PM by RG
Thanks Paul. This may get me on the right track. I had seen this but only thought of it as a way to translate the object not a vertice. Let me play with this a bit.

Rich

RG

May 22, 2008, 08:31:48 PM #3 Last Edit: May 22, 2008, 08:38:56 PM by RG
I was trying to use these commands from the users guide:

MATRIX4 matresult, matpos, matrot
MatrixIdentity(matrot)
MatrixTranslation(matpos, 25.0, 10.0, -2)
MatrixRotation(matrot, 90 * 0.01745, 0, 0)
MatrixMultiply(matresult, matpos, matrot)

but I got compiler errors:

Compiling...
vasemaker001.eba
File: C:\Program Files\EBDev\projects\3D samples\vasemaker001.eba (569) Warning: undeclared function 'MatrixIdentity' - )
File: C:\Program Files\EBDev\projects\3D samples\vasemaker001.eba (570) Warning: undeclared function 'MatrixTranslation' - )
File: C:\Program Files\EBDev\projects\3D samples\vasemaker001.eba (571) Warning: undeclared function 'MatrixRotation' - )
File: C:\Program Files\EBDev\projects\3D samples\vasemaker001.eba (572) Warning: undeclared function 'MatrixMultiply' - )
C:\Program Files\EBDev\projects\3D samples\vasemaker001.a:7798: error: symbol `MatrixIdentity' undefined
C:\Program Files\EBDev\projects\3D samples\vasemaker001.a:7824: error: symbol `MatrixTranslation' undefined
C:\Program Files\EBDev\projects\3D samples\vasemaker001.a:7856: error: symbol `MatrixRotation' undefined
C:\Program Files\EBDev\projects\3D samples\vasemaker001.a:7866: error: symbol `MatrixMultiply' undefined
C:\Program Files\EBDev\projects\3D samples\vasemaker001.a:10996: error: phase error detected at end of assembly.
Error(s) in assembling "C:\Program Files\EBDev\projects\3D samples\vasemaker001.a"

I noticed the functions like MatrixIdentity did not show in the popup box in the IDE nor did they change color. Looking into the ebx3d.incc, I saw these commands had a dx in front of them. When I converted the commands to:

dxMatrixIdentity(matrot)
dxMatrixTranslation(matpos, 25.0, 10.0, -2)
dxMatrixRotation(matrot, 90 * 0.01745, 0, 0)
dxMatrixMultiply(matresult, matpos, matrot)

They did show in the popup box and with a blue color, making it look like this was the proper spelling. However I get the following compiler message:

Compiling...
vasemaker001.eba
No Errors

Unresolved external __imp_dxMatrixIdentity
Error: Unresolved extern __imp_dxMatrixIdentity
Error: Unresolved extern __imp_dxMatrixTranslation
Error: Unresolved extern __imp_dxMatrixRotation
Error: Unresolved extern __imp_dxMatrixMultiply
Error(s) in linking C:\Program Files\EBDev\projects\3D samples\vasemaker001.exe

Not clear to me what I'm doing wrong.

Rich

LarryMc

May 23, 2008, 01:02:28 AM #4 Last Edit: May 23, 2008, 01:07:59 AM by Larry McCaughn
Appears there is a naming mismatch somewhere.

In the ebx3d.incc file you have:`\$command CDECL IMPORT, dxMatrixIdentity(mat as MATRIX4)\$command CDECL IMPORT, dxMatrixTranslation(mat as MATRIX4,x as FLOAT,y as FLOAT,z as FLOAT)\$command CDECL IMPORT, dxMatrixRotation(mat as MATRIX4,x as FLOAT,y as FLOAT,z as FLOAT)\$command CDECL IMPORT, dxMatrixMultiply(out as MATRIX4,m1 as MATRIX4,m2 as MATRIX4)`
I got a file to compile by using :`MATRIX4 matresult, matpos, matrotMatrixIdentity(matrot)MatrixTranslation(matpos, 25.0, 10.0, -2)MatrixRotation(matrot, 90 * 0.01745, 0, 0)MatrixMultiply(matresult, matpos, matrot)`
after I changed the ebx3d.incc lines to:`\$command CDECL IMPORT, MatrixIdentity(mat as MATRIX4)\$command CDECL IMPORT, MatrixTranslation(mat as MATRIX4,x as FLOAT,y as FLOAT,z as FLOAT)\$command CDECL IMPORT, MatrixRotation(mat as MATRIX4,x as FLOAT,y as FLOAT,z as FLOAT)\$command CDECL IMPORT, MatrixMultiply(out as MATRIX4,m1 as MATRIX4,m2 as MATRIX4)`

Have no idea if the functions even work when I do that but at least it compiled and makes me think(based upon your results and my results) that there is a name mismatch somewhere. Possibly missing aliases?

Paul will probably tell me I'm all wet as usual and it's us doing something totally wrong.

Larry
LarryMc
Larry McCaughn
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

RG

May 23, 2008, 05:28:58 PM #5 Last Edit: May 23, 2008, 05:35:24 PM by RG
Larry,

Thanks! I had the same thought but was hesitant to mess with the .incc file. But I went ahead and deleted the extra dx's and it appears to work. I made a small console program, used the MatrixIdentity command, and printed out the matrix. It looks as it should with diagonal one's.

`OPENCONSOLEMATRIX4 matresultMatrixIdentity(matresult)FOR i=0 to 3 PRINT matresult.m[i,0],matresult.m[i,1],matresult.m[i,2],matresult.m[i,3]NEXT iPRINTPRINT "Press Any Key To Close"DOUNTIL INKEY\$ <> ""CLOSECONSOLEEND`

I did the same with the other matrix commands and they appear to work too.

Now I can move forward

Rich

RG

May 23, 2008, 08:24:52 PM #6
Now I'm even happier    Was able to get vertice translation and rotation to work in my vasemaker program. After I add some controls, I'll publish an updated version.

RG

June 07, 2008, 04:17:25 PM #7 Last Edit: June 07, 2008, 04:58:24 PM by RG
Used these learnings to revise Vasemaker code:

http://www.ionicwind.com/forums/index.php/topic,2000.0.html