Page 1 of 1

TransformSprite3D

Posted: Tue Dec 23, 2003 9:19 pm
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

Posted: Tue Dec 23, 2003 9:34 pm
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


Posted: Tue Dec 23, 2003 11:14 pm
by J. Baker
Nice example, worked great here. :D

Posted: Wed Dec 24, 2003 12:53 am
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?