I cannot drawing sprites on 3D

Just starting out? Need help? Post your questions and find answers here.
xenopsyx
User
User
Posts: 10
Joined: Wed Mar 01, 2006 3:10 pm

I cannot drawing sprites on 3D

Post by xenopsyx »

I do ... a merging mesh.pb + sprite.pb
but sprite cannot be drawed with 3d mesh
Is it impossible?
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

Lol, if it isn't, then use my engine, because it has 2D and 3D support.
bye,
Daniel
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

you will have to create a textureif you want to apply it on a 3D mesh.
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post 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.
bye,
Daniel
xenopsyx
User
User
Posts: 10
Joined: Wed Mar 01, 2006 3:10 pm

mesh+sprite?

Post 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.....
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

Does it also work in OpenGL mode?
bye,
Daniel
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

No, because the engine 3D doesn't work in OpenGL (but you already know that, so why do you asked that ?).
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post 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?
bye,
Daniel
xenopsyx
User
User
Posts: 10
Joined: Wed Mar 01, 2006 3:10 pm

thank you Fred

Post by xenopsyx »

your code works well...
exception define.f, clearscreen(rgb(0,0,0))
thankyou
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

you're welcome ;).
vrman3d
User
User
Posts: 13
Joined: Thu Jul 26, 2007 7:44 pm

(very powerful and cool =)

Post 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
Last edited by vrman3d on Fri Jul 27, 2007 7:46 pm, edited 1 time in total.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

do you think it is necessary to post your question in two threads at the same time?

INFORMATION
oh... and have a nice day.
Post Reply