I think I have found a bug: If you have scaled an Entity to another value than 1,1,1, then If you use RotateEntity the mesh is scaled wrong the way. eg: a sphere looks more like an oval than a sphere.
here is a modified primitives sample which should demonstrate the problem.
Import "../MiniB3D.bmx"
Strict
Local width=640,height=480,depth=16,mode=0
Graphics3D width,height,depth,mode
Local cam:TCamera=CreateCamera()
PositionEntity cam,0,0,-10
Local light:TLight=CreateLight(1)
Local tex:TTexture=LoadTexture("media/test.png")
Local cube:TMesh=CreateCube()
Local sphere:TMesh=CreateSphere()
Local cylinder:TMesh=CreateCylinder()
Local cone:TMesh=CreateCone()
PositionEntity cube,-6,0,0
PositionEntity sphere,-2,0,0
PositionEntity cylinder,2,0,0
PositionEntity cone,6,0,0
ScaleEntity sphere,3,3,3
EntityTexture cube,tex
EntityTexture sphere,tex
EntityTexture cylinder,tex
EntityTexture cone,tex
' used by camera code
Local mxs#=0
Local mys#=0
Local move#=0.5
MouseXSpeed() ' flush
MouseYSpeed() ' flush
' used by fps code
Local old_ms=MilliSecs()
Local renders
Local fps
While Not KeyDown(KEY_ESCAPE)
If KeyHit(KEY_ENTER) Then DebugStop
'' control camera
' mouse look
mxs#=mxs#+(MouseXSpeed()/5.0)
mys#=mys#+(MouseYSpeed()/5.0)
RotateEntity cam,mys#,-mxs#,0
MoveMouse width/2,height/2
MouseXSpeed() ' flush
MouseYSpeed() ' flush
' move camera forwards/backwards/left/right with cursor keys
If KeyDown(KEY_UP)=True Then MoveEntity cam,0,0,move# ' move camera forward
If KeyDown(KEY_DOWN)=True Then MoveEntity cam,0,0,-move# ' move camera back
If KeyDown(KEY_LEFT)=True Then MoveEntity cam,-move#,0,0 ' move camera left
If KeyDown(KEY_RIGHT)=True Then MoveEntity cam,move#,0,0 ' move camera right
''
TurnEntity cube,0,1,0
RotateEntity(sphere,EntityPitch(sphere)+0.7,EntityYaw(sphere)+0.7,EntityRoll(sphere)+0.7)
RenderWorld
renders=renders+1
' calculate fps
If MilliSecs()-old_ms>=1000
old_ms=MilliSecs()
fps=renders
renders=0
EndIf
Text 0,0,"FPS: "+String(fps)
Flip
Wend
End
|