Page 1 of 1
RotateSprite3D() - 2 more parameters
Posted: Sat Jun 26, 2010 6:43 am
by J. Baker
RotateSprite3D(#Sprite3D, X, Y, Angle.f, Mode)
X and Y coordinates to define a pivot point within the sprite, at which the sprite rotates around.
Re: RotateSprite3D() - 2 more parameters
Posted: Sat Jun 26, 2010 7:13 am
by jamirokwai
J. Baker wrote:RotateSprite3D(#Sprite3D, X, Y, Angle.f, Mode)
X and Y coordinates to define a pivot point within the sprite, at which the sprite rotates around.
+1.
Should be made optional.
Re: RotateSprite3D() - 2 more parameters
Posted: Sat Jun 26, 2010 8:40 am
by STARGĂ…TE
Why should a RotateSprite3D x, y?
The rotation of sprites always looks the same.
The shift comes at DisplaySprite3D.
There, the x and y:
Code: Select all
x+Cos(Angle)*dx-Sin(Angle)*dy
y+Sin(Angle)*dx+Cos(Angle)*dy
Where dx and dy represent the displacement then.
Here a result:
Code: Select all
InitSprite()
InitSprite3D()
OpenWindow(0, 0, 0, 800, 600, "SCREEN", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 0, 0, 0)
CreateSprite(1, 256, 256,#PB_Sprite_Texture)
StartDrawing(SpriteOutput(1))
Box(0,0,128,128,$FF0000)
Box(128,0,128,128,$00FF00)
Box(0,128,128,128,$0000FF)
Box(128,128,128,128,$00FFFF)
StopDrawing()
CreateSprite3D(1,1)
Repeat
Event = WindowEvent()
ClearScreen(0)
Angle.f+0.02
Start3D()
RotateSprite3D(1, Degree(Angle), 0)
DisplaySprite3D(1, 128, 128) ; no shift, roate at center
dx = 128 : dy = 128 ; Shift to a corner
DisplaySprite3D(1, 384+Cos(Angle)*dx-Sin(Angle)*dy, 128+Sin(Angle)*dx+Cos(Angle)*dy) ; with shift
Stop3D()
FlipBuffers()
Until Event = #PB_Event_CloseWindow
Re: RotateSprite3D() - 2 more parameters
Posted: Sun Jun 27, 2010 4:49 am
by J. Baker
Interesting and thanks for posting. But I think I would still prefer the request. As I think it would fit the command.
