Copy all files in the same directory. And use this code for cathedral.pb
Code: Select all
; quick and dirty modified cathedral.pb from applePi and Samuel
#LEFTCAM = 0
#RIGHTCAM = 1
#EYES_DISTANCE = 0.05
#SCREENWIDTH = 1280
#SCREENHEIGHT = 1024
Define.f MouseX,MouseY,KeyX,KeyY
;#CameraSpeed = 0.05
#CameraSpeed = 0.2
Enumeration
#MESH
#TEX
#TEX_plane
#MAT
#MAT_plane
#plane
#cathedral
#camera
#mainwin
EndEnumeration
Global Quit.b = #False
Speed = 0.5
;- Initialisation
If InitEngine3D(#PB_Engine3D_DebugLog) = 0
MessageRequester( "Error" , "Can't initialize 3D, check if engine3D.dll is available" , 0 )
End
ElseIf InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse()=0
MessageRequester( "Error" , "Can't initialize Screen, mouse or keyboard" , 0 )
End
EndIf
ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), "use the mouse and arrow keys to move ", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0), DesktopHeight(0), 0, 0, #PB_Screen_SmartSynchronization)
;Initialize environment
;- Ressources
Add3DArchive("compositors\", #PB_3DArchive_FileSystem )
Add3DArchive("shaders\", #PB_3DArchive_FileSystem )
Add3DArchive("textures\", #PB_3DArchive_FileSystem )
Add3DArchive("meshes\", #PB_3DArchive_FileSystem )
Add3DArchive("materials\", #PB_3DArchive_FileSystem )
;- Cathedral
Add3DArchive("Data\", #PB_3DArchive_FileSystem)
Add3DArchive(".", #PB_3DArchive_FileSystem)
Parse3DScripts()
CreateMaterial(#MAT_plane, LoadTexture(#TEX_plane, "basalt.jpg"))
;CreatePlane(#Mesh, TileSizeX, TileSizeZ, TileCountX, TileCountZ, TextureRepeatCountX, TextureRepeatCountZ)
CreatePlane(#plane, 100, 100, 1, 1, 10, 10)
CreateEntity (#plane, MeshID(#plane), MaterialID(#MAT_plane))
LoadMesh(#MESH, "sibenik.mesh")
CreateEntity(#cathedral, MeshID(#MESH), #PB_Material_None )
ScaleEntity(#cathedral,0.5,0.5,0.5)
EntityRenderMode(#cathedral, #PB_Entity_CastShadow)
MoveEntity(#cathedral,0,8,6)
CreateLight(0,RGB(255,255,255),-100,40,30)
CreateLight(1,RGB(255,255,255),0,10,6)
CreateLight(2,RGB(255,255,255),-150,40,30)
CreateLight(3,RGB(255,255,255),150,40,30)
CreateLight(4,RGB(200,190,200),0,3,-10)
;- Lights
AmbientColor($555555)
CreateLight(0, $FFFFFF, 20,50,50)
LightAttenuation(0, 750, 0)
WorldShadows(#PB_Shadow_Additive)
;- Cameras
CreateCamera(#LEFTCAM, 0,0,100,100)
CameraBackColor(#LEFTCAM,0)
MoveCamera(#LEFTCAM, #EYES_DISTANCE, 0, 0,#PB_Absolute)
CreateCamera(#RIGHTCAM, 0,0,100,100)
CameraBackColor(#RIGHTCAM,0)
MoveCamera(#RIGHTCAM, -#EYES_DISTANCE, 0, 0,#PB_Absolute)
; Both cameras (the eyes) are attached to a node (the head)
camNode = CreateNode(#PB_Any,0,0,0)
AttachNodeObject(camNode,CameraID(#LEFTCAM))
AttachNodeObject(camNode,CameraID(#RIGHTCAM))
MoveNode(camNode,0,2,5)
CameraLookAt(#LEFTCAM, 0 , 2, 0)
CameraLookAt(#RIGHTCAM, 0 , 2, 0)
; The view from the "right-eye" camera is rendered to a texture.
; The last param (Ogre name) is used so the render texture can be used in the material script.
rightEyeTex = CreateRenderTexture(#PB_Any,CameraID(#RIGHTCAM),#SCREENWIDTH,#SCREENHEIGHT,#PB_Texture_AutomaticUpdate,"rightEye")
;- Compositor
; This full-screen compositor renders the scene from the "left-eye" camera to a texture,
; then calls a material which passes the "left-eye" and "right-eye" textures to a shader.
; The shader merges the red from one cam and green & blue from the other to get the final result.
CreateCompositorEffect(0, CameraID(0), "stereoscopy")
rot.l=1
;Main loop
;- Main loop
Repeat
While WindowEvent(): Wend
ExamineKeyboard()
; Cameras movement
If ExamineMouse()
MouseX = -MouseDeltaX() * #CameraSpeed
MouseY = -MouseDeltaY() * #CameraSpeed
EndIf
RotateNode(camNode, MouseY, MouseX, 0, #PB_Relative)
; Cube movements
RotateEntity(cube,0.5,0.2,0.3, #PB_Relative)
moveTimer1 + 0.005
moveTimer2 + 0.007
MoveEntity(cube,3 * Cos(moveTimer1),2,-3 + 5 * Sin(moveTimer2),#PB_Absolute)
; Render scene
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1