Green...

Everything related to 3D programming
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Green...

Post 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()
Last edited by DK_PETER on Tue Oct 22, 2019 1:05 pm, edited 2 times in total.
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
#NULL
Addict
Addict
Posts: 1499
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Green...

Post 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.
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Green...

Post by DK_PETER »

The link works perfectly here. :?:
Copy/pasted the code from a different machine and it still runs fine.
It should work...
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
STARGÅTE
Addict
Addict
Posts: 2266
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Green...

Post 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
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Green...

Post by DK_PETER »

That's odd..I'll make the downloads available real soon from other location. :shock:
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Green...

Post by DK_PETER »

Updated...
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
blueb
Addict
Addict
Posts: 1121
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Green...

Post 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.
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Green...

Post by DK_PETER »

Here's the entire project..Unpack and run...
https://www.dropbox.com/s/z003j87aqrjjf ... n.zip?dl=0
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
#NULL
Addict
Addict
Posts: 1499
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Green...

Post by #NULL »

Works on linux. Looks cool. Makes me wanna play xcom: ufo defense :D
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5524
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Green...

Post by Kwai chang caine »

Very very nice..i love it :shock:
Thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: Green...

Post by applePi »

nice and green
Thank you DK_PETER
User avatar
blueb
Addict
Addict
Posts: 1121
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Green...

Post 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'?
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Green...

Post 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. :)
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Post Reply