RotateSprite3D() - 2 more parameters

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

RotateSprite3D() - 2 more parameters

Post 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.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
jamirokwai
Enthusiast
Enthusiast
Posts: 796
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

Re: RotateSprite3D() - 2 more parameters

Post 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.
Regards,
JamiroKwai
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: RotateSprite3D() - 2 more parameters

Post 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
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: RotateSprite3D() - 2 more parameters

Post 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. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
Post Reply