a great addition to the 3D. just a note that using
MoveEntity(3, 0, 0, -0.05, #PB_Local)
RotateEntity(3, 0, -1, 0, #PB_Relative)
i can't revolve the object around itself using RotateEntity(3, 0, y, 0, #PB_Absolute) while orbiting it will interfere with the two lines above unless i am wrong. here comes the possible usefulness of the virtual TurnEntity
but we can revolve it while orbiting using node ideas. here is the two codes, save to Examples\3D folder
the examples are edited to work with PB v5.31 _ 22 June 2015
orbiting:
Code: Select all
Enumeration
#MESH
#TEX
#TEX_plane
#MAT
#MAT_plane
#plane
#LIGHT
#CAMERA_ONE
#mainwin
EndEnumeration
Global Quit.b = #False
Speed = 0.5
If OpenWindow(#mainwin, 0, 0, 500, 480, "press ESC to exit...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;Initialize environment
InitEngine3D()
InitSprite()
InitKeyboard()
OpenWindowedScreen(WindowID(#mainwin), 0, 0, 500, 400, 0, 0, 0)
;WorldShadows(#PB_Shadow_Additive)
WorldShadows(#PB_Shadow_Modulative, -1, RGB(255, 255, 0))
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
CreateMaterial(#MAT_plane, LoadTexture(#TEX_plane, "clouds.jpg"))
CreatePlane(#plane, 10, 10, 1, 1, 1, 1)
CreateEntity (#plane, MeshID(#plane), MaterialID(#MAT_plane))
LoadTexture(#TEX, "Geebee2.bmp")
CreateMaterial(#MAT, TextureID(#TEX))
CreateSphere(3, 0.5)
CreateEntity(3, MeshID(3), MaterialID(#MAT))
MoveEntity(3,-3,1.5,0)
CreateLight(0,RGB(255,255,255),-50,40,30)
AmbientColor(RGB(100,100,100))
CreateCamera(#CAMERA_ONE, 0, 0, 100, 100)
MoveCamera(#CAMERA_ONE, 0, 4, 9)
CameraLookAt(#CAMERA_ONE, 0, 2, 0)
EndIf
rot.f=4
;Main loop
Repeat
Event = WindowEvent()
y.f + rot
x.f + rot
z.f + rot
;RotateEntity(3, 0, 6, 0)
MoveEntity(3, 0, 0, -0.05, #PB_Local)
RotateEntity(3, 0, -1, 0, #PB_Relative)
RenderWorld()
FlipBuffers()
ExamineKeyboard()
If KeyboardReleased(#PB_Key_Escape)
Quit = #True
EndIf
Until Quit = #True Or Event = #PB_Event_CloseWindow
Orbiting while revolving:
Code: Select all
Enumeration
#MESH
#TEX
#TEX_plane
#MAT
#MAT_plane
#plane
#LIGHT
#CAMERA_ONE
#mainwin
EndEnumeration
Global Quit.b = #False
Speed = 0.5
If OpenWindow(#mainwin, 0, 0, 500, 480, "press ESC to exit...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;Initialize environment
InitEngine3D()
InitSprite()
InitKeyboard()
OpenWindowedScreen(WindowID(#mainwin), 0, 0, 500, 400, 0, 0, 0)
;WorldShadows(#PB_Shadow_Additive)
WorldShadows(#PB_Shadow_Modulative, -1, RGB(255, 255, 0))
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
CreateMaterial(#MAT_plane, LoadTexture(#TEX_plane, "clouds.jpg"))
CreatePlane(#plane, 10, 10, 1, 1, 1, 1)
CreateEntity (#plane, MeshID(#plane), MaterialID(#MAT_plane))
node = CreateNode(#PB_Any, -3,1.5,0)
LoadTexture(#TEX, "Geebee2.bmp")
CreateMaterial(#MAT, TextureID(#TEX))
CreateSphere(3, 0.5)
CreateEntity(3, MeshID(3), MaterialID(#MAT))
AttachNodeObject(node, EntityID(3))
MoveEntity(3,0,0,0)
CreateLight(0,RGB(255,255,255),-50,40,30)
AmbientColor(RGB(100,100,100))
;AttachNodeObject(node, LightID(0))
CreateCamera(#CAMERA_ONE, 0, 0, 100, 100)
MoveCamera(#CAMERA_ONE, 0, 4, 9)
CameraLookAt(#CAMERA_ONE, 0, 2, 0)
EndIf
rot.f=13
;Main loop
Repeat
Event = WindowEvent()
y.f + rot
x.f + rot
z.f + rot
RotateEntity(3, 0, -y, 0)
;MoveEntity(3, 0, 0, -0.05, #PB_Local)
;RotateEntity(3, 0, -1, 0, #PB_Relative)
MoveNode(node, 0, 0, -0.05, #PB_Local)
RotateNode(node, 0, -1, 0, #PB_Relative)
RenderWorld()
FlipBuffers()
ExamineKeyboard()
If KeyboardReleased(#PB_Key_Escape)
Quit = #True
EndIf
Until Quit = #True Or Event = #PB_Event_CloseWindow