What's wrong with ScaleEntity?

Blitz3D Forums/Blitz3D Beginners Area/What's wrong with ScaleEntity?

Happy Sammy(Posted 2007) [#1]
Hi all,

Do you know what's wrong with these codes?
I did use scaleEntity cub, 1,.5,2 (not a cube)
However, cub appears as if without using scaleEntity (ie. still a cube)
If I use "cam = createCamera()" without parent inside, Everything is ok.
Why? Any ideas?
Thanks in advance

Graphics3D 640,480,16,2
SetBuffer BackBuffer()
lit = CreateLight()
cub = CreateCube()
ScaleEntity cub, 1,.5,2
cam = CreateCamera(cub)
PositionEntity cam,0,5,-10

pln = CreatePlane()
tex = LoadTexture("floor.bmp")
ScaleTexture tex, 10,10
EntityTexture pln,tex
PositionEntity pln, 0,-1,0

Repeat
	If KeyDown(200) MoveEntity cub, 0,0, .1
	If KeyDown(208) MoveEntity cub, 0,0,-.1
	If KeyDown(203) TurnEntity cub, 0,1,0
	If KeyDown(205) TurnEntity cub, 0,-1,0
	UpdateWorld
	RenderWorld
	Flip
Until KeyHit(1)
End



big10p(Posted 2007) [#2]
When the camera is parented to the cube, it's scale of 2x2x2 then refers to it's parent's coordinate system, not the global/world coord system. So, because the cube has been scaled, this effectively scales the camera to match, so the cube appears as though it hasn't been scaled.

You can remedy this by using ScaleEntity cam,2,2,2,True, which scales the camera to 2x2x2 in global/world scale.

[edit] Actually, that may have to be ScaleEntity cam,1,1,1,True. I can't remember what the default world scale is for cameras...


Happy Sammy(Posted 2007) [#3]
Thank you, big10p. I got it!

After parenting, Position or scale must be refer to global coorindate (using "true" parameter)

Graphics3D 640,480,16,2
SetBuffer BackBuffer()
lit = CreateLight()
cub = CreateCube()
ScaleEntity cub, 1,.5,2
cam = CreateCamera(cub)
PositionEntity cam,0,5,-10,true   ;<----- change to this
ScaleEntity cam,1,.5,2,true    ; <------ change to this

pln = CreatePlane()
tex = LoadTexture("floor.bmp")
ScaleTexture tex, 10,10
EntityTexture pln,tex
PositionEntity pln, 0,-1,0

Repeat
	If KeyDown(200) MoveEntity cub, 0,0, .1
	If KeyDown(208) MoveEntity cub, 0,0,-.1
	If KeyDown(203) TurnEntity cub, 0,1,0
	If KeyDown(205) TurnEntity cub, 0,-1,0
	UpdateWorld
	RenderWorld
	Flip
Until KeyHit(1)
End