3d Engine Textured Plain.

Advanced game related topics
AndyMK
Enthusiast
Enthusiast
Posts: 582
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

3d Engine Textured Plain.

Post by AndyMK »

I have never used the 3d engine commands before. Is it easy to create textured plains from just a loaded image?

Ignore this, i managed to do it.. i have one more question.. can i draw text directly to a texture?
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Re: 3d Engine Textured Plain.

Post by citystate »

not directly...
you can draw text to an image, save the image and then load it from disk as a texture...
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
AndyMK
Enthusiast
Enthusiast
Posts: 582
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: 3d Engine Textured Plain.

Post by AndyMK »

Does anyone have some basic code to create a simple plain ready for texturing, i thought i had it but it didn't work. Im getting confused with the meshdata stuff.
AndyMK
Enthusiast
Enthusiast
Posts: 582
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: 3d Engine Textured Plain.

Post by AndyMK »

Ok, i managed to make a plain with some code i found but i cant get the texture to appear.

Code: Select all

InitEngine3D()
InitSprite()
UsePNGImageDecoder()
Add3DArchive("d:\work\digitalselecta\media", #PB_3DArchive_FileSystem)

ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0)/2, DesktopHeight(0)/2, "")
OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0)/2, DesktopHeight(0)/2, 0, 0, 0)

LoadTexture(0, "knob.png")
CreateMaterial(0, TextureID(0))

CreateMesh(0, 100)

SetMeshData(0, #PB_Mesh_Vertex, ?Ecken, 4)
SetMeshData(0, #PB_Mesh_Face, ?Viereck_1, 2)
SetMeshData(0, #PB_Mesh_UVCoordinate, ?TexturKoordinaten, 4)

CreateEntity(0, MeshID(0), MaterialID(0))

CreateCamera(0, 0, 0, DesktopWidth(0)/2, DesktopHeight(0)/2)
CameraBackColor(0, $FF0000)
CameraLocate(0, 0, 0, 10)
CameraLookAt(0, EntityX(0), EntityY(0), EntityZ(0))

Repeat
  ClearScreen(0)
  RenderWorld()
  FlipBuffers()
Until WindowEvent() = #PB_Event_CloseWindow

DataSection
  
  Ecken:
  Data.f-1, -1, 0 ; Ecke 0             3-----2
  Data.f 1, -1, 0 ; Ecke 1             |     |
  Data.f 1, 1, 0  ; Ecke 2             |     |
  Data.f-1, 1, 0  ; Ecke 3             0-----1
  
  Viereck_1:
  Data.w 0, 1, 2
  Data.w 2, 3, 0
  
  TexturKoordinaten:
  Data.f 0.0, 0.0 ; Vertex 0
  Data.f 1.0, 0.0 ; Vertex 1
  Data.f 1.0, 1.0 ; Vertex 2
  Data.f 0.0, 1.0 ; Vertex 3
    
EndDataSection
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: 3d Engine Textured Plain.

Post by Rook Zimbabwe »

A link to the knob.png pic you used would be nice :D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
AndyMK
Enthusiast
Enthusiast
Posts: 582
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: 3d Engine Textured Plain.

Post by AndyMK »

you can replace "knob.png" with any square png or bmp image
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: 3d Engine Textured Plain.

Post by Comtois »

I changed few lines, it work like this

Code: Select all

InitEngine3D()
InitSprite()
UsePNGImageEncoder()
Add3DArchive("d:\", #PB_3DArchive_FileSystem)

ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0)/2, DesktopHeight(0)/2, "")
OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0)/2, DesktopHeight(0)/2, 0, 0, 0)

CreateImage(0, 256,256)
StartDrawing(ImageOutput(0))
  Box(0,0,256,256, #Red)
  Circle(128,128,80, #Blue)
StopDrawing()
SaveImage(0, "d:\knob.png",#PB_ImagePlugin_PNG)

LoadTexture(0, "knob.png")


CreateMaterial(0, TextureID(0))

CreateMesh(0, 100)

SetMeshData(0, #PB_Mesh_Vertex | #PB_Mesh_UVCoordinate, ?Ecken, 4)
SetMeshData(0, #PB_Mesh_Face, ?Viereck_1, 2)

CreateEntity(0, MeshID(0), MaterialID(0))

CreateCamera(0, 0, 0, DesktopWidth(0)/2, DesktopHeight(0)/2)
CameraBackColor(0, $FFFF00)
CameraLocate(0, 0, 0, 10)
CameraLookAt(0, EntityX(0), EntityY(0), EntityZ(0))

Repeat
  ClearScreen(0)
  RenderWorld()
  FlipBuffers()
Until WindowEvent() = #PB_Event_CloseWindow

DataSection
 
  Ecken:
  Data.f-1, -1, 0 ; Ecke 0            
  Data.f 0.0, 0.0 ; Vertex 0
  Data.f 1, -1, 0 ; Ecke 1  
  Data.f 1.0, 0.0 ; Vertex 1            
  Data.f 1, 1, 0  ; Ecke 2  
  Data.f 1.0, 1.0 ; Vertex 2            
  Data.f-1, 1, 0  ; Ecke 3           
  Data.f 0.0, 1.0 ; Vertex 3

  Viereck_1:
  Data.w 0, 1, 2
  Data.w 2, 3, 0
  
EndDataSection
Please correct my english
http://purebasic.developpez.com/
Post Reply