TextureQuad
TextureQuad TextureImage, x1, y1, u1, v1, x2, y2, u2, v2, x3, y3, u3, v3, x4, y4, u4, v4, TransparentFlag
 
Parameters:

    TextureImage = The image number to be used as the source texture
    x1 = X coordinate of point 1
    y1 = Y coordinate of point 1
    u1 = The U coordinate of point 1 on the texture
    v1 = The V coordinate of point 1 on the texture
    x2 = X coordinate of point 2
    y2 = Y coordinate of point 2
    u2 = The U coordinate of point 2 on the texture
    v2 = The V coordinate of point 2 on the texture
    x3 = X coordinate of point 3
    y3 = Y coordinate of point 3
    u3 = The U coordinate of point 3 on the texture
    v3 = The U coordinate of point 3 on the texture
    x4 = X coordinate of point 4
    y4 = Y coordinate of point 4
    u4 = The U coordinate of point 4 on the texture
    v4 = The V coordinate of point 4 on the texture
    TransparentFlag = Render the image with or without transparency (0=solid, 1=transparent)
Returns: NONE
 

     TextureQuad draws a texture mapped quad (four sided polygon) to the current surface. This command uses a previously loaded or created image as the texture, which will be mapped onto the polygon surface.


Transparent Flags:

      0 = Solid
      1 = Transparent (uses mask colour or alpha channel on AFX images)
      8 = Solid With Bilinear Filter
      9 = Transparent With Bilinear Filter (uses mask colour or alpha channel on AFX images)





FACTS:


      * U/V coords are the X/Y coords in Texture space.
      * U/V coords should never exceed the size (width and height) of the texture.
      * U coords should range from 0 to the Texture Images Width-1
      * V coords should range from 0 to the Texture Images Height-1

      * Note: For best results it's recommended that your texture be in FX image. Moreover small textures render faster than larger ones. So sometimes it can more efficient to split larger images up into small blocks, than using the entire thing as a texture.

      * TextureQuad will render to the current surface, except when the user has either CaptureToScene, or CaptureToWorld activated. In either situation the drawing request will be added to the scene or world queues.

      * TextureQuad can react to some InkMode settings




Mini Tutorial:


This example first manually creates an image filled with coloured circles. It then converts this to an FX image. Once converted it can then draw this image to the screen using it as a texture for the TextureTri command.


  
  
; First we'll create image 1, width=100 and height=100
  CreateImage 1,100,100
  
; next we tell pb to redirect all drawing operations to this
; image
  RenderToImage 1
  
; now we draw 50 randomly sized circles to the image
  For lp=0 To 50
     CircleC Rnd(100),Rnd(100),Rnd(20),1,RndRGB()
  Next lp
  
; Prepare the image to be used for rotation
  PrepareFXImage 1
  
; Tell PB to re-direc all drawing back to the screen
  RenderToScreen
  
  
; create variables to hold the UV coords for out teture mapper
; U1/v1 = top left cord on texture
  u1=0
  v1=0
  
; U2/v2 = top left cord on texture
  u2=99
  v2=0
  
; U3/v3 = top left cord on texture
  u3=99
  v3=99
  
; U4/v4 = top left cord on texture
  u4=0
  v4=99
  
; Draw a texture mapped triangle to the screen
  TextureTri 1,100,100,u1,v1,300,150,u2,v2,200,200,u3,v3,false
  
; Draw a texture mapped quad to the screen
  TextureQuad 1,100,300,u1,v1,300,350,u2,v2,200,400,u3,v3,50,350,u4,v4,false
  
; draw the original image to the screen
  DrawImage 1,400,100,0
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  
  




 
Example Source: Download This Example
; Enable Screen Vsync
  ScreenVsync on
  SetFPS 75
  
  
; Load the Ship image into image slot #1
  MyImage=LoadNewFxImage(ProgramDir$()+"Help/Commands/Media/ship.bmp")
  
; Get the Width of this image and use it as the images size
  Size=GetImageWidth(MyIMage)
  
  
; =============================
; Start a main loop
; =============================
  Do
     
   ; Clear the screen to a dark red colour
     Cls RGB(100,40,30)
     
   ; Read the mouses position
     mx#=MouseX()
     my#=MouseY()
     
     
   ; Space KEy To Change Draw Mode
     
     If SpaceKey()
        Select DrawMode
            Case 0  :Drawmode=1
            Case 1  :Drawmode=8
            Case 8  :Drawmode=9
            Case 9  :Drawmode=0
        EndSelect
        FlushKeys
     EndIf
     
     LockBuffer
     Toggle=0
     For angle#=0 To 359 Step 60
        x#=mx#+CosRadius(baseangle#+angle#,200)
        Y#=my#+SinRadius(baseangle#+angle#,200)
        If Toggle
           DrawRotatedQuad(MyImage,x#,y#,RotAngle#,64,DrawMode)
        Else
           DrawRotatedTri(MyImage,x#,y#,RotAngle#,64,DrawMode)
        EndIf
        Toggle=(Toggle+1)&1
     Next
     UnLockBuffer
     
     
   ; Draw Message at the mouse position
     Print "Drawing Rotated Image Using TextureQuad & TextureTri"
     Print "Current drawMode:"+Str$(drawMode)
     
     RotAngle#=WrapAngle(RotAngle#,2)
     
     Baseangle#=WrapAngle(BaseAngle#,1)
     
   ; Display the screen and loop until the users presses the ESC key.
     Sync
  Loop
  
  
  
Function DrawRotatedQuad(ThisIMage,x#,y#,Angle#,size#,TransparentFlag)
  
  x1#=CosNewValue(x#,angle#,size#)
  y1#=SinNewValue(y#,angle#,size#)
  u1=0
  v1=0
  
  Angle#+=90
  x2#=CosNewValue(x#,angle#,size#)
  y2#=SinNewValue(y#,angle#,size#)
  u2=GetImageWidth(Thisimage)
  v2=0
  
  
  Angle#+=90
  x3#=CosNewValue(x#,angle#,size#)
  y3#=SinNewValue(y#,angle#,size#)
  u3=GetImageWidth(Thisimage)
  v3=GetImageHeight(ThisIMage)
  
  Angle#+=90
  x4#=CosNewValue(x#,angle#,size#)
  y4#=SinNewValue(y#,angle#,size#)
  u4=0
  v4=v3
  
  TextureQuad Thisimage,x1#,y1#,u1,v1,x2#,y2#,u2,v2,x3#,y3#,u3,v3,x4#,y4#,u4,v4,transparentFlag
  
  CenterText X#,y#,"Textured Quad"
  
EndFunction
  
  
  
  
Function DrawRotatedTri(ThisIMage,x#,y#,Angle#,size#,TransparentFlag)
  
  x1#=CosNewValue(x#,angle#,size#)
  y1#=SinNewValue(y#,angle#,size#)
  u1=0
  v1=0
  
  Angle#+=90
  x2#=CosNewValue(x#,angle#,size#)
  y2#=SinNewValue(y#,angle#,size#)
  u2=GetImageWidth(Thisimage)
  v2=0
  
  
  Angle#+=90
  x3#=CosNewValue(x#,angle#,size#)
  y3#=SinNewValue(y#,angle#,size#)
  u3=GetImageWidth(Thisimage)
  v3=GetImageHeight(ThisIMage)
  
  
  TextureTri Thisimage,x1#,y1#,u1,v1,x2#,y2#,u2,v2,x3#,y3#,u3,v3,transparentFlag
  
  
  CenterText X#,y#,"Textured Triangle"
  
EndFunction
  
  
  
 
Related Info: GouraudQuad | GouraudStripH | GouraudStripV | GouraudTri | Quad | QuadC | TextureStripH | TextureStripV | TextureTri | Tri | TriC :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com