Trying to Texture Sphere - Moon PB v4.41

Advanced game related topics
SoulReaper
Enthusiast
Enthusiast
Posts: 372
Joined: Sun Apr 03, 2005 2:14 am
Location: England

Trying to Texture Sphere - Moon PB v4.41

Post by SoulReaper »

Hello :)

I Seem to be having trouble trying to texture a sphere, I load in the mesh and the texure - there is something i have done wrong :(

Maybe some kind person could put me on the right track, the sphere mesh is from the forum somewhere it was a library with a shape primitives .

The moon keeps turning a grey and plain.
i know its something to do with the mesh because the robot.mesh works, any help welcome.

I have tryed to create a mesh - Sphere in blender and it to appears grey and plain.

Code: Select all

UseJPEGImageEncoder()

InitEngine3D()
InitMouse()

    _Window=#True


   Add3DArchive("I:\Pure Basic Backup\Project\Space Invasion PB\Data",#PB_3DArchive_FileSystem )

   If InitKeyboard()=0 Or InitSprite()=0
   MessageRequester("Error", "Can't open DirectX 7 or Greater", 0) : End
   EndIf

   ExamineDesktops()
   MonitorFrequency=DesktopFrequency(0)
   If MonitorFrequency=0 : MessageRequester("Error", "Failed to open a 800*600 screen!",0) : End : EndIf

   If _Window=#False
     If OpenScreen(800,600,16,"Moon Test",#PB_Screen_WaitSynchronization,MonitorFrequency)
       Else
        MessageRequester("Error", "Failed to open a 800*600 16 bit screen",0)
     EndIf
   EndIf


   If _Window=#True
    OpenWindow(0,0,0,800,600,"Moon Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget)
     If OpenWindowedScreen(WindowID(0),0,0,800,600,1,0,0,#PB_Screen_WaitSynchronization)
       Else
        MessageRequester("Error", "Failed to open a 800*600 32 bit screen",0)
     EndIf
   EndIf


   If LoadMesh   (0, "Moon.Mesh")
   Else
     MessageRequester("Error", "Could not load Mesh",0) : End
   EndIf
   Parse3DScripts()

   If LoadTexture(0, "Moon.jpg")
     Else
   MessageRequester("Error", "Could not load Texture",0) : End
   EndIf


    CreateMaterial(0, TextureID(0))
    CreateEntity(0, MeshID(0), MaterialID(0))

    CreateCamera(0, 0, 0, 800, 600) 
    CameraLocate(0,0,0,5) 
    CameraLookAt(0,0,0,0) 
    CameraBackColor(0, RGB(0,0,0))

    CreateLight(0, RGB(255,255,255), 0, 0, 0)

  Repeat 
    ClearScreen(RGB(0,0,0)) 
    ExamineKeyboard()
    ExamineMouse()
    MouseX = -MouseDeltaX()/10 
    MouseY = -MouseDeltaY()/10
   
    If KeyboardReleased(#PB_Key_F1) 
     ClearScreen(RGB(0,0,0))
     CameraRenderMode(0, #PB_Camera_Wireframe) 
    EndIf 
    
    If KeyboardReleased(#PB_Key_F2)
     ClearScreen(RGB(0,0,0))
     CameraRenderMode(0, #PB_Camera_Textured)
    EndIf 
    
    If KeyboardReleased(#PB_Key_F3)
     ClearScreen(RGB(0,0,0))
     CameraRenderMode(0, #PB_Camera_Plot)
    EndIf 

    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
    
    RotateEntity(0, 0, 1, 0, #PB_Relative)
    RotateCamera(0, MouseY, MouseX, RollZ, #PB_Relative)
    MoveCamera  (0, KeyX, 0, KeyY)

    RenderWorld() 

    StartDrawing(WindowOutput(0)) : DrawingMode(#PB_2DDrawing_Transparent)
      FrontColor(RGB(255,255,255))
      BackColor(RGB(0,0,0))
      DrawingMode(0)
      DrawText(10,70,"Framerate: "+Str(Engine3DFrameRate(#PB_Engine3D_Current)))
    StopDrawing()

    FlipBuffers() 
    
  Until KeyboardPushed(#PB_Key_Escape)
End 



Regards :)
Kevin
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Trying to Texture Sphere - Moon PB v4.41

Post by J. Baker »

Did you uv map your 3d object?
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
SoulReaper
Enthusiast
Enthusiast
Posts: 372
Joined: Sun Apr 03, 2005 2:14 am
Location: England

Re: Trying to Texture Sphere - Moon PB v4.41

Post by SoulReaper »

Hello :)

Must have been the U/V
I have changed over to DelED not a bad 3d model maker, I have got it displaying a sphere textured now but the texture has a line though the middle horizontal and vertical.

Is this because i Selected Auto U/V in Deled editor. or is it to do with the Texture Size W:1024 - H:512

Regards
Kevin :wink:
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Trying to Texture Sphere - Moon PB v4.41

Post by J. Baker »

It may be the fact that you selected auto uv. You might have to adjust a bit.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
Post Reply