ClipSprite3D for DirectX7 / DirectX9 (x86/x64)

Share your advanced PureBasic knowledge/code with the community.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

djes wrote:It's a mistake. I thought that tip = hint. My english is so bad :'(
ah, sorry.
I forgot to put an "also" into my sentence.
"hint" or "clue" is the normal meaning, "gratuity" is an additional, slang meaning.

... so, in french there is no other meaning of "tip"?
oh... and have a nice day.
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

Hum... Not really. In french, a TIP is something like a special cheque (Titre Interbancaire de Paiement)
User avatar
thepastrycook
User
User
Posts: 19
Joined: Tue Aug 25, 2009 12:30 pm
Location: french

Re: ClipSprite3D for DirectX7 / DirectX9

Post by thepastrycook »

Fluid Byte wrote:the famous ClipSprite3D
Thank you, l' use since the month April and it's perfect
very nice
Image
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: ClipSprite3D for DirectX7 / DirectX9

Post by STARGÅTE »

Why the queries for x, y, width and height there are in it?

Without these queries, you can still use one more effect, the tile-effect:

Code: Select all

InitSprite()
InitSprite3D()

; DirectX9
Structure D3DTLVERTEX
  x.f:y.f:z.f
  rhw.f:Color.l
  tu.f:tv.f
EndStructure  

Structure PB_DX9Sprite3D
  TexRes.l                    ; TexRes
  Vertice.D3DTLVERTEX[4]      ; The 4 vertices for the rectangle sprite
  TmpVertice.D3DTLVERTEX[4]   ; The 4 vertices for the rectangle sprite
  Width.l                     ; width set with ZoomSprite3D()
  Height.l                    ; height set with ZoomSprite3D()
  RealWidth.l
  RealHeight.l
  Angle.f
  Transformed.l
EndStructure


Procedure ClipSprite3D(Sprite3D, x, y, Width, Height)
  Protected *Sprite3D.PB_DX9Sprite3D = IsSprite3D(Sprite3D)
  With *Sprite3D
    \Vertice[0]\tu = x / \RealWidth
    \Vertice[0]\tv = y / \RealHeight 
    \Vertice[1]\tu = (x + Width) / \RealWidth 
    \Vertice[1]\tv = y / \RealHeight
    \Vertice[2]\tu = x / \RealWidth 
    \Vertice[2]\tv = (y + Height) / \RealHeight 
    \Vertice[3]\tu = (x + Width) / \RealWidth 
    \Vertice[3]\tv = (y + Height) / \RealHeight 
  EndWith
EndProcedure

OpenWindow(0, 0, 0, 800, 600, "SCREEN", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 0, 0, 0)
 
  Sprite3DQuality(1)
  
  CreateSprite(1, 32, 32, #PB_Sprite_Texture)
  StartDrawing(SpriteOutput(1))
    Box(0,0,16,16,$FFFF00)
    Box(16,16,16,16,$00FFFF)
  StopDrawing()
  CreateSprite3D(1, 1)

 
Repeat

  ClearScreen(0)
   
  Start3D()
  
  ClipSprite3D(1, 0, 0, 32, 32)
  RotateSprite3D(1, 0, #PB_Absolute)
  ZoomSprite3D(1, 32, 32)
  DisplaySprite3D(1, 128, 64)
 
  Time.f = ElapsedMilliseconds()/1000
 
  ClipSprite3D(1, Mod(Time*50,256), Mod(Time*70,256), 256, 256)
  RotateSprite3D(1, Time*25, #PB_Absolute)
  ZoomSprite3D(1, 256, 256)
  DisplaySprite3D(1, 128, 128)
 
  Stop3D()
 
  FlipBuffers()

Until WindowEvent() =  #PB_Event_CloseWindow
Last edited by STARGÅTE on Wed Jul 21, 2010 8:38 pm, edited 2 times in total.
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
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Re: ClipSprite3D for DirectX7 / DirectX9

Post by Fluid Byte »

I don't know exactly but I guess for backwards compatibility with older cards and DirectX 7.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: ClipSprite3D for DirectX7 / DirectX9

Post by STARGÅTE »

i see, it have a bug.
it's better to use:

Code: Select all

ClipSprite3D(1, Mod(Time*50,256), Mod(Time*70,256), 256, 256)
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
Post Reply