GetMatElement questions.

Blitz3D Forums/Blitz3D Beginners Area/GetMatElement questions.

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

http://www.kcstudios.net/testlevel1.zip


I seperate the objects in the 3ds by loading it useing
Function Obj_LoadMesh(FileName$="", MeshHandle=0)
	Local ChlCnt=0,ChlInd=0,ChlHndl=0
	If FileName$ <> "" Then MeshHandle=LoadAnimMesh(FileName$)

	If MeshHandle <> 0 Then
		ChlCnt = CountChildren(MeshHandle)
		If ChlCnt > 0 Then
			For ChlInd = 1 To ChlCnt
				ChlHndl = GetChild(MeshHandle,1)
				If ChlHndl <> 0 Then Obj_LoadMesh("", ChlHndl)
			Next
		Else
			Obj_Add(MeshHandle)	
			EntityParent(MeshHandle,0)
		EndIf	
	EndIf
End Function


for each object that goes into Obj_Add() is is done the following to:
Function Obj_Add(ObjHandle=0)
	Local Obj.ObjList
		Obj.ObjList 		=New ObjList
		Obj\ID 				=ObjID_Index:ObjID_Index=ObjID_Index+1
		Obj\ObjHandle 		=ObjHandle
		Obj\Name$			=EntityName$(Obj\ObjHandle)
		Obj\X#				=EntityX#(Obj\ObjHandle,1)
		Obj\Y#				=EntityY#(Obj\ObjHandle,1)
		Obj\Z#				=EntityZ#(Obj\ObjHandle,1)		
		Obj\ORX#				=EntityPitch#(Obj\ObjHandle,1)
		Obj\ORY#				=EntityYaw#(Obj\ObjHandle,1)	
		Obj\ORZ#				=EntityRoll#(Obj\ObjHandle,1)
		;Set rotation and position to 0,0,0 to extract the scale factor of getmatelement
		RotateEntity(Obj\ObjHandle,0,0,0,1)
		PositionEntity(Obj\ObjHandle,0,0,0,1)
		ESX# = GetMatElement(Obj\ObjHandle,0,0)
		ESY# = GetMatElement(Obj\ObjHandle,1,1)
		ESZ# = GetMatElement(Obj\ObjHandle,2,2)
                ;We have the scale, now put the scale to 1, position and rotate the mesh
		ScaleEntity(Obj\ObjHandle,1,1,1)
		PositionEntity(Obj\ObjHandle,Obj\X#,Obj\Y#,Obj\Z#)
		RotateMesh(Obj\ObjHandle,Obj\ORX#,Obj\ORY#,Obj\ORZ#)
                ;Now scale the mesh by it's scaled value
		ScaleMesh(Obj\ObjHandle,ESX#,ESY#,ESZ#)
		Return Obj\ID

End Function


When I load the 3ds file useing the above 2 functions (the loader to seperate the children from the parent, then adding each to the list to reset the position, rotation, scale) all the platforms are at 90 degree angles along the Y axis. They are all positioned and scaled correctly.

Reason I position entity rather then positionmesh, is that when I save the file (in my own format) i want the mesh relative to its position from the 3ds file.
Reason I use rotatemesh rather then rotateentity, is because I want all rotation and such in the editor done from a 0,0,0 refference that way I am not fighting blitz rotations when doing simple animations with position/rotation. A starting point of 0,0,0 (0,0,0 being the whatever rotation it was placed in 3ds max).
I have tried scaleentity(mesh,1,1,1) and it makes everything really small. Even by doing a conversion to an editable mesh in max, I still get odd scale values by scalin it to 1,1,1 in blitz.

Thanks for your help thus far by the way, I appreciate it.

Any Thoughts?