Whats going on here ?

Blitz3D Forums/Blitz3D Programming/Whats going on here ?

PaulJG(Posted 2003) [#1]
I've got this little program which just doesnt want to behave as it should..

Whats wrong with it ????

Graphics3D 800,600,32,2
SetBuffer BackBuffer()

light=CreateLight()

box=CreateCube()
PositionEntity box,0,0,0
ScaleEntity box,1,0.5,1; <-- THIS LINE

camerapivot=CreatePivot(box)
camera=CreateCamera(camerapivot)
MoveEntity camera,0,0,-7

While Not KeyHit(1)
If KeyDown(200) MoveEntity camera,0,0,0.5
If KeyDown(203) TurnEntity camerapivot,0,-1,0
If KeyDown(205) TurnEntity camerapivot,0,1,0
If KeyDown(208) MoveEntity camera,0,0,-.5
UpdateWorld
RenderWorld
Flip
Wend
 End


As you can see its nothing special, just creates a box, a pivot and finally a camera.

But for some reason the 'scaleentity' command on the box wont take effect. No matter the values or size, it just wont change ?.

Is this a bug ? (since the box is the main entity for the others) - or am I doing something wrong ??

Thanks Paul.


darklordz(Posted 2003) [#2]
Look. You created a pivot with the box as a parent. The pivot causes the box look exactly the same as it does but in fact the box is twisted :P. Just use the folowing
Graphics3D 800,600,32,2
SetBuffer BackBuffer()

light=CreateLight()

box=CreateCube()
PositionEntity box,0,0,0
ScaleEntity box,1,0.5,1

camerapivot=CreatePivot()
camera=CreateCamera(camerapivot)
MoveEntity camera,0,0,-7

While Not KeyHit(1)
	If KeyDown(200) MoveEntity camera,0,0,0.5
	If KeyDown(203) TurnEntity camerapivot,0,-1,0
	If KeyDown(205) TurnEntity camerapivot,0,1,0
	If KeyDown(208) MoveEntity camera,0,0,-.5
UpdateWorld
RenderWorld
Flip
Wend
End



PaulJG(Posted 2003) [#3]
Thanks. :)

Although really that was what I wanted.. so that both the pivot and camera would move with the shape.

Can't see why making the pivot a child of the object should make it behave like that though ?. (perhaps more of a bug ??)

Anyway, cheers for the advice - I'll just have to work around it.


DJWoodgate(Posted 2003) [#4]
Its not a bug. Scaling is relative in a hierarchy. ScaleEntity camera,1,1,1,True after parenting might help. Alternatively you can avoid the issue by using scalemesh on the box instead of scaleentity.


Floyd(Posted 2003) [#5]
Experiment with this.
Graphics3D 800,600,32,2

light=CreateLight()

box=CreateCube()  :  PositionEntity box,0,0,0

camera=CreateCamera()  :  MoveEntity camera,0,0,-7

ScaleEntity camera, 1, 2, 1
ScaleEntity box, 1, 2, 1

RenderWorld  :  Flip  :  WaitKey


Camera and box are scaled identically. The result is no visible change.
Try scaling just the camera, then just the box.
You can see why doing both will cancel out.

Child entities inherit the scale of the parent.
So in the original example the box and camera had the same scale.