TFormNormal Not Working?

BlitzMax Forums/MiniB3D Module/TFormNormal Not Working?

BLaBZ(Posted 2013) [#1]
Hey guys,

I can't seem to get TFormNormal to return any results other than -1

I'm trying to get cube1's normal of cube2

Import sidesign.minib3d

Graphics3D(800,600,0,2)

Global cam:TCAmera = CreateCamera()
PositionEntity cam,0,0,-10

Global light:TLight = CreateLight()

Global cube1:TMesh = CreateCube()


Global cube2:TMesh = CreateCube()
PositionEntity cube2,0,5,0


Global pointX:Float 
Global pointY:Float
Global pointZ:Float

Global vectX:Float
Global vectY:Float
Global vectZ:Float

Global normX:Float
Global normY:Float
Global normZ:Float

Global dpitch:Float
Global dyaw:Float


SetBlend(ALPHABLEND)
While Not KeyHit(KEY_ESCAPE)

	TFormPoint  0,0,0,cube1,cube2
	pointX = TFormedX()
	pointY = TFormedY()
	pointZ = TFormedZ()
	
	TFormVector 0,0,0,cube1,cube2
	vectX = TFormedX()
	vectY = TFormedY()
	vectZ = TFormedZ()
	
	TFormNormal 0,0,0,cube1,cube2
	normX = TFormedX()
	normY = TFormedY()
	normZ = TFormedZ()
	
	dpitch = DeltaPitch(cube1,cube2)
	dyaw = DeltaYaw(cube2,cube1)
	
	If KeyDown(KEY_LEFT) Then MoveEntity(cube2,-0.5,0,0)
	If KeyDown(KEY_RIGHT) Then MoveEntity(cube2,0.5,0,0)
	If KeyDown(KEY_UP) Then MoveEntity(cube2,0,0.5,0)
	If KeyDown(KEY_DOWN) Then MoveEntity(cube2,0,-0.5,0)
	
	If KeyDown(KEY_A) Then MoveEntity(cube1,-0.5,0,0)
	If KeyDown(KEY_D) Then MoveEntity(cube1,0.5,0,0)
	If KeyDown(KEY_W) Then MoveEntity(cube1,0,0.5,0)
	If KeyDown(KEY_S) Then MoveEntity(cube1,0,-0.5,0)
	
	If KeyDown(KEY_Z) Then TurnEntity(cube1,0,-1,0)
	If KeyDown(KEY_X) Then TurnEntity(cube1,0,1,0)
	
	If KeyDown(KEY_C) Then TurnEntity(cube2,0,-1,0)
	If KeyDown(KEY_V) Then TurnEntity(cube2,0,1,0)

	RenderWorld

	BeginMax2d()

		DrawText "PX: " + pointx,0,0
		DrawText "PY: " + pointy,0,12
		DrawText "PZ: " + pointz,0,24
		
		DrawText "VX: " + vectX,0,48
		DrawText "VY: " + vectY,0,60
		DrawText "VZ: " + vectZ,0,72
		
		DrawText "NX: " + normX,0,96
		DrawText "NY: " + normY,0,108
		DrawText "NZ: " + normZ,0,120
		
		DrawText "EX: " + EntityX(cube2),0,144
		DrawText "EY: " + EntityY(cube2),0,156
		DrawText "EZ: " + EntityZ(cube2),0,168	
		
		DrawText "DP: " + dpitch,0,192
		DrawText "DY: " + dyaw,0,204	
		
	EndMax2d()

	Flip
	Cls

Wend



Floyd(Posted 2013) [#2]
It's not clear what you are trying to do here. The result of TFormNormal applied to 0,0,0 is not defined. In real Blitz3D it would produce NaN rather than -1.

You can find a description of TFormNormal in the Blitz3D online manual http://blitzbasic.com/b3ddocs/command.php?name=tformnormal&ref=goto
Scroll down to the comments to see what it really does.