Page 1 of 1

Green...

Posted: Tue Oct 22, 2019 11:56 am
by DK_PETER
;Green...Just a little fun..
Depending on your bandwidth...Please be patience.
Edit:
If you get an error downloading the assets - download the assets here:
https://www.dropbox.com/s/fhtp4xr5o5levbt/data.zip?dl=0
and use the second code:

Code: Select all

DeclareModule Globe
  UseJPEGImageDecoder()
 
  Enumeration Initialize
    #globe_InitEngine_Error
    #Globe_InitSprite_Error
    #Globe_InitKeyboard_Error
    #Globe_InitNetwork_Error
    #Globe_InitSound_Error
    #Globe_Init_Success
  EndEnumeration
 
  Declare.i Init()
  Declare.i Setup()
EndDeclareModule

Module Globe
 
  Structure BaseVars
    w.i
    h.i
    win.i
    scr.i
    ev.i
    snd.i
    path.s
    cam.i
    lgt.i
    fn.i
  EndStructure
  Global v.BaseVars, th.i
  Global DoingNow.s = "", DwlAssets.i = #True
 
  Declare.i Run()
  Declare.i DownloadAssetsAndPrepare()
  Declare.i Lines(*Image)
  Declare.i Screen(value.i)
  
  Procedure.i Init()
    If InitNetwork() = 0
      ProcedureReturn #Globe_InitNetwork_Error
    EndIf
    If InitEngine3D(#PB_Engine3D_DebugLog) = 0
      ProcedureReturn #globe_InitEngine_Error
    EndIf
    If InitSprite() = 0
      ProcedureReturn #Globe_InitSprite_Error
    EndIf
    If InitKeyboard() = 0
      ProcedureReturn #Globe_InitKeyboard_Error
    EndIf
    If InitMovie() = 0
      v\snd = #False
    Else
      v\snd = #True
    EndIf
    ProcedureReturn #Globe_Init_Success
  EndProcedure
 
  Procedure.i Setup()
    ExamineDesktops()
    v\w = DesktopWidth(0) : v\h = DesktopHeight(0)
    v\win = OpenWindow(#PB_Any, 0, 0, DesktopWidth(0), DesktopHeight(0), "Globe", #PB_Window_BorderLess)
    v\scr = OpenWindowedScreen(WindowID(v\win), 0, 0, WindowWidth(v\win), WindowHeight(v\win))
    v\cam = CreateCamera(#PB_Any, 0, 0, 100, 100)
    MoveCamera(v\cam, 0, 0, 22)
    v\lgt = CreateLight(#PB_Any, $00FF03, 0, 0, 4)
    run()
  EndProcedure
  
  Procedure.i Screen(value.i)
    Protected spr, ev
    spr = CreateSprite(#PB_Any, v\w, v\h)
    StartDrawing(SpriteOutput(spr))
    Box(0, 0, OutputWidth(), OutputHeight(), $0)
    DrawText(v\w/2 - TextWidth("DOWNLOADING ASSETS")/2, v\h/2 - TextHeight("H")/2, "DOWNLOADING ASSETS")
    StopDrawing()
    
    Repeat    
      RenderWorld()
      DisplaySprite(spr, 0, 0)
      FlipBuffers()
      Delay(20)
    Until DwlAssets = #False
    
  EndProcedure
  
  Procedure.i DownloadAssetsAndPrepare()
    Protected ret.i, spr.i
    DwlAssets = #True
    th = CreateThread(@Screen(), #True)
    
    v\path = GetTemporaryDirectory()
    Add3DArchive(v\path, #PB_3DArchive_FileSystem)

    ret = ReceiveHTTPFile("https://srv-file2.gofile.io/download/MMF7IU/earth_bw.jpg", v\path + "earth.jpg")
    If ret = 0
      MessageRequester("Download error", "Can't download earth.jpg")
      End
    EndIf
    ret = ReceiveHTTPFile("https://srv-file2.gofile.io/download/XSQysm/PB.mesh", v\path + "pb.mesh")
    If ret = 0
      MessageRequester("Download error", "Can't download pb.mesh")
      End
    EndIf
    ret = ReceiveHTTPFile("https://srv-file7.gofile.io/download/W7iXm7/pb.material", v\path + "pb.material")
    If ret = 0
      MessageRequester("Download error", "Can't download pb.material")
      End
    EndIf
    If v\snd = #True
      ret = ReceiveHTTPFile("http://static1.squarespace.com/static/59dcec2112abd985b7417cbd/t/5b9e316f21c67c4506125feb/1537094034349/3.+Nor%C3%B0ur+-+320bit.mp3/original/3.+Nor%C3%B0ur+-+320bit.mp3?download=true", v\path + "celtic.mp3")
    EndIf     
    ;MUSIC FROM INCOMPETECH.COM!! :-)
    Parse3DScripts()
    image.i = LoadImage(#PB_Any, v\path + "earth.jpg")
    ret = Lines(image)
    DwlAssets = #False
    If ret = #True
      CreateSphere(0, 2, 60, 60)
      CreateTexture(0, ImageWidth(image), ImageHeight(image), "earth")
      StartDrawing(TextureOutput(0))
      DrawImage(ImageID(image), 0, 0)
      StopDrawing()
      CreateMaterial(0, TextureID(0))
      MaterialBlendingMode(0, #PB_Material_Add)
      AddMaterialLayer(0, TextureID(0), #PB_Material_Add)
      MaterialFilteringMode(0, #PB_Material_Anisotropic, 8)
      SetMaterialColor(0, #PB_Material_AmbientColor, $00FF03)
      SetMaterialColor(0, #PB_Material_SelfIlluminationColor, $00FF03)
      MaterialCullingMode(0, #PB_Material_NoCulling)
      CreateEntity(0, MeshID(0), MaterialID(0), 0, 0, 13)
      RotateEntity(0, 0, 23.44, 0, #PB_Absolute)
     
      CreateIcoSphere(1, 2.6, 80)
      CreateTexture(1, 512, 512, "Mat2")
      StartDrawing(TextureOutput(1))
      DrawingMode(#PB_2DDrawing_Outlined)
      Box(0, 0, 512, 512, $00FF03)
      StopDrawing()
      CreateMaterial(1, TextureID(1))
      MaterialBlendingMode(1, #PB_Material_Add)
      AddMaterialLayer(1, TextureID(1), #PB_Material_Add)
      MaterialCullingMode(1, #PB_Material_NoCulling)
      ScaleMaterial(1, 0.2, 0.2, 0)
      ScaleMaterial(1, 0.2, 0.2, 1)
      ScrollMaterial(1, -0.1, 0, #PB_Material_Animated, 0)
      ScrollMaterial(1, 0.1, 0, #PB_Material_Animated, 1)
      MaterialFilteringMode(1, #PB_Material_Anisotropic, 8)
      CreateEntity(1, MeshID(1), MaterialID(1), 0, 0, 13)
     
      LoadMesh(2, "pb.mesh")
      GetScriptMaterial(2, "Green")
      CreateEntity(2, MeshID(2), #PB_Material_None, 0, 7, 0)
      RotateEntity(2, 90, 0, 0)
     
      CreateParticleEmitter(3, 100, 100, 100, #PB_Particle_Box, 0, 0, -50)
      CreateTexture(3, 128, 128, "Particle")
      StartDrawing(TextureOutput(3))
      DrawingMode(#PB_2DDrawing_Gradient)
      FrontColor($0) : BackColor($00FF03)
      CircularGradient(64, 64, 54)
      Circle(64, 64, 54)
      GradientColor(0.2,$00FF03)
      StopDrawing()
      CreateMaterial(3, TextureID(3))
      MaterialBlendingMode(3, #PB_Material_Add)
      AddMaterialLayer(3, TextureID(3), #PB_Material_Add)
      ParticleMaterial(3, MaterialID(3))
      ParticleSize(3, 0.1, 0.1)
      ParticleEmissionRate(3, 500)
      ParticleEmitterDirection(3, 0, 0, 1)
      ParticleVelocity(3, #PB_Particle_MinimumVelocity, 3)
      ParticleVelocity(3, #PB_Particle_Velocity, 5)
      ParticleVelocity(3, #PB_Particle_MaximumVelocity, 10)
      ParticleAngle(3, 0, 45)
    EndIf
    If v\snd = #True
      LoadMovie(0, v\path + "celtic.mp3")
      PlayMovie(0, 0)
    EndIf
    ProcedureReturn #True
  EndProcedure
 
  Procedure.i Lines(*image)
    Protected st.i = #True
    Protected w = ImageWidth(*image)-1
    Protected h = ImageHeight(*image)-1
    StartDrawing(ImageOutput(*image))
    For y = 1 To h Step 2
      For x = 1 To w Step 2
        Box(0, y, w, 1, $0)
        Box(x, 0, 1, h, $0)
      Next x
    Next y   
    StopDrawing()
    ProcedureReturn #True
  EndProcedure
 
  Procedure.i Run()
    ret = DownloadAssetsAndPrepare()
    Repeat
     
      Repeat
        v\ev = WindowEvent()
      Until v\ev = 0
     
      ExamineKeyboard()
     
      RotateEntity(0, 0, -0.05, 0, #PB_Relative)
      RotateEntity(1, 0.07, -0.04, -0.05, #PB_Relative)
      RotateEntity(2, 0, 0, -0.05, #PB_Relative)
      RenderWorld()
     
      FlipBuffers()
     
    Until KeyboardPushed(#PB_Key_Escape)
  EndProcedure
 
EndModule

Globe::Init()
Globe::Setup()
Extract the contents of data.zip and run the code below.
The content must be at the same location as the code or
you must change the path yourself.
(Damn! So much extra for such a little simple example.. :lol: )

Code: Select all

DeclareModule Globe
  UseJPEGImageDecoder()
 
  Enumeration Initialize
    #globe_InitEngine_Error
    #Globe_InitSprite_Error
    #Globe_InitKeyboard_Error
    #Globe_InitSound_Error
    #Globe_Init_Success
  EndEnumeration
 
  Declare.i Init()
  Declare.i Setup()
EndDeclareModule

Module Globe
 
  Structure BaseVars
    w.i
    h.i
    win.i
    scr.i
    ev.i
    snd.i
    path.s
    cam.i
    lgt.i
    fn.i
  EndStructure
  Global v.BaseVars, th.i
  Global DoingNow.s = "", DwlAssets.i = #True
 
  Declare.i Run()
  Declare.i DownloadAssetsAndPrepare()
  Declare.i Lines(*Image)
  
  Procedure.i Init()
    If InitEngine3D(#PB_Engine3D_DebugLog) = 0
      ProcedureReturn #globe_InitEngine_Error
    EndIf
    If InitSprite() = 0
      ProcedureReturn #Globe_InitSprite_Error
    EndIf
    If InitKeyboard() = 0
      ProcedureReturn #Globe_InitKeyboard_Error
    EndIf
    If InitMovie() = 0
      v\snd = #False
    Else
      v\snd = #True
    EndIf
    ProcedureReturn #Globe_Init_Success
  EndProcedure
 
  Procedure.i Setup()
    ExamineDesktops()
    v\w = DesktopWidth(0) : v\h = DesktopHeight(0)
    v\win = OpenWindow(#PB_Any, 0, 0, DesktopWidth(0), DesktopHeight(0), "Globe", #PB_Window_BorderLess)
    v\scr = OpenWindowedScreen(WindowID(v\win), 0, 0, WindowWidth(v\win), WindowHeight(v\win))
    v\cam = CreateCamera(#PB_Any, 0, 0, 100, 100)
    MoveCamera(v\cam, 0, 0, 22)
    v\lgt = CreateLight(#PB_Any, $00FF03, 0, 0, 4)
    run()
  EndProcedure
  
 
  Procedure.i DownloadAssetsAndPrepare()
    Protected ret.i, spr.i

    v\path = GetTemporaryDirectory()
    Add3DArchive(".", #PB_3DArchive_FileSystem)
    
    ;MUSIC FROM INCOMPETECH.COM!! :-)
    Parse3DScripts()
    image.i = LoadImage(#PB_Any, "earth.jpg")
    ret = Lines(image)
    If ret = #True
      CreateSphere(0, 2, 60, 60)
      CreateTexture(0, ImageWidth(image), ImageHeight(image), "earth")
      StartDrawing(TextureOutput(0))
      DrawImage(ImageID(image), 0, 0)
      StopDrawing()
      CreateMaterial(0, TextureID(0))
      MaterialBlendingMode(0, #PB_Material_Add)
      AddMaterialLayer(0, TextureID(0), #PB_Material_Add)
      MaterialFilteringMode(0, #PB_Material_Anisotropic, 8)
      SetMaterialColor(0, #PB_Material_AmbientColor, $00FF03)
      SetMaterialColor(0, #PB_Material_SelfIlluminationColor, $00FF03)
      MaterialCullingMode(0, #PB_Material_NoCulling)
      CreateEntity(0, MeshID(0), MaterialID(0), 0, 0, 13)
      RotateEntity(0, 0, 23.44, 0, #PB_Absolute)
     
      CreateIcoSphere(1, 2.6, 80)
      CreateTexture(1, 512, 512, "Mat2")
      StartDrawing(TextureOutput(1))
      DrawingMode(#PB_2DDrawing_Outlined)
      Box(0, 0, 512, 512, $00FF03)
      StopDrawing()
      CreateMaterial(1, TextureID(1))
      MaterialBlendingMode(1, #PB_Material_Add)
      AddMaterialLayer(1, TextureID(1), #PB_Material_Add)
      MaterialCullingMode(1, #PB_Material_NoCulling)
      ScaleMaterial(1, 0.2, 0.2, 0)
      ScaleMaterial(1, 0.2, 0.2, 1)
      ScrollMaterial(1, -0.1, 0, #PB_Material_Animated, 0)
      ScrollMaterial(1, 0.1, 0, #PB_Material_Animated, 1)
      MaterialFilteringMode(1, #PB_Material_Anisotropic, 8)
      CreateEntity(1, MeshID(1), MaterialID(1), 0, 0, 13)
     
      LoadMesh(2, "pb.mesh")
      GetScriptMaterial(2, "Green")
      CreateEntity(2, MeshID(2), #PB_Material_None, 0, 7, 0)
      RotateEntity(2, 90, 0, 0)
     
      CreateParticleEmitter(3, 100, 100, 100, #PB_Particle_Box, 0, 0, -50)
      CreateTexture(3, 128, 128, "Particle")
      StartDrawing(TextureOutput(3))
      DrawingMode(#PB_2DDrawing_Gradient)
      FrontColor($0) : BackColor($00FF03)
      CircularGradient(64, 64, 54)
      Circle(64, 64, 54)
      GradientColor(0.2,$00FF03)
      StopDrawing()
      CreateMaterial(3, TextureID(3))
      MaterialBlendingMode(3, #PB_Material_Add)
      AddMaterialLayer(3, TextureID(3), #PB_Material_Add)
      ParticleMaterial(3, MaterialID(3))
      ParticleSize(3, 0.1, 0.1)
      ParticleEmissionRate(3, 500)
      ParticleEmitterDirection(3, 0, 0, 1)
      ParticleVelocity(3, #PB_Particle_MinimumVelocity, 3)
      ParticleVelocity(3, #PB_Particle_Velocity, 5)
      ParticleVelocity(3, #PB_Particle_MaximumVelocity, 10)
      ParticleAngle(3, 0, 45)
    EndIf
    If v\snd = #True
      LoadMovie(0, "celtic.mp3")
      PlayMovie(0, 0)
    EndIf
    ProcedureReturn #True
  EndProcedure
 
  Procedure.i Lines(*image)
    Protected st.i = #True
    Protected w = ImageWidth(*image)-1
    Protected h = ImageHeight(*image)-1
    StartDrawing(ImageOutput(*image))
    For y = 1 To h Step 2
      For x = 1 To w Step 2
        Box(0, y, w, 1, $0)
        Box(x, 0, 1, h, $0)
      Next x
    Next y   
    StopDrawing()
    ProcedureReturn #True
  EndProcedure
 
  Procedure.i Run()
    ret = DownloadAssetsAndPrepare()
    Repeat
     
      Repeat
        v\ev = WindowEvent()
      Until v\ev = 0
     
      ExamineKeyboard()
     
      RotateEntity(0, 0, -0.05, 0, #PB_Relative)
      RotateEntity(1, 0.07, -0.04, -0.05, #PB_Relative)
      RotateEntity(2, 0, 0, -0.05, #PB_Relative)
      RenderWorld()
     
      FlipBuffers()
     
    Until KeyboardPushed(#PB_Key_Escape)
  EndProcedure
 
EndModule

Globe::Init()
Globe::Setup()

Re: Green...

Posted: Tue Oct 22, 2019 12:11 pm
by #NULL
https://srv-file2.gofile.io/download/MM ... rth_bw.jpg
gives me
You are not authorized to download this file.
and that's also what is written to earth.jpg so that LoadImage() fails.

Re: Green...

Posted: Tue Oct 22, 2019 12:19 pm
by DK_PETER
The link works perfectly here. :?:
Copy/pasted the code from a different machine and it still runs fine.
It should work...

Re: Green...

Posted: Tue Oct 22, 2019 12:46 pm
by STARGĂ…TE
Maybe a location/IP problem, I also got "You are not authorized to download this file."
Germany, Berlin, tested with IE and Chrome

Re: Green...

Posted: Tue Oct 22, 2019 12:49 pm
by DK_PETER
That's odd..I'll make the downloads available real soon from other location. :shock:

Re: Green...

Posted: Tue Oct 22, 2019 1:07 pm
by DK_PETER
Updated...

Re: Green...

Posted: Tue Oct 22, 2019 1:15 pm
by blueb
I get an error on both 32 and 64 bit compiler:

Code: Select all

[07:06:42] Executable started.
[07:06:49] [ERROR] Line: 187
[07:06:49] [ERROR] The specified #Image is not initialised.

Re: Green...

Posted: Tue Oct 22, 2019 1:43 pm
by DK_PETER
Here's the entire project..Unpack and run...
https://www.dropbox.com/s/z003j87aqrjjf ... n.zip?dl=0

Re: Green...

Posted: Tue Oct 22, 2019 1:54 pm
by #NULL
Works on linux. Looks cool. Makes me wanna play xcom: ufo defense :D

Re: Green...

Posted: Tue Oct 22, 2019 6:32 pm
by Kwai chang caine
Very very nice..i love it :shock:
Thanks for sharing 8)

Re: Green...

Posted: Tue Oct 22, 2019 7:37 pm
by applePi
nice and green
Thank you DK_PETER

Re: Green...

Posted: Wed Oct 23, 2019 12:37 pm
by blueb
DK_PETER wrote:Here's the entire project..Unpack and run...
https://www.dropbox.com/s/z003j87aqrjjf ... n.zip?dl=0
Thanks DK_PETER.

Everything worked well.

I opened the Ogre.log file and I clipped the last 10 lines or so...

Code: Select all

06:32:34: All done
06:32:34: Parsing scripts for resource group Internal
06:32:34: Finished parsing scripts for resource group Internal
06:32:34: Creating resources for group Internal
06:32:34: All done
06:32:34: Can't assign material Sphere to SubEntity of E0 because this Material does not exist. Have you forgotten to define it in a .material script?
06:32:35: Can't assign material IcoSphere to SubEntity of E1 because this Material does not exist. Have you forgotten to define it in a .material script?
06:32:35: Mesh: Loading pb.mesh.
Do I need this 'Material script'?

Re: Green...

Posted: Wed Oct 23, 2019 12:55 pm
by DK_PETER
@blueb
I've asked about the error message a while ago without any response.
Now I simply ignore it. It doesn't seem to matter at all. :)