GetMatElement() does not correspond to anything

Blitz3D Forums/Blitz3D Programming/GetMatElement() does not correspond to anything

JoshK(Posted 2004) [#1]
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)+";;"



fredborg(Posted 2004) [#2]
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.


JoshK(Posted 2004) [#3]
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;;")



fredborg(Posted 2004) [#4]
Global <> Local


JoshK(Posted 2004) [#5]
Even so, that would only effect rotations. Each matrix should still not be skewed.


fredborg(Posted 2004) [#6]
If you have scaled the parent it is skewed. Otherwise you are doing something weird.


JoshK(Posted 2004) [#7]
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



fredborg(Posted 2004) [#8]
To what is it gibberish? That works perfectly fine.


JoshK(Posted 2004) [#9]
Dammit, the x file code won't fit in this.


JoshK(Posted 2004) [#10]
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



fredborg(Posted 2004) [#11]
And what exactly is the problem, then?


JoshK(Posted 2004) [#12]
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.


fredborg(Posted 2004) [#13]
What are you loading the file into?

You can probably post the x file in a codebox
(codebox)...(/codebox) replace () with []