if you replace number 20 with 0 then the texture wood.jpg will be completely transparent, change 20 to 160 and it is semi transparent , change it to 255 and it is completely opaque wood
. i suppose you want to look from the front wall and to see the rear textured wall . this what i understant from "the front without texture"
to texture the rear and front walls and any wall , i prefer to build the cube from scratch from 6 submeshes (numbered 0 to 5) and after that we assign a specific texture to specific submesh (the cube side) like this for the front wall
SetEntityMaterial(0, MaterialID(#tex2), 0) ; material for the cube front side (transparent
use the keys and mouse to move the camera. try to go inside the cube, you can make it very big by scaling it again. press 'space' key to stop rotation. press 'W' to see the cube wireframe
Code: Select all
Declare DrawCube()
Define.f keyX, keyY, CameraSpeed = 0.1
Enumeration
#mesh
#entity
#tex
#tex2
#tex3
#tex4
#tex5
#texWhite
#light
#camera
#sphere
EndEnumeration
InitEngine3D(#PB_Engine3D_DebugLog)
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops()
OpenWindow(0,0,0,DesktopWidth(0), DesktopHeight(0),"Cube with different textures",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,DesktopWidth(0), DesktopHeight(0),1,0,0,#PB_Screen_WaitSynchronization)
Add3DArchive(".", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
KeyboardMode(#PB_Keyboard_AllowSystemKeys)
CreateMaterial(#texWhite, LoadTexture(#texWhite, "white.jpg"))
MaterialBlendingMode(#texWhite, #PB_Material_AlphaBlend)
SetMaterialColor(#texWhite, #PB_Material_DiffuseColor, RGBA(255, 255, 255, 50))
CreateMaterial(#tex, LoadTexture(#tex, "Geebee2.bmp"))
MaterialCullingMode(#tex, #PB_Material_NoCulling)
CreateMaterial(#tex2, LoadTexture(#tex2, "Wood.jpg"))
MaterialBlendingMode(#tex2, #PB_Material_AlphaBlend)
SetMaterialColor(#tex2, #PB_Material_DiffuseColor, RGBA(255, 255, 255, 20))
CreateMaterial(#tex4, LoadTexture(#tex4, "DosCarte.png"))
MaterialCullingMode(#tex4, #PB_Material_NoCulling)
CreateMaterial(#tex5, LoadTexture(#tex5, "ValetCoeur.jpg"))
MaterialCullingMode(#tex5, #PB_Material_NoCulling)
MaterialBlendingMode(#tex5, #PB_Material_AlphaBlend)
SetMaterialColor(#tex5, #PB_Material_DiffuseColor, RGBA(255, 255, 255, 120))
MaterialCullingMode(#tex2, #PB_Material_NoCulling)
CreateMaterial(#tex3, LoadTexture(#tex3, "MRAMOR6X6.jpg"))
CreatePlane(500, 30, 30, 5, 5, 2, 2)
CreateEntity(500, MeshID(500), MaterialID(#tex3), 0,-6,0)
CreateLight(0,RGB(245,245,205),6,13,0)
;Create Camera
CreateCamera(0,0,0,100,100)
MoveCamera(0,0,0, 10,#PB_Absolute)
CameraLookAt(0, 0, 0, 0)
CameraBackColor(0, RGB(0,200,200))
AmbientColor(RGB(100,100,100))
;WorldShadows(#PB_Shadow_Modulative , -1, RGB(100, 100, 100))
;WorldShadows(#PB_Shadow_Additive )
;-Mesh
DrawCube()
CreateSphere(#sphere, 0.5)
CreateEntity(#sphere,MeshID(#sphere), #PB_Material_None, 0,-1,0 )
wireFrame = 1 : rot=1
Repeat
WindowEvent()
If ExamineMouse()
MouseX = -MouseDeltaX() * CameraSpeed * 0.7
MouseY = -MouseDeltaY() * CameraSpeed * 0.7
EndIf
ShowCursor_(0)
; Use arrow keys and mouse to rotate camera and fly in/out
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX.f = -CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX.f = CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = CameraSpeed
Else
KeyY = 0
EndIf
If KeyboardReleased(#PB_Key_W)
If wireFrame
MaterialShadingMode(#tex, #PB_Material_Wireframe)
MaterialShadingMode(#tex2, #PB_Material_Wireframe)
MaterialShadingMode(#tex5, #PB_Material_Wireframe)
MaterialShadingMode(#tex4, #PB_Material_Wireframe)
wireFrame ! 1
Else
MaterialShadingMode(#tex, #PB_Material_Solid)
MaterialShadingMode(#tex2, #PB_Material_Solid)
MaterialShadingMode(#tex5, #PB_Material_Solid)
MaterialShadingMode(#tex4, #PB_Material_Solid)
wireFrame ! 1
EndIf
EndIf
If KeyboardReleased(#PB_Key_Space) ;press key to toggle the rotation of the object
rot ! 1
EndIf
RotateEntity(0, 0, rot, 0,#PB_Relative)
RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
MoveCamera (0, KeyX, 0, KeyY)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or WindowEvent() = #PB_Event_CloseWindow
;main drawing routine
Procedure DrawCube()
CreateMesh(0, #PB_Mesh_TriangleList, #PB_Mesh_Dynamic)
;pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
;subMesh 0 ; Front Side
MeshVertexPosition(-1,-1,1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(0, 0)
MeshVertexPosition(1,-1,1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(1,1,1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(1, 1)
MeshVertexPosition(-1,1,1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(0, 1)
MeshFace(0, 1, 2)
MeshFace(2,3,0)
;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
;subMesh 1 ; right side
AddSubMesh(#PB_Mesh_TriangleList)
MeshVertexPosition(1,-1,1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(0, 0)
MeshVertexPosition(1,-1,-1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(1,1,-1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(1, 1)
MeshVertexPosition(1,1,1);;;;;;
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(0, 1)
MeshFace(0, 1, 2)
MeshFace(2,3,0)
;;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
;subMesh 2 ; back side
AddSubMesh(#PB_Mesh_TriangleList)
MeshVertexPosition(1,-1,-1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(0, 0)
MeshVertexPosition(-1,-1,-1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(-1,1,-1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(1, 1)
MeshVertexPosition(1,1,-1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(0, 1)
MeshFace(0, 1, 2)
MeshFace(2,3,0)
;000000000000000000000000000000000000000000000000000000000
;subMesh 3 ; Left side
AddSubMesh(#PB_Mesh_TriangleList)
MeshVertexPosition(-1,-1,-1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(0, 0)
MeshVertexPosition(-1,-1,1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(-1,1,1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(1, 1)
MeshVertexPosition(-1,1,-1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(0, 1)
MeshFace(0, 1, 2)
MeshFace(2,3,0)
;000000000000000000000000000000000000000000000000000000000
;subMesh 4 ; Upper side
AddSubMesh(#PB_Mesh_TriangleList)
MeshVertexPosition(-1,1,1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(0, 0)
MeshVertexPosition(1,1,1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(1,1,-1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(1, 1)
MeshVertexPosition(-1,1,-1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(0, 1)
MeshFace(0, 1, 2)
MeshFace(2,3,0)
;000000000000000000000000000000000000000000000000000000000
;subMesh 5 ; Bottom side
AddSubMesh(#PB_Mesh_TriangleList)
MeshVertexPosition(-1,-1,-1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(0, 0)
MeshVertexPosition(1,-1,-1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(1,-1,1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(1, 1)
MeshVertexPosition(-1,-1,1)
MeshVertexNormal(0,1,0)
MeshVertexTextureCoordinate(0, 1)
MeshFace(0, 1, 2)
MeshFace(2,3,0)
FinishMesh(#True)
CreateEntity(0, MeshID(0), MaterialID(#tex) ,0,0,0)
ScaleEntity(0, 2,2,2)
SetEntityMaterial(0, MaterialID(#tex2), 0) ; material for the cube front side (transparent
SetEntityMaterial(0, MaterialID(#tex4), 2) ;material for the cube Back side
SetEntityMaterial(0, MaterialID(#tex5), 1) ; material for the cube right side
SetEntityMaterial(0, MaterialID(#tex5), 3) ; material for the cube Left side
;SetEntityMaterial(0, MaterialID(#tex2), 1)
EndProcedure
i don't know how to do this now, but i saw in the PB examples the robot throw particles like a thick line .