Page 1 of 1

Cannot put text on screen in 3D

Posted: Fri Jan 21, 2011 5:26 pm
by Rook Zimbabwe
I have the follwoing program (models can be found on topic:

http://www.purebasic.fr/english/viewtop ... 16&t=45061

and I want to be able t print on the 3D window... no technique I have attempted has allowed me to do this. I had thought of setting the text as texture on a billboard or something but I am confused as to how that would be possible.

The 3D text gadget seems to be broken...

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Mesh (Skeleton Animation)
;
;    (c) 2002 - Fantaisie Software
;
; ------------------------------------------------------------
;
; Modified by Rook Zimbabwe
;             and DarkDragon (in order to help Rook Zimbabwe)


InitSprite()
InitKeyboard()
InitMouse()

Define.f KeyX, KeyY

#WheelMesh = 0
#WheelMesh2 = 1
#WheelMesh3 = 2
#WheelMesh4 = 3
#WheelTexture = 0
#METAL = 1
#Wheel = 0
#Wheel2 = 1
#Wheel3 = 2
#Wheel4 = 3
#Gear = 4
#Rod = 5
#Sun = 6
#a3Dtext = 7
#File = 8
#Sprite = 9
#Sprite3D = 10

; DATA OUTPUT
;OpenFile(#File, "wheeldrop.txt")

Dim spin(9)

spin(0) = 254
spin(1) = 292
spin(2) = 324
spin(3) = 0
spin(4) = 38
spin(5) = 74
spin(6) = 108
spin(7) = 144
spin(8) = 180
spin(9) = 216

If InitEngine3D()
  
  OpenWindow(0, #PB_Ignore, #PB_Ignore, 800, 600, "Test", #PB_Window_SystemMenu)
  
  If OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 1, 0, 0)
    
    Add3DArchive("Data", #PB_3DArchive_FileSystem)
    
    ;- ** LOAD MESH **
    LoadMesh   (#WheelMesh   , "wheel2.mesh")
    LoadTexture(#WheelTexture, "Image1.jpg")
    CopyMesh(#WheelMesh , #WheelMesh2 )
    CopyMesh(#WheelMesh2 , #WheelMesh3 )
    CopyMesh(#WheelMesh3 , #WheelMesh4 )
    
    ;gear = LoadMesh(#PB_Any   , "gear1.mesh")
    ;rod = LoadMesh(#PB_Any   , "rod1.mesh")
    ;mettext = LoadTexture(#PB_Any, "25.bmp")
    ;CreateMaterial(#METAL, TextureID(mettext))
    
    CreateMaterial(0, TextureID(#WheelTexture))
    ;- create entity
    CreateEntity(#Wheel, MeshID(#WheelMesh), MaterialID(0), 11, 0, 0)
    CreateEntity(#Wheel2, MeshID(#WheelMesh2), MaterialID(0), 0, 0, 0)
    CreateEntity(#Wheel3, MeshID(#WheelMesh3), MaterialID(0), -11, 0, 0)
    CreateEntity(#Wheel4, MeshID(#WheelMesh4), MaterialID(0),-22, 0, 0)
    
    ;CreateEntity(#Gear, MeshID(gear), MaterialID(#METAL),-30, 0, 0)
    
    DisableMaterialLighting(0, 0) ; was (0,1)
    
    MaterialAmbientColor(0, RGB(202, 202, 202))
    MaterialSpecularColor(0, RGB(28,28,28))
    
    CreateLight(#Sun, RGB(255,255,255), 0, 260, 0) ; 100.0, 0, 0)
    LightSpecularColor(#Sun, RGB(128, 128, 128))
    
    CreateCamera(0, 0, 0, 100, 100)
    CameraLocate(0,0,0,97)
    
;   *********************   
;- ****    MAIN LOOP   ****
;   ********************* 

    Repeat
      
      ClearScreen(RGB(0, 0, 0))
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_Down)
          xx + 1
        ElseIf KeyboardPushed(#PB_Key_Up)
          xx - 1
        EndIf
        
        If KeyboardReleased(#PB_Key_Space)
          ; *** rem values write the data lines for inclusion in program ***
          ; WriteStringN(#File, "spin("+Str(j)+") = "+Str(xx))
          ; j = j + 1
          
        EndIf
        
      EndIf
      
      RotateEntity(#Wheel, xx, 0, 0, #PB_Absolute) ;#Wheel, 0, 1, 0, #PB_Relative)
      ;RotateEntity(#gear, xx, 0, 0, #PB_Absolute) ;#Wheel, 0, 1, 0, #PB_Relative)
      
      xxx = EntityX(#Wheel)
      
      If xx > 359
        xx = 0
   EndIf
   
   ; ###########
   ; NOW the BIG thing is HOW do I print stuff on the screen???
   ; ###########
   
      RenderWorld()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
; CloseFile(#File)
End
How can I print info on the screen?

BTW I am .mesh converting all me b3D models to OGRE... will post a link to the gallery FREE for PBers! (posted very soon!)

Re: Cannot put text on screen in 3D

Posted: Fri Jan 21, 2011 6:05 pm
by IdeasVacuum
Lots going on in your code there Rook. firstly, I'd separate it out into logical procedures - set-up the window in it's own procedure, the Mesh loading does not really belong there.

Given that you are using a windowed screen, you can use regular gadgets on the window, just not on the screen area. For me, that's preferable, but if your app needs to write text on the screen instead, how about using a screen rather than windowed screen? I suspect the issue of the 3D gadgets is the use of a windowed screen, that is where I fell into troubled water myself.

Re: Cannot put text on screen in 3D

Posted: Fri Jan 21, 2011 6:33 pm
by DarkDragon
I answered to your problem in the other thread you've linked.

Re: Cannot put text on screen in 3D

Posted: Sat Jan 22, 2011 6:57 pm
by Rook Zimbabwe
well I can put a 3d WINDOW on the screen with CEGUI but only the basic one... seems OGRE didn't update to the newer version either yet... cannot print text direct to screen!!! still... if I disable the mouse I suppose I can work it into a funky HUD...

prelim screenpic...
(cannot use PSP9 to get screenshot in PB when program runs so used wifes cam... the little red blob near bottom is flash shining THROUGH finger!!! Buy your wife a Panasonic LUMIX with the Leica lens set... is GOOD!)

Image

numbers to be replaced by graphics in release version... :D
Now to add sounds, pull handle animation, betting controls, win information and a start screen!

I do wish textures could be SPHERE MAPPED so my metal textures would show up SHINY!

Re: Cannot put text on screen in 3D

Posted: Sun Jan 23, 2011 9:05 am
by DarkDragon
Rook Zimbabwe wrote:I do wish textures could be SPHERE MAPPED so my metal textures would show up SHINY!
Nothing easier than that:
http://www.bradan.eu/files/rook.zip

Look at the material script changes and I wonder why you didn't use the material script instead of defining a new material.

Re: Cannot put text on screen in 3D

Posted: Sun Jan 23, 2011 11:27 am
by Comtois
cannot print text direct to screen!!!
You can use a TransparentSprite, see example here :

http://www.purebasic.fr/english/viewtop ... 16&t=34593

Re: Cannot put text on screen in 3D

Posted: Sun Jan 23, 2011 11:33 am
by DarkDragon
Comtois wrote:
cannot print text direct to screen!!!
You can use a TransparentSprite, see example here :

http://www.purebasic.fr/english/viewtop ... 16&t=34593
I've already posted an example in his other thread, but he doesn't seem to see it :lol: :
http://www.purebasic.fr/english/viewtop ... 46#p344446

Maybe he generally wanted to use the CEGUI and didn't respond because its not with CEGUI.

Re: Cannot put text on screen in 3D

Posted: Sun Jan 23, 2011 5:33 pm
by Rook Zimbabwe
Nope... he didn't see it... the glasses ae not working! I am looking again! :D

Re: Cannot put text on screen in 3D

Posted: Sun Jan 23, 2011 7:07 pm
by DarkDragon
Rook Zimbabwe wrote:Nope... he didn't see it... the glasses ae not working! I am looking again! :D
So, to summarize it for you :wink: :
Draw text on screen (Comtois) http://www.purebasic.fr/english/viewtop ... 16&t=34593
Draw text on screen (DarkDragon) http://www.purebasic.fr/english/viewtop ... 46#p344446
Spheremapping (DarkDragon) http://www.bradan.eu/files/rook.zip

Re: Cannot put text on screen in 3D

Posted: Mon Jan 24, 2011 4:51 am
by Rook Zimbabwe
Danke Daniel!!!
I am still having issues with the spheremapping but I think that might be my model! The Test.pb looks like the original code with no changes! I am rebuilding meshes now!

Re: Cannot put text on screen in 3D

Posted: Mon Jan 24, 2011 8:21 am
by DarkDragon
Rook Zimbabwe wrote:Danke Daniel!!!
I am still having issues with the spheremapping but I think that might be my model! The Test.pb looks like the original code with no changes! I am rebuilding meshes now!
You have to look at the "wheel2.material" file (open it with notepad or such). It gets parsed through calling "Parse3DScripts()" in the "Test.pb" file and you don't need to create the material manually inside the PureBasic Code.

Its linked with your mesh through the material name:

Code: Select all

[...]
material mat0
{
   [...]
Open the "wheel2_mesh.xml" to read this line:

Code: Select all

[...]
<submesh material="mat0" usesharedvertices="false" use32bitindexes="false" operationtype="triangle_list">
[...]
As you can see the materialname mat0 is responsible for identifying the right material script for your mesh.

Re: Cannot put text on screen in 3D

Posted: Tue Jan 25, 2011 9:47 pm
by Rook Zimbabwe
Sorry... had to go to hospital with acute blood poisoning... I guess it is ugly blood poisoning now as they let me go!

I had wondered about that. I attach the images to the mesh objects in UU3d or in Rhino3D and unless we can actually specify each MAT texture with OGRE it is gonna get ugly!

:mrgreen:

Re: Cannot put text on screen in 3D

Posted: Wed Jan 26, 2011 8:05 am
by DarkDragon
Rook Zimbabwe wrote:Sorry... had to go to hospital with acute blood poisoning... I guess it is ugly blood poisoning now as they let me go!

I had wondered about that. I attach the images to the mesh objects in UU3d or in Rhino3D and unless we can actually specify each MAT texture with OGRE it is gonna get ugly!

:mrgreen:
Hmm using " :mrgreen: " with blood poisoning?
You can specify it inside the "wheel2.material". It is a OGRE feature to have those scripts externally. I don't understand your problem with it. I don't understand why it should get ugly?!

Re: Cannot put text on screen in 3D

Posted: Wed Jan 26, 2011 5:33 pm
by Rook Zimbabwe
My toe was green for a while... ALL BETTER!

I will post an example of my attempt at using internal images on MESH in a bit!

Re: Cannot put text on screen in 3D

Posted: Wed Jan 26, 2011 5:46 pm
by DarkDragon
Rook Zimbabwe wrote:My toe was green for a while... ALL BETTER!
Get well soon! My toe is dark red all over the year. In a while I will let them amputate my toe nail so it will never come again.
Rook Zimbabwe wrote:I will post an example of my attempt at using internal images on MESH in a bit!
You should use shaders for this. PureBasic images and all modifications to it are stored on the normal CPU connected RAM and not inside the GPU connected RAM, so it would always send those images through the bottleneck if you're modifying textures with the CPU.