I doubt this is a bug but rather the mesh data structure has changed with the 3D engine...
The cube example "MeshManual.pb" no longer creates a cube, nor does it seem to rotate... Works in PB3.94 though.
Mesh format changed in PB4?
Now , Color is a long and RotateEntity() use Absolu angle
Code: Select all
#CameraSpeed = 5
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY,Angle
If InitEngine3D()
Add3DArchive("Data\" , #PB_3DArchive_FileSystem)
Add3DArchive("Data\Skybox.zip", #PB_3DArchive_Zip)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
; The data has to be organize in this order: Vertex, Normal, Color, UVCoordinate (per vertex)
;
; Create a cube, manually.. See the DataSetion, for more precisions
;
CreateMesh(0, 100)
;SetMeshData(0, #PB_Mesh_Vertex | #PB_Mesh_UVCoordinate, ?CubeVertices, 8)
;SetMeshData(0, #PB_Mesh_Face, ?CubeFacesIndexes, 12)
SetMeshData(0, #PB_Mesh_Vertex | #PB_Mesh_Normal | #PB_Mesh_Color, ?CubeData2, 8)
SetMeshData(0, #PB_Mesh_Face, ?CubeDataIndex, 12)
CreateMaterial(0, LoadTexture(0, "clouds.jpg"))
CreateEntity(0, MeshID(0), MaterialID(0))
; ScaleEntity(0, 100, 100, 100)
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0,0,0,1000)
Repeat
Screen3DEvents()
ClearScreen(0)
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
If ExamineMouse()
;If 0
MouseX = -(MouseDeltaX()/10)*#CameraSpeed/2
MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
EndIf
Angle + 1
RotateEntity(0, Angle, Angle, Angle)
RotateCamera(0, MouseX, MouseY, RollZ)
MoveCamera (0, KeyX, 0, KeyY)
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End
#SQRT13 = 0.57735026
DataSection
CubeData2:
Data.f -100.0,100.0,-100.0; //0 position
Data.f -#SQRT13,#SQRT13,-#SQRT13; //0 normal
Data.l $FFFF ;, //0 colour
Data.f 100.0,100.0,-100.0; //1 position
Data.f #SQRT13,#SQRT13,-#SQRT13; //1 normal
Data.l $FFFF ;, //1 colour
Data.f 100.0,-100.0,-100.0;, //2 position
Data.f #SQRT13,-#SQRT13,-#SQRT13;, //2 normal
Data.l $FFFF ;, //2 colour
Data.f -100.0,-100.0,-100.0;, //3 position
Data.f -#SQRT13,-#SQRT13,-#SQRT13;, //3 normal
Data.l $FFFF ;, //3 colour
Data.f -100.0,100.0,100.0;, //4 position
Data.f -#SQRT13,#SQRT13,#SQRT13;, //4 normal
Data.l $FFFF ;, //4 colour
Data.f 100.0,100.0,100.0;, //5 position
Data.f #SQRT13,#SQRT13,#SQRT13;, //5 normal
Data.l $FFFF ;, //5 colour
Data.f 100.0,-100.0,100.0;, //6 position
Data.f #SQRT13,-#SQRT13,#SQRT13;, //6 normal
Data.l $FFFF ;, //6 colour
Data.f -100.0,-100.0,100.0;, //7 position
Data.f -#SQRT13,-#SQRT13,#SQRT13;, //7 normal
Data.l $FFFF ; //7 colour
CubeDataIndex:
Data.w 0,2,3
Data.w 0,1,2
Data.w 1,6,2
Data.w 1,5,6
Data.w 4,6,5
Data.w 4,7,6
Data.w 0,7,4
Data.w 0,3,7
Data.w 0,5,1
Data.w 0,4,5
Data.w 2,7,3
Data.w 2,6,7
EndDataSection
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
to see color , you have to set
Code: Select all
MaterialAmbientColor(0,#PB_Material_AmbientColors)Code: Select all
#CameraSpeed = 5
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY,Angle
If InitEngine3D()
Add3DArchive("Data\" , #PB_3DArchive_FileSystem)
Add3DArchive("Data\Skybox.zip", #PB_3DArchive_Zip)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
; The data has to be organize in this order: Vertex, Normal, Color, UVCoordinate (per vertex)
;
; Create a cube, manually.. See the DataSetion, for more precisions
;
CreateMesh(0, 100)
;SetMeshData(0, #PB_Mesh_Vertex | #PB_Mesh_UVCoordinate, ?CubeVertices, 8)
;SetMeshData(0, #PB_Mesh_Face, ?CubeFacesIndexes, 12)
SetMeshData(0, #PB_Mesh_Vertex | #PB_Mesh_Normal | #PB_Mesh_Color, ?CubeData2, 8)
SetMeshData(0, #PB_Mesh_Face, ?CubeDataIndex, 12)
CreateTexture(0,64,64)
StartDrawing(TextureOutput(0))
Box(0,0,64,64,$FFFFFF)
StopDrawing()
CreateMaterial(0, TextureID(0))
MaterialAmbientColor(0,#PB_Material_AmbientColors)
CreateEntity(0, MeshID(0), MaterialID(0))
; ScaleEntity(0, 100, 100, 100)
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0,0,0,1000)
Repeat
Screen3DEvents()
ClearScreen(0)
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
If ExamineMouse()
;If 0
MouseX = -(MouseDeltaX()/10)*#CameraSpeed/2
MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
EndIf
Angle + 1
RotateEntity(0, Angle, Angle, Angle)
RotateCamera(0, MouseX, MouseY, RollZ)
MoveCamera (0, KeyX, 0, KeyY)
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End
#SQRT13 = 0.57735026
DataSection
CubeData2:
Data.f -100.0,100.0,-100.0; //0 position
Data.f -#SQRT13,#SQRT13,-#SQRT13; //0 normal
Data.l $F87FF ;, //0 colour
Data.f 100.0,100.0,-100.0; //1 position
Data.f #SQRT13,#SQRT13,-#SQRT13; //1 normal
Data.l $34F67F ;, //1 colour
Data.f 100.0,-100.0,-100.0;, //2 position
Data.f #SQRT13,-#SQRT13,-#SQRT13;, //2 normal
Data.l $FF00FF ;, //2 colour
Data.f -100.0,-100.0,-100.0;, //3 position
Data.f -#SQRT13,-#SQRT13,-#SQRT13;, //3 normal
Data.l $FF00FF ;, //3 colour
Data.f -100.0,100.0,100.0;, //4 position
Data.f -#SQRT13,#SQRT13,#SQRT13;, //4 normal
Data.l $FFF3F ;, //4 colour
Data.f 100.0,100.0,100.0;, //5 position
Data.f #SQRT13,#SQRT13,#SQRT13;, //5 normal
Data.l $FFFF ;, //5 colour
Data.f 100.0,-100.0,100.0;, //6 position
Data.f #SQRT13,-#SQRT13,#SQRT13;, //6 normal
Data.l $FFF3F ;, //6 colour
Data.f -100.0,-100.0,100.0;, //7 position
Data.f -#SQRT13,-#SQRT13,#SQRT13;, //7 normal
Data.l $FF12FF ; //7 colour
CubeDataIndex:
Data.w 0,2,3
Data.w 0,1,2
Data.w 1,6,2
Data.w 1,5,6
Data.w 4,6,5
Data.w 4,7,6
Data.w 0,7,4
Data.w 0,3,7
Data.w 0,5,1
Data.w 0,4,5
Data.w 2,7,3
Data.w 2,6,7
EndDataSectionPlease correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
