GetMatElement() does not correspond to anything
Blitz3D Forums/Blitz3D Programming/GetMatElement() does not correspond to anything
| ||
I am trying to save an .x file, but the Blitz matrix does not appear to correspond to DX matrices:WriteLine f,GetMatElement(bone,0,0)+","+GetMatElement(bone,0,1)+","+GetMatElement(bone,0,2)+","+GetMatElement(bone,0,3)+"," WriteLine f,GetMatElement(bone,1,0)+","+GetMatElement(bone,1,1)+","+GetMatElement(bone,1,2)+","+GetMatElement(bone,1,3)+"," WriteLine f,GetMatElement(bone,2,0)+","+GetMatElement(bone,2,1)+","+GetMatElement(bone,2,2)+","+GetMatElement(bone,2,3)+"," WriteLine f,GetMatElement(bone,3,0)+","+GetMatElement(bone,3,1)+","+GetMatElement(bone,3,2)+","+GetMatElement(bone,3,3)+";;" |
| ||
It's a 3x4 matrix, not a 4x4 matrix. So basically you need to fill in the last column yourself. Which is always 0,0,0,1. It is also a global matrix so if you are trying to do a hierachy, you need to do a bit of mucking about yourself. |
| ||
It's still just gibberish. Some of the matrices are actually skewed:WriteLine(f,GetMatElement(bone,0,0)+","+GetMatElement(bone,0,1)+","+GetMatElement(bone,0,2)+",0.0,") WriteLine(f,GetMatElement(bone,1,0)+","+GetMatElement(bone,1,1)+","+GetMatElement(bone,1,2)+",0.0,") WriteLine(f,GetMatElement(bone,2,0)+","+GetMatElement(bone,2,1)+","+GetMatElement(bone,2,2)+",0.0,") WriteLine(f,EntityX(bone,0)+","+EntityY(bone,0)+","+EntityZ(bone,0)+",1.0;;") |
| ||
Global <> Local |
| ||
Even so, that would only effect rotations. Each matrix should still not be skewed. |
| ||
If you have scaled the parent it is skewed. Otherwise you are doing something weird. |
| ||
If it's global, then this should work, but again, it is gibberish:bone1=CreatePivot() PositionEntity bone1,EntityX(bone),EntityY(bone),EntityZ(bone) RotateEntity bone1,EntityPitch(bone),EntityYaw(bone),EntityRoll(bone) WriteLine(f,GetMatElement(bone1,0,0)+","+GetMatElement(bone1,0,1)+","+GetMatElement(bone1,0,2)+",0.0,") WriteLine(f,GetMatElement(bone1,1,0)+","+GetMatElement(bone1,1,1)+","+GetMatElement(bone1,1,2)+",0.0,") WriteLine(f,GetMatElement(bone1,2,0)+","+GetMatElement(bone1,2,1)+","+GetMatElement(bone1,2,2)+",0.0,") WriteLine(f,EntityX(bone1,1)+","+EntityY(bone1,1)+","+EntityZ(bone1,1)+",1.0;;") FreeEntity bone1 |
| ||
To what is it gibberish? That works perfectly fine. |
| ||
Dammit, the x file code won't fit in this. |
| ||
Here is my function for writing the hierarchy:Function XWriteBones(bone,f,tab$="") WriteLine(f,tab+"Frame "+Entityname(bone)) WriteLine(f,tab+" {") WriteLine(f,tab+" FrameTransformMatrix") WriteLine(f,tab+" {") temp=CreatePivot() PositionEntity temp,EntityX(bone),EntityY(bone),EntityZ(bone) RotateEntity temp,EntityPitch(bone),EntityYaw(bone),EntityRoll(bone) WriteLine(f,tab+" "+GetMatElement(temp,0,0)+","+GetMatElement(temp,0,1)+","+GetMatElement(temp,0,2)+",0.0,") WriteLine(f,tab+" "+GetMatElement(temp,1,0)+","+GetMatElement(temp,1,1)+","+GetMatElement(temp,1,2)+",0.0,") WriteLine(f,tab+" "+GetMatElement(temp,2,0)+","+GetMatElement(temp,2,1)+","+GetMatElement(temp,2,2)+",0.0,") WriteLine(f,tab+" "+EntityX(temp)+","+EntityY(temp)+","+EntityZ(temp)+",1.0;;") WriteLine(f,tab+" }") FreeEntity temp For c=1 To CountChildren(bone) XWriteBones(GetChild(bone,c),f,tab+" ") Next WriteLine(f,tab+" }") End Function |
| ||
And what exactly is the problem, then? |
| ||
It works now. I had to do some weird scaling stuff for the orthographic camera to work. The longer I have been coding, the less patience I have when I run into a problem. Thanks for trying. |
| ||
What are you loading the file into? You can probably post the x file in a codebox (codebox)...(/codebox) replace () with [] |