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?
3d Engine Textured Plain.
Re: 3d Engine Textured Plain.
not directly...
you can draw text to an image, save the image and then load it from disk as a texture...
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
WARNING: may be talking out of his hat
Re: 3d Engine Textured Plain.
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.
Re: 3d Engine Textured Plain.
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- Rook Zimbabwe
- Addict

- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Re: 3d Engine Textured Plain.
A link to the knob.png pic you used would be nice 
Re: 3d Engine Textured Plain.
you can replace "knob.png" with any square png or bmp image
Re: 3d Engine Textured Plain.
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
EndDataSectionPlease correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/

