Flip Sprite ???

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
DaylightDreamer
User
User
Posts: 52
Joined: Wed Feb 04, 2009 8:11 am
Location: Armenia

Flip Sprite ???

Post by DaylightDreamer »

Is it possible to have something like FlipSprite or Mirror sprite function ? All OS

Or at least something to invert the 3D sprite polygon so it doesn't disappear when you try to flip it using the TransformSprite function.
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Flip Sprite ???

Post by STARGÅTE »

but only optional, like TransformSprite(Sprite, x1, y1 ..., z4[, ShowBackSide]), I have written a small 3D-Engine with TransformSprite(), and I don't want to see the back side of my Sprites :wink: .

But yes, it would be nice to flip a Sprite with ZoomSprite(Sprite, -256, 256) or with ClipSprite(Sprite, 100, 0, -100, 100).
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
DaylightDreamer
User
User
Posts: 52
Joined: Wed Feb 04, 2009 8:11 am
Location: Armenia

Re: Flip Sprite ???

Post by DaylightDreamer »

Another possible solution also could be is to have access to the polygons normals.
User avatar
thyphoon
Enthusiast
Enthusiast
Posts: 327
Joined: Sat Dec 25, 2004 2:37 pm

Re: Flip Sprite ???

Post by thyphoon »

+1
I don't understand why not always simple solution to enable/disable backface culling when use transformsprite (All Os)

Fred Pleeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaase !! :P
User avatar
thyphoon
Enthusiast
Enthusiast
Posts: 327
Joined: Sat Dec 25, 2004 2:37 pm

Re: Flip Sprite ???

Post by thyphoon »

I found this way for 5.20 on windows.
press space to flip sprite
InitSprite()
InitKeyboard()
OpenWindow(0, 0, 0, 800, 600, "", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,WindowWidth(0),WindowHeight(0))


;Disable Backface Culling
; from http://www.forums.purebasic.com/english ... 16&t=43718
; thanks Innesoft
Define pd3d.IDirect3DDevice9

EnableASM
!extrn _PB_Screen_Direct3DDevice
!MOV dword EAX, [_PB_Screen_Direct3DDevice]
!MOV dword [v_pd3d],EAX
DisableASM
pd3d\SetRenderState(22,1)
pd3d\SetRenderState(7,0)

;-create sprite
CreateSprite(0,128,128)
StartDrawing(SpriteOutput(0))
Circle(32,32,64,#Red)
Box(64,32,64,32,#Green)
StopDrawing()

Repeat
Repeat
Event = WindowEvent()

Select Event
Case #PB_Event_CloseWindow
End
EndSelect
Until Event=0

ExamineKeyboard()

ClearScreen(#Black)
If KeyboardPushed(#PB_Key_Space)
TransformSprite(0,SpriteWidth(0),0,0,0,0,SpriteHeight(0),SpriteWidth(0),SpriteHeight(0))

Else
TransformSprite(0,0,0,SpriteWidth(0),0,SpriteWidth(0),SpriteHeight(0),0,SpriteHeight(0))

EndIf
DisplaySprite(0,32,32)
FlipBuffers()
Delay(1)
ForEver
But i have no solution for Linux/MacOsX :(
DaylightDreamer
User
User
Posts: 52
Joined: Wed Feb 04, 2009 8:11 am
Location: Armenia

Re: Flip Sprite ???

Post by DaylightDreamer »

Thanks in PB 5.20 SpriteOutput drawing works ok now so its possible to create flipped sprite instance using Drawing functions .
User avatar
thyphoon
Enthusiast
Enthusiast
Posts: 327
Joined: Sat Dec 25, 2004 2:37 pm

Re: Flip Sprite ???

Post by thyphoon »

DaylightDreamer wrote:Thanks in PB 5.20 SpriteOutput drawing works ok now so its possible to create flipped sprite instance using Drawing functions .
Yes, but it's very slow and you must to copy the orginal sprite ...
it is a shame not to use the hardware facilities
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: Flip Sprite ???

Post by eddy »

STARGÅTE wrote:but only optional, like TransformSprite(Sprite, x1, y1 ..., z4 [, ShowBackSide])
But yes, it would be nice to flip a Sprite with: ZoomSprite(Sprite, -256, 256) or ClipSprite(Sprite, 100, 0, -100, 100).
+1
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

Re: Flip Sprite ???

Post by Lebostein »

Yes, that is a shame. After 14 years PureBasic there is no function to mirror a sprite in an easy way...
The workaround with TransformSprite, is this possible with Win, Mac and Linux?
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: Flip Sprite ???

Post by bfernhout »

Damn.
Its not working for me. When i hit the spacebar it blank out the screen. Or maybe i see the backside of the sprite.
I am using PB 5.62 on a win 8.1 system 16 Gb mem,i7 core intel(64 bits). Nvidea Geforce 950m

There must be something i miss.

Bart.
From my first self made computer till now I stil like computers.
Post Reply