.MESH Editor version 1

Advanced game related topics
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

.MESH Editor version 1

Post by LJ »

IMPORTANT: Save in Purebasic\Examples\Sources\ folder before you execute.

Major revision includes:
- Broke screen3drequestor dependencies
- Rebuilt user interface
--- Spin gadget
--- Spin gadget peeks memory to 'remember' values
--- Windowed Screen
--- User Window
--- Windows 'button' interface, no longer DirectX keyboard controlled

Code: Select all

; 
; ------------------------------------------------------------ 
; 
;   .MESH  Editor version 1 
;   Open Source 
;   8/12/03 
;   Programmer: 
;   Lance Jepsen 
;   (c) 2003 
; ------------------------------------------------------------ 
; Feel free to add on and improve. 
; INSTRUCTIONS: Select a vertice letter to edit, then select 
; a value.

#CameraSpeed = 5 


Procedure DrawScreen()
     ClearScreen(0, 0, 0)
      
      RenderWorld() 
      
      StartDrawing(ScreenOutput()) 
      DrawingMode(1) 
      FrontColor(255,255,255) 
      Locate(0, 0) 
      DrawText("Vertices: ") 
      Dim a.f(24) 
      Restore CubeVertices 
      For t = 1 To 24 
      Read a(t) 
      Next 
      Dim b.s(24) 
      For t = 1 To 24 
      b(t)=Str(a(t)) 
      Next 
      Locate(0,15) 
      DrawText("A = "+b(1)+", B = "+b(2)+", C = "+b(3)) 
      Locate(0,30) 
      DrawText("D = "+b(4)+", E = "+b(5)+", F = "+b(6)) 
      Locate(0,45) 
      DrawText("G = "+b(7)+", H = "+b(8)+", I = "+b(9)) 
      Locate(0,60) 
      DrawText("J = "+b(10)+", K = "+b(11)+", L = "+b(12)) 
      Locate(0,75) 
      DrawText("M = "+b(13)+", N = "+b(14)+", O = "+b(15)) 
      Locate(0,90) 
      DrawText("P = "+b(16)+", Q = "+b(17)+", R = "+b(18)) 
      Locate(0,105) 
      DrawText("S = "+b(19)+", T = "+b(20)+", U = "+b(21)) 
      Locate(0,120) 
      DrawText("V = "+b(22)+", W = "+b(23)+", X = "+b(24)) 
      Locate (0,140) 
      DrawText("Output in Purebasic data statements:") 
      Locate (0,155) 
      DrawText("Data.f "+b(1)+", "+b(2)+", "+b(3)) 
      Locate (0,170) 
      DrawText("Data.f "+b(4)+", "+b(5)+", "+b(6)) 
      Locate (0,185) 
      DrawText("Data.f "+b(7)+", "+b(8)+", "+b(9)) 
      Locate (0,200) 
      DrawText("Data.f "+b(10)+", "+b(11)+", "+b(12)) 
      Locate (0,215) 
      DrawText("Data.f "+b(13)+", "+b(14)+", "+b(15)) 
      Locate (0,230) 
      DrawText("Data.f "+b(16)+", "+b(17)+", "+b(18)) 
      Locate (0,245) 
      DrawText("Data.f "+b(19)+", "+b(20)+", "+b(21)) 
      Locate (0,260) 
      DrawText("Data.f "+b(22)+", "+b(23)+", "+b(24)) 
      
      StopDrawing() 

              FlipBuffers()

EndProcedure


DefType.f KeyX, KeyY, MouseX, MouseY 

If InitEngine3D() 
  
  InitSprite() 

  If OpenWindow(0, 256, 0, 544, 600, #PB_Window_BorderLess,"") 
    If OpenWindowedScreen(WindowID(0), 0, 0, 540, 600, 0, 0, 0)
       OpenWindow(2,0,0,250,590,#PB_Window_TitleBar,".Mesh Editor version 1 by Lance Jepsen")
          CreateGadgetList(UseWindow(2))   
           ComboBoxGadget(1,10,50,200,100)
            AddGadgetItem(1,-1,"Select Vertice")
            AddGadgetItem(1,-1,"A")
            AddGadgetItem(1,-1,"B")
            AddGadgetItem(1,-1,"C")
            AddGadgetItem(1,-1,"D")
            AddGadgetItem(1,-1,"E")
            AddGadgetItem(1,-1,"F")
            AddGadgetItem(1,-1,"G")
            AddGadgetItem(1,-1,"H")
            AddGadgetItem(1,-1,"I")
            AddGadgetItem(1,-1,"J")
            AddGadgetItem(1,-1,"K")
            AddGadgetItem(1,-1,"L")
            AddGadgetItem(1,-1,"M")
            AddGadgetItem(1,-1,"N")
            AddGadgetItem(1,-1,"O")
            AddGadgetItem(1,-1,"P")
            AddGadgetItem(1,-1,"Q")
            AddGadgetItem(1,-1,"R")
            AddGadgetItem(1,-1,"S")
            AddGadgetItem(1,-1,"T")
            AddGadgetItem(1,-1,"U")
            AddGadgetItem(1,-1,"V")
            AddGadgetItem(1,-1,"W")
            AddGadgetItem(1,-1,"X")
            
            SetGadgetState(1,0) 
           SpinGadget(2,10, 150, 100, 30, 0, 10)
           SetGadgetText(2,"0")   ; set initial value
           
           ButtonGadget(4, 10, 30, 200, 20, "Quit")
           ButtonGadget(5, 10, 200, 200, 20, "Rotate Left")
           ButtonGadget(6, 10, 230, 200, 20, "Rotate Right")
           ButtonGadget(7, 10, 260, 200, 20, "Rotate Up")
           ButtonGadget(8, 10, 290, 200, 20, "Rotate Down")
           ButtonGadget(9, 10, 320, 200, 20, "Zoom In")
           ButtonGadget(10, 10,350,200,20,"Zoom Out")
           ButtonGadget(11, 10,380,200,20,"Move Up")
           ButtonGadget(12, 10,410,200,20,"Move Down")
            

    CreateMesh(0) 
    SetMeshData(0, 0, ?CubeVertices          , 8) 
    SetMeshData(0, 1, ?CubeFacesIndexes      , 12) 
    SetMeshData(0, 2, ?CubeTextureCoordinates, 8) 
    
   CreateEntity(0, MeshID(0), CreateMaterial(0, LoadTexture(0, "Data/clouds.jpg")))
    
    ScaleEntity(0, 3, 3, 3) 
    
    CreateCamera(0, 0, 0, 100, 100) 
    CameraLocate(0,0,0,20) 
    CameraRenderMode(0, #PB_Camera_Wireframe)
    
    Repeat 
    EventID = WaitWindowEvent()
         If EventID = #PB_EventGadget
           Select EventGadgetID()
       
       Case 1 ; Set spin gadget to value of vertice 
     vert$ = GetGadgetText(1)
     targ$= GetGadgetText(2)
     If vert$ = "A"
     temp.b = 0
     EndIf
     If vert$ = "B"
     temp.b = 4
     EndIf
      If vert$ = "C"
     temp.b = 8
     EndIf
     If vert$ = "D"
     temp.b = 12
     EndIf
     If vert$ = "E"
     temp.b = 16
     EndIf
     If vert$ = "F"
     temp.b = 20
     EndIf
     If vert$ = "G"
     temp.b = 24
     EndIf
     If vert$ = "H"
     temp.b = 28
     EndIf
     If vert$ = "I"
     temp.b = 32
     EndIf
     If vert$ = "J"
     temp.b = 36
     EndIf
     If vert$ = "K"
     temp.b = 40
     EndIf
     If vert$ = "L"
     temp.b = 44
     EndIf
     If vert$ = "M"
     temp.b = 48
     EndIf
     If vert$ = "N"
     temp.b = 52
     EndIf
     If vert$ = "O"
     temp.b = 56
     EndIf
     If vert$ = "P"
     temp.b = 60
     EndIf
     If vert$ = "Q"
     temp.b = 64
     EndIf
     If vert$ = "R"
     temp.b = 68
     EndIf
     If vert$ = "S"
     temp.b = 72
     EndIf
     If vert$ = "T"
     temp.b = 76
     EndIf
     If vert$ = "U"
     temp.b = 80
     EndIf
     If vert$ = "V"
     temp.b = 84
     EndIf
     If vert$ = "W"
     temp.b = 88
     EndIf
     If vert$ = "X"
     temp.b = 92
     EndIf
     flag.f = PeekF(?CubeVertices+temp)  
     SetGadgetState(2,flag)
     flag$=Str(flag)
     SetGadgetText(2,flag$)
           
       Case 12
       MoveCamera  (0, 0, 0.1, 0)    
       DrawScreen()         
           
           
      Case 11
       MoveCamera  (0, 0, -0.1, 0)    
       DrawScreen()
       
      Case 10
      MoveCamera  (0, 0, 0,0.2)
      DrawScreen()
    
           
      Case 9
      MoveCamera  (0, 0, 0,-0.2)
      DrawScreen()
      
           
     Case 8
      RotateEntity(0, 0, 1, 0)
      DrawScreen()     
           
     Case 7
     RotateEntity(0, 0, -1, 0)
     DrawScreen()
                
     Case 6
      RotateEntity(0, 1, 0, 0)
      DrawScreen()     
           
     Case 5
      RotateEntity(0, -1, 0, 0)
      DrawScreen()
           
           
     Case 4
     End
           
           
     Case 2
     SetGadgetText(2,Str(GetGadgetState(2)))
     WindowEvent()
     vert$ = GetGadgetText(1)
     targ$= GetGadgetText(2)
     target.f = Val(targ$)
     PokeF(?CubeVertices+temp, target) 
     SetMeshData(0, 0, ?CubeVertices          , 8) 
     DrawScreen()

            
             
           EndSelect
         EndIf
  Until EventID = #PB_Event_CloseWindow 
End
                

 
     
      
      
 EndIf 
EndIf
EndIf

  
End 


DataSection 

  CubeVertices: 
    Data.f 0, 0, 0 ; Vertex index 0 
    Data.f 1, 0, 0 ; Vertex index 1 
    Data.f 1, 0, 1 ; Vertex index 2 
    Data.f 0, 0, 1 ; Vertex index 3 

    Data.f 0, 1, 0 ; Vertex index 4 - Note: exactly the same as above, but with 'y' 
    Data.f 1, 1, 0 ; Vertex index 5 
    Data.f 1, 1, 1 ; Vertex index 6 
    Data.f 0, 1, 1 ; Vertex index 7 

  CubeFacesIndexes: 
    Data.w 0, 1, 2 ; bottom face (clockwise as it's reversed...) 
    Data.w 2, 3, 0 
    Data.w 6, 5, 4 ; top face 
    Data.w 4, 7, 6 
    Data.w 1, 5, 6 ; right face 
    Data.w 6, 2, 1 
    Data.w 7, 4, 0 ; left face 
    Data.w 0, 3, 7 
    Data.w 5, 1, 0 ; back face 
    Data.w 0, 4, 5 
    Data.w 2, 6, 7 ; front face 
    Data.w 7, 3, 2 

  CubeTextureCoordinates: 
    Data.f 0   , 0.33 ; Vertex 0 
    Data.f 0.33, 0.33 ; Vertex 1 
    Data.f 0.33, 0    ; Vertex 2 
    Data.f 0,    0    ; Vertex 3 

    Data.f 0.66, 1    ; Vertex 4 
    Data.f 1,    1    ; Vertex 5 
    Data.f 1,    0.66 ; Vertex 6 
    Data.f 0.66, 0.66 ; Vertex 7 
      
EndDataSection 
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

Hi, isn't possible to put the 3D view inside a (draggable) window, instead of viewing that black hole inside my desktop? :wink:

After searching for a Lightwavw3D importer for OGRE, I've understood that it doesn't exist!!! (despite what the PB manual said)

Years ago I had already done it for a my C/OpenGL project, so I should just convert it, but I'm worried about the bad handling of variable types with PB (no longwords, no unsigned variables !!!) I wouldn't get crazy using absurd tricks to make things work. Someone talked about BP v4.0? When?
Fred
Administrator
Administrator
Posts: 18384
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Blade wrote:After searching for a Lightwavw3D importer for OGRE, I've understood that it doesn't exist!!! (despite what the PB manual said)
http://members.chello.nl/dennisverbeek/ ... esh082.zip Am I hallucinating or what ? :wink:
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Hmmm

Post by LJ »

@Blade,

You can stick your black hole anywhere you want. :twisted:

In the next revision I'll add the dragable window.

Lj
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

http://members.chello.nl/dennisverbeek/ ... esh082.zip Am I hallucinating or what ? :wink:[/quote]

I searched a lot, and Google failed any search... thanks a lot! :D
Post Reply