TransformSprite3D

Advanced game related topics
User avatar
Ypser
User
User
Posts: 19
Joined: Wed Jun 18, 2003 9:13 am
Location: Germany
Contact:

TransformSprite3D

Post by Ypser »

Hello. Why does the left image (1), after transforming, look like image (2), but not like image 3?
Image

In this form the TransformSprite3D command is totaly useless!
Can someone tell me, if there is a chance to get the command in an usefull version one day??? 8O
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Hi!

A 3dsprite is composed of 2 triangles...

What is happening is that you're swapping one of the coordinates...

Take special notice that coords of a 3d sprite are like this:

Code: Select all

a----b
|  / |
| /  |
d----c
Here's an example of a working engine i'm building...:

Code: Select all


;/// Size of cube
#squarex = 164
#squarey = 164

Procedure face(sprite.b,type.b,zoom.b)
   
  dif=16+#squarex-#squarey
  
  Select type
    Case 1 ; ///// square
      TransformSprite3D(sprite,0,0,#squarex,0,#squarex,#squarey,0,#squarey)
      
    Case 2 ; ///// left face
      TransformSprite3D(sprite,0,0,(#squarex-dif)/5,0+dif,(#squarex-dif)/5,#squarey-dif,0,#squarey)
      
  EndSelect
  
  
EndProcedure

If OpenWindow(0,0,0,640,400,#PB_Window_ScreenCentered,"Dungeon")
  If InitSprite():EndIf : If InitSprite3D() : EndIf 
  InitKeyboard()
  
  
  
  If OpenWindowedScreen(WindowID(0),0,0,640,480,0,0,0)
    LoadSprite(1,"text01.bmp",#PB_Sprite_Texture) ; /// change this to your texture
    CreateSprite3D(0,1)
    CreateSprite3D(1,1)
    ; _startworld()   
    
    ClearScreen(0,0,0)
    Repeat 
      ClearScreen(0,0,0)
      
      Start3D()
        face(0,1,0)
        DisplaySprite3D(0,0,50)
        face(0,2,0)
        DisplaySprite3D(0,#squarex,50,180)
      Stop3D()
      
      FlipBuffers()
      ExamineKeyboard()
    Until KeyboardPushed(#PB_Key_Escape)
    
    ;GrabSprite(100,0,0,640,480)
    
    ;SaveSprite(100,"SBS.bmp")
  EndIf
EndIf

User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

Nice example, worked great here. :D
User avatar
Ypser
User
User
Posts: 19
Joined: Wed Jun 18, 2003 9:13 am
Location: Germany
Contact:

Post by Ypser »

I know what TransformSprite3D does. But it's useless this way.
Test the "PureRacerDemo". If you take a closer look at the Road texture, you'll see what happens, if you try to
use TransformSprite3D for those things. So what is it good for?
Post Reply