Page 1 of 1

I cannot drawing sprites on 3D

Posted: Wed Mar 01, 2006 3:14 pm
by xenopsyx
I do ... a merging mesh.pb + sprite.pb
but sprite cannot be drawed with 3d mesh
Is it impossible?

Posted: Wed Mar 01, 2006 3:31 pm
by DarkDragon
Lol, if it isn't, then use my engine, because it has 2D and 3D support.

Posted: Wed Mar 01, 2006 3:37 pm
by Fred
you will have to create a textureif you want to apply it on a 3D mesh.

Posted: Wed Mar 01, 2006 3:53 pm
by DarkDragon
Fred wrote:you will have to create a textureif you want to apply it on a 3D mesh.
No, he meant drawing a GUI or HUD or however you'll call it.

mesh+sprite?

Posted: Wed Mar 01, 2006 3:53 pm
by xenopsyx
i tested examples, and merged examples. that is below

Code: Select all

; mesh.pd
...
...
If InitEngine3D()

  Add3DArchive("Data\"          , #PB_3DArchive_FileSystem)
  Add3DArchive("Data\Skybox.zip", #PB_3DArchive_Zip)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
...
;sprirte.pb
  LoadSprite(0, "Data\PureBasic.bmp", 0)
  CopySprite(0,1,0)
...
...
..
; mesh.pd
    Repeat
      Screen3DEvents()
      
...
...

      MoveCamera  (0, KeyX, 0, KeyY)
      
      RenderWorld()
      Screen3DStats()
;;;;;;;;;sprite.pb

    DisplaySprite(0, x, 100)
    DisplaySprite(1, x, x)
    DisplaySprite(0, 600-x, x)
    x+1

;;;;;;;;;mesh.pb
      FlipBuffers()
and run. no bug...but sprite is not displayed????
I want to see 2d sprites & 3d mesh together.....

Posted: Wed Mar 01, 2006 4:06 pm
by Fred
You have to call displaysprite() after renderworld() and before flipbuffers() and it should work:

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Entity
;
;    (c) 2002 - Fantaisie Software
;
; ------------------------------------------------------------
;

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

  
If InitEngine3D()

  Add3DArchive("Data\"          , #PB_3DArchive_FileSystem)
  Add3DArchive("Data\Skybox.zip", #PB_3DArchive_Zip)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    LoadMesh   (0, "Robot.mesh")

    ; Load a sprite here
    ;
    LoadSprite(0, x"c:\8bits.bmp"x)
    
    CreateMaterial(0, LoadTexture(0, "clouds.jpg"))
    CreateMaterial(1, LoadTexture(1, "r2skin.jpg"))
    
    CreateEntity(0, MeshID(0), MaterialID(0))
    CreateEntity(1, MeshID(0), MaterialID(1), -60, 0, 0)
    CreateEntity(2, MeshID(0), MaterialID(1),  60, 0, 0)
    
    AnimateEntity(0, "Walk")
    
    SkyBox("desert07.jpg")
   
    CreateCamera(0, 0, 0, 100, 100)
    CameraLocate(0,0,0,100)
      
    Repeat
      Screen3DEvents()
      
      ClearScreen(RGB(0, 0, 0))
            
      If ExamineKeyboard()
      
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -1
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = 1
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -1
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = 1
        Else
          KeyY = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_PageUp)
          RollZ = 3
        Else
          RollZ = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_Add)
          Frame.f+0.005
        EndIf
        
      EndIf
      
      If ExamineMouse()
        MouseX = -MouseDeltaX()/10 
        MouseY = -MouseDeltaY()/10
      EndIf
      
      RotateEntity(1, 1, 0, 0)
      RotateEntity(2, 1, 0, 0)
      
      RotateCamera(0, MouseX, MouseY, RollZ)
      MoveCamera  (0, KeyX, 0, KeyY)
      
      RenderWorld()
      
      ; Here is the sprite..
      ;
      DisplaySprite(0, 0, 0)
      
      Screen3DStats()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
    
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
  
End

Posted: Wed Mar 01, 2006 4:10 pm
by DarkDragon
Does it also work in OpenGL mode?

Posted: Wed Mar 01, 2006 5:25 pm
by Fred
No, because the engine 3D doesn't work in OpenGL (but you already know that, so why do you asked that ?).

Posted: Wed Mar 01, 2006 5:58 pm
by DarkDragon
Fred wrote:No, because the engine 3D doesn't work in OpenGL (but you already know that, so why do you asked that ?).
I didn't know that, because Ogre also renders with OpenGL on Linux, so why is there no Ogre OpenGL subsystem?

thank you Fred

Posted: Thu Mar 02, 2006 2:51 am
by xenopsyx
your code works well...
exception define.f, clearscreen(rgb(0,0,0))
thankyou

Posted: Thu Mar 02, 2006 9:53 am
by Fred
you're welcome ;).

(very powerful and cool =)

Posted: Fri Jul 27, 2007 12:42 am
by vrman3d
Yep you were right Gaman, and it wasn't intentional so I deleted it here and posted it in a new topic hoping it would be seen. But I guess I never actually hit the submit on this one (to erase it). Sorry yer right, my bad!

And btw, problem all solved now. Pm me or email me sometime Gaman and I'll let you in on a (very powerful and cool =) secret that I came up with using what we figured out (geesh that was painful, so glad it's over now!) along with a (very powerful and cool =) dll I wrote in PB a while back. You were cool about things at the end of that pointless flamefest, and even though I didn't like being falsely accused of things, I respect that you owned up/manned up at the end, that took guts (and maturity). Thanks (and seriously you'll be blown away with what I show you, the potential is HUGE, and I've been doing 3D dev since the first 3Dfx card came out in beta, I know it's revolutionary (and by the way, it's (very powerful and cool =) hehheh. Seriously tho, Plz contact me for it! I'll give you a free ver of the DLL that I sell and show you how to combine them). You will smile broadly. :D

Posted: Fri Jul 27, 2007 10:11 am
by Kaeru Gaman
do you think it is necessary to post your question in two threads at the same time?

INFORMATION