also, Dein Code funktioniert, danke dafür und für die Erläuterung, wäre wohl auch ein Thema das in die Hilfe mit aufgenommen werden sollte.
ABER, wenn ich Deinen Code einbaue, geht es trotzdem nicht, hier das gesamte Beispiel:
Code: Alles auswählen
EnableExplicit
Define.i sprite, tempTexture, tempMaterial, tempMesh, font, mx, my, camera, light, entity, entBtn1, entBtn2, entBakgrd, picked
Declare.i CreateButton3D(hEntity.i, hMaterial.i, xSize.i, ySize.i)
Declare CreateStaticBackground(hEntity.i, hMaterial.i, hFarestEntity.i, TextureRepeatX.i=1, TextureRepeatY.i=1)
; init
InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
OpenWindow(0,0,0,1024,768,"3D Buttons",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0, #PB_Screen_WaitSynchronization)
; create objects
font = LoadFont(#PB_Any, "Wingdings", 28, #PB_Font_HighQuality)
sprite = CreateSprite(#PB_Any, 32, 32)
StartDrawing(SpriteOutput(sprite))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(font))
DrawText(0, 0, Chr(245), RGB(192,192,192))
StopDrawing()
FreeFont(font)
font = LoadFont(#PB_Any, "Wingdings", 60, #PB_Font_HighQuality)
; create cube texture
tempTexture = CreateTexture(#PB_Any, 256, 256)
StartDrawing(TextureOutput(tempTexture))
Box(0, 0, 256, 256, 0)
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor(RGB(63, 0, 191))
BackColor(RGB(255, 128, 0))
BoxedGradient(0, 0, 256, 256)
Box(0, 0, 256, 256)
StopDrawing()
; create cube mesh and material
tempMaterial = CreateMaterial(#PB_Any, TextureID(tempTexture))
tempMesh = CreateCube(#PB_Any, 50)
; create cube entity
entity = CreateEntity(#PB_Any, MeshID(tempMesh), MaterialID(tempMaterial), 0, 0, -50)
RotateEntity(entity, 0, 45, 0, #PB_Relative)
FreeMesh(tempMesh)
FreeMaterial(tempMaterial)
FreeTexture(tempTexture)
; create button texture
tempTexture = CreateTexture(#PB_Any, 128, 128)
StartDrawing(TextureOutput(tempTexture))
DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Transparent)
DrawingFont(FontID(font))
Box(0, 0, 128, 128, RGBA(0,255,0,64))
Box(8, 8, 112, 112, RGBA(0,128,0,128))
DrawText(128/2-TextWidth(Chr(231))/2, 128/2-TextHeight(Chr(231))/2, Chr(231), RGBA(0,255,0,192))
StopDrawing()
; create button material
tempMaterial = CreateMaterial(#PB_Any, TextureID(tempTexture))
MaterialBlendingMode(tempMaterial, #PB_Material_AlphaBlend)
; create button mesh and entity
entBtn1 = CreateButton3D(#PB_Any, tempMaterial, 20, 20)
MoveEntity(entBtn1, -50, -25, -25)
FreeMaterial(tempMaterial)
FreeTexture(tempTexture)
; create button 2 texture
tempTexture = CreateTexture(#PB_Any, 128, 128)
StartDrawing(TextureOutput(tempTexture))
DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Transparent)
DrawingFont(FontID(font))
Box(0, 0, 128, 128, RGBA(0,255,0,64))
Box(8, 8, 112, 112, RGBA(0,128,0,128))
DrawText(128/2-TextWidth(Chr(232))/2, 128/2-TextHeight(Chr(232))/2, Chr(232), RGBA(0,255,0,192))
StopDrawing()
; create button 2 material
tempMaterial = CreateMaterial(#PB_Any, TextureID(tempTexture))
MaterialBlendingMode(tempMaterial, #PB_Material_AlphaBlend)
; create button 2 mesh and entity
entBtn2 = CreateButton3D(#PB_Any, tempMaterial, 20, 20)
MoveEntity(entBtn2, 50, -25, -25)
FreeMaterial(tempMaterial)
FreeTexture(tempTexture)
; create background texture and material
tempTexture = CreateTexture(#PB_Any, 64, 64)
StartDrawing(TextureOutput(tempTexture))
Box(0,0,64,64,RGB(65, 105, 225))
StopDrawing()
tempMaterial = CreateMaterial(#PB_Any, TextureID(tempTexture))
; create background mesh and entity
tempMesh = CreateMesh(#PB_Any)
MeshVertexPosition(-1000, 1000, 0)
MeshVertexTextureCoordinate(0, 1)
MeshVertexPosition(1000, 1000, 0)
MeshVertexTextureCoordinate(1, 1)
MeshVertexPosition(1000, -1000, 0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(-1000, -1000, 0)
MeshVertexTextureCoordinate(0, 0)
MeshFace(3, 1, 0)
MeshFace(3, 2, 1)
FinishMesh(#True)
entBakgrd = CreateEntity(#PB_Any, MeshID(tempMesh), MaterialID(tempMaterial))
MoveEntity(entBakgrd, 0, 0, -500, #PB_Absolute)
FreeMesh(tempMesh)
FreeMaterial(tempMaterial)
FreeTexture(tempTexture)
; create light
light = CreateLight(#PB_Any, RGB(225, 225, 225), 0, 0, 250, #PB_Light_Directional)
LightLookAt(light, EntityX(entity), EntityY(entity), EntityZ(entity))
; create camera
camera = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(camera, 0, 0, 250, #PB_Absolute)
AmbientColor(RGB(32,32,32))
FreeFont(font)
MouseLocate(WindowWidth(0)/2, WindowHeight(0)/2)
Repeat
While WindowEvent() : Wend
ExamineKeyboard()
If ExamineMouse()
mx = MouseX()
my = MouseY()
If MouseButton(#PB_MouseButton_Left)
picked = MousePick(camera, mx, my)
If picked >= 0
Select picked
Case entBtn1 : RotateEntity(entity, 0, -1, 0, #PB_Relative)
Case entBtn2 : RotateEntity(entity, 0, 1, 0, #PB_Relative)
EndSelect
EndIf
EndIf
EndIf
RenderWorld()
DisplayTransparentSprite(sprite, mx, my)
FlipBuffers()
Until KeyboardReleased(#PB_Key_Escape)
End
Procedure.i CreateButton3D(hEntity.i, hMaterial.i, xSize.i, ySize.i)
Protected.i mesh, entity
mesh = CreateMesh(#PB_Any, #PB_Mesh_TriangleList, #PB_Mesh_Static)
MeshVertexPosition(-xSize/2, ySize/2, 0)
MeshVertexTextureCoordinate(0, 1)
MeshVertexPosition(xSize/2, ySize/2, 0)
MeshVertexTextureCoordinate(1, 1)
MeshVertexPosition(xSize/2, -ySize/2, 0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(-xSize/2, -ySize/2, 0)
MeshVertexTextureCoordinate(0, 0)
MeshFace(3, 1, 0)
MeshFace(3, 2, 1)
FinishMesh(#True)
entity = CreateEntity(hEntity, MeshID(mesh), MaterialID(hMaterial))
FreeMesh(mesh)
If hEntity = #PB_Any
ProcedureReturn entity
Else
ProcedureReturn EntityID(entity)
EndIf
EndProcedure
Procedure CreateStaticBackground(hEntity.i, hMaterial.i, hFarestEntity.i, TextureRepeatX.i=1, TextureRepeatY.i=1)
Protected.i mesh, entity
EndProcedure
Eigentlich wollte ich für einen anderen Thread ein kurzes Beispiel posten und "mal eben" was zusammenschreiben und die Meshes selber erstellen, bei mir wird aber immer nur die zweite Oberfläche (face) angezeigt. An 5.11 kann es nicht liegen, da wie gesagt Dein Code funktioniert. Was läuft bei mir falsch ? Noch eine Idee ?