What am I doing wrong? (trying to texture mesh/entity)
Posted: Sat Sep 23, 2006 2:14 am
Ok, here's what I've got so far:
But it's just a blue screen. and I don't see my PNG image.
When i remove this line:
Then I see a white square where the image should be, but the image isn't on it.
Is there something that I'm missing to Texture an Entity?
Code: Select all
Structure s_Vertex
px.f
py.f
pz.f
u.f
v.f
EndStructure
Structure s_Face
face.w[3]
EndStructure
InitEngine3D()
InitSprite()
;InitSprite3D()
InitKeyboard()
InitMouse()
ScreenW = 800
ScreenH = 600
BitDepth = 32 ;This should be changed in settings
ProgramName.s = "test"
;Allows us to use PNG files!
UsePNGImageDecoder()
OpenScreen(ScreenW, ScreenH, BitDepth, ProgramName.s)
Add3DArchive("Data\", #PB_3DArchive_FileSystem)
Tid = LoadTexture(#PB_Any, "ship.png")
Mid = CreateMaterial(#PB_Any, TextureID(Tid))
MaterialBlendingMode (Mid, #PB_Material_AlphaBlend | #PB_Material_Add)
MaterialFilteringMode(Mid, #PB_Material_None)
DisableMaterialLighting(Mid, 1)
Ret_Mesh = CreateMesh(#PB_Any, 5)
Dim Vertices.s_Vertex(3)
Dim Triangles.s_Face(1)
Vertices(0)\px = 0
Vertices(0)\py = 0
Vertices(0)\pz = 10
Vertices(0)\u = 0
Vertices(0)\v = 1
Vertices(1)\px = 64
Vertices(1)\py = 0
Vertices(1)\pz = 10
Vertices(1)\u = 0
Vertices(1)\v = 1
Vertices(2)\px = 64
Vertices(2)\py = 64
Vertices(2)\pz = 10
Vertices(2)\u = 0
Vertices(2)\v = 1
Vertices(3)\px = 0
Vertices(3)\py = 64
Vertices(3)\pz = 10
Vertices(3)\u = 0
Vertices(3)\v = 1
Triangles(0)\face[0] = 0
Triangles(0)\face[1] = 1
Triangles(0)\face[2] = 3
Triangles(1)\face[0] = 1
Triangles(1)\face[1] = 2
Triangles(1)\face[2] = 3
SetMeshData(Ret_Mesh, #PB_Mesh_Vertex | #PB_Mesh_UVCoordinate , Vertices(), 4)
SetMeshData(Ret_Mesh, #PB_Mesh_Face, Triangles(), 2)
Ret_Ent = CreateEntity(#PB_Any, MeshID(Ret_Mesh), MaterialID(Mid))
#Camera = 0
CreateCamera(#Camera, 0, 0, 100, 100) ; Créate caméra
CameraBackColor(#Camera, $FF0000) ; Back color is blue
CameraLocate(#Camera,0,0,500) ; Position the caméra
CameraLookAt(#Camera, EntityX(Ret_Ent), EntityY(Ret_Ent), EntityZ(Ret_Ent)) ; Point/orient the caméra towards the entity
Repeat
;ClearScreen(0)
;{ Input
If ExamineKeyboard()
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
If KeyboardPushed(#PB_Key_PageUp)
RollZ = 3
Else
If KeyboardPushed(#PB_Key_PageDown)
RollZ = -3
Else
RollZ = 0
EndIf
EndIf
If KeyboardPushed(#PB_Key_Add)
Frame.f+0.005
EndIf
EndIf
If ExamineMouse()
MouseX = -MouseDeltaX()/2
MouseY = -MouseDeltaY()/2
EndIf
;}
RotateCamera(#Camera, MouseX, MouseY, RollZ*2)
MoveCamera (#Camera, KeyX*2, 0, KeyY*2)
RenderWorld() ; Display the 3D world
FlipBuffers()
;Delay(10)
OnErrorResume()
Until KeyboardPushed(#PB_Key_Escape)
Debug ret_ent
End
When i remove this line:
Code: Select all
MaterialBlendingMode (Mid, #PB_Material_AlphaBlend | #PB_Material_Add)
Is there something that I'm missing to Texture an Entity?