GetMatElement

Blitz3D Forums/Blitz3D Beginners Area/GetMatElement

Yue(Posted 2012) [#1]
For GetMaterialElement serves a practical example please.


Charrua(Posted 2012) [#2]
Mat isn't for Material, is for Matrix

as the help says, a Transformation Matrix is used for: Scale, Position and Rotation of Blitz entities.

if you want an example of getting x, y z scale from this matrix:

(this functions aren't mine)

; -------------------------------------------------------------------------------------------------------------------
; This function returns the X axis scale of an entity, as set by ScaleEntity().
; -------------------------------------------------------------------------------------------------------------------
Function EntityScaleX#(Entity)
	
	Local Scale#, X#, Y#, Z#

	X# = GetMatElement(Entity, 0, 0)
	Y# = GetMatElement(Entity, 0, 1)
	Z# = GetMatElement(Entity, 0, 2)	
	
	Scale# = Sqr(X#*X# + Y#*Y# + Z#*Z#)
	
	Return Scale#

End Function

; -------------------------------------------------------------------------------------------------------------------
; This function returns the Y axis scale of an entity, as set by ScaleEntity().
; -------------------------------------------------------------------------------------------------------------------
Function EntityScaleY#(Entity)
	
	Local Scale#, X#, Y#, Z#
	
	X# = GetMatElement(Entity, 1, 0)
	Y# = GetMatElement(Entity, 1, 1)
	Z# = GetMatElement(Entity, 1, 2)	
	
	Scale# = Sqr(X#*X# + Y#*Y# + Z#*Z#)
	
	Return Scale#

End Function

; -------------------------------------------------------------------------------------------------------------------
; This function returns the Z axis scale of an entity, as set by ScaleEntity().
; -------------------------------------------------------------------------------------------------------------------
Function EntityScaleZ#(Entity)
	
	Local Scale#, X#, Y#, Z#
	
	X# = GetMatElement(Entity, 2, 0)
	Y# = GetMatElement(Entity, 2, 1)
	Z# = GetMatElement(Entity, 2, 2)	
	
	Scale# = Sqr(X#*X# + Y#*Y# + Z#*Z#)
	
	Return Scale#



regards

Juan


Yue(Posted 2012) [#3]
ok thanks, I was confused with the material.