The watch

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

The watch

Post by DK_PETER »

Edit3: Works now on PB 5.43 and 5.50

Added the CreateTorus() from the link below
http://www.purebasic.fr/english/viewtop ... reatetorus

Code: Select all

;Simple Watch
;Needs active network to download the media files
EnableExplicit
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UseZipPacker()

If InitEngine3D(#PB_Engine3D_DebugLog) = 0
  MessageRequester("Engine error", "Check the output logfile")
  End
EndIf
If InitSprite() = 0
  MessageRequester("Sprite init error", "Exiting")
EndIf
If InitMouse() = 0
  End
EndIf
If InitKeyboard() = 0
  End
EndIf
If InitNetwork() = 0
  End
EndIf

Structure _Obj
  id.i
  ma.i
  ms.i
  tx.i[3]
EndStructure

Structure _Objects
  Inner._Obj
  outer._Obj
  Knob._Obj
  Hours._Obj
  Minut._Obj
  Secs._Obj
  Glass._Obj
  Back._Obj
  SunB._Obj 
  Moon._Obj
  dots._Obj[4]
  nod.i[4]
EndStructure

Structure _Par
  id.i
  ma.i
  tx.i
  no.i
EndStructure

Structure _Navigate
  x.f
  y.f
  z.f
  mx.i
  my.i
EndStructure

Structure _media
  gold.i
  silver.i
  astro.i
  moon.i
  fn.i
EndStructure

Declare.i GetData()
Declare.i MakeWatch()
Declare.i CreateToruss(MinorRadius.f, MajorRadius.f, Meridian = 32, Parallel = 32) ;Starbootic's torus Code

Global m._media, ret.i, ev.i, pck.i, path.s = GetPathPart(ProgramFilename())
Global ver = #PB_Compiler_Version
Global ob._Objects, pa._Par, nav._Navigate, el.i


AntialiasingMode(#PB_AntialiasingMode_x6)
OpenWindow(0, 0, 0, 800, 600, "Time - Use WASD and mouse to navigate. By DK_PETER.", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)
Add3DArchive(path, #PB_3DArchive_FileSystem)

ret = GetData()
ret = MakeWatch()

CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, 4)

el = ElapsedMilliseconds()

Repeat
 
  Repeat
    ev = WindowEvent()
  Until ev = 0
 
  ExamineMouse()
  nav\mx = -MouseDeltaX()/10
  nav\my = -MouseDeltaY()/10
 
  ExamineKeyboard()
 
  If KeyboardPushed(#PB_Key_A)
    nav\x = -0.05
  ElseIf KeyboardPushed(#PB_Key_D)
    nav\x = 0.05
  Else
    nav\x = 0
  EndIf
 
  If KeyboardPushed(#PB_Key_W)
    nav\y = -0.05
  ElseIf KeyboardPushed(#PB_Key_S)
    nav\y = 0.05
  Else
    nav\y = 0
  EndIf
  RotateCamera(0, nav\my, nav\mx, 0, #PB_Relative)
  MoveCamera(0, nav\x, 0, nav\y)
  If ElapsedMilliseconds()-el > 300
    SetMaterialColor(pa\ma, #PB_Material_AmbientColor, RGB(Random(255, 100), Random(255,100),Random(255,100)))
    el = ElapsedMilliseconds()
  EndIf
  RotateNode(ob\nod[1], 0, 0, -Second(Date())*360/60, #PB_Absolute)
  RotateNode(ob\nod[2], 0, 0, -Minute(Date())*360/60, #PB_Absolute)
  RotateNode(ob\nod[3], 0, 0, -Hour(Date())*360/12, #PB_Absolute)
  RotateNode(pa\no, 1, 1, 1, #PB_Relative)
  RenderWorld()
 
  FlipBuffers()

  ExamineKeyboard()
 
Until KeyboardPushed(#PB_Key_Escape)

Procedure.i MakeWatch()
  Protected x.i, y.i, im.i
  If IsImage(m\astro) > 0
    im = CreateImage(#PB_Any, 2048, 2048, 32)
    StartDrawing(ImageOutput(im))
    DrawImage(ImageID(m\astro), 512, 256, 1024, 1536)
    DrawingMode(#PB_2DDrawing_Gradient|#PB_2DDrawing_AlphaBlend)
    FrontColor($AA888888)
    BackColor($00888888)
    EllipticalGradient(OutputWidth() / 2, OutputHeight() / 2, OutputWidth() / 4, OutputHeight() / 3)
    Ellipse(OutputWidth() / 2, OutputHeight() / 2, OutputWidth(), OutputHeight())
    StopDrawing()
    CompilerIf #PB_Compiler_Version = 550
      ob\Inner\tx[0] = CreateTexture(#PB_Any, 2048, 2048, "Astro")
    CompilerElse
      ob\Inner\tx[0] = CreateTexture(#PB_Any, 2048, 2048)
    CompilerEndIf
    StartDrawing(TextureOutput(ob\Inner\tx[0]))
    DrawImage(ImageID(im), 0, 0)
    StopDrawing()
    FreeImage(im)
  EndIf
  With ob\Inner
    \ms = CreateSphere(#PB_Any, 1, 50, 50)
    TransformMesh(\ms, 0, 0, 0, 1, 1, 0.01, 0, 0, 0)
    \ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
    RotateMaterial(\ma, 180, #PB_Material_Fixed)
    ScrollMaterial(\ma, 1024, 0, #PB_Material_Fixed)
    MaterialFilteringMode(\ma, #PB_Material_Anisotropic, 8)
    SetMaterialColor(\ma, #PB_Material_SelfIlluminationColor, $FFFFFF)
    \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0, 0)
    RotateEntity(\id, 180, 0, 0)
  EndWith
  With ob\outer
    CompilerIf #PB_Compiler_Version  >= 550
      \ms = CreateTorus(#PB_Any, 1, 0.03, 50, 70)
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024, "Outer")
    CompilerElse
      \ms = CreateToruss(0.03, 1, 50, 70)
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024)
    CompilerEndIf
    StartDrawing(TextureOutput(\tx[0]))
    DrawImage(ImageID(m\gold), 0, 0, OutputWidth(), OutputHeight())
    StopDrawing()
    \ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
    MaterialFilteringMode(\ma, #PB_Material_Anisotropic, 8)
    ScaleMaterial(\ma, 30, 90)
    RotateMaterial(\ma, 90, #PB_Material_Fixed)
    SetMaterialColor(\ma, #PB_Material_SelfIlluminationColor, $73D4FB)
    \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0, 0)
    CompilerIf #PB_Compiler_Version >= 550
      RotateEntity(\id, 90, 0, 0)
    CompilerEndIf
  EndWith
  With ob\Knob
    \ms = CreateCylinder(#PB_Any, 0.05, 0.05, 30, 30, #True)
    CompilerIf #PB_Compiler_Version >= 550
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024, "Knob")
    CompilerElse
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024)
    CompilerEndIf
    StartDrawing(TextureOutput(\tx[0]))
    DrawImage(ImageID(m\gold), 0, 0, OutputWidth(), OutputHeight())
    StopDrawing()
    \ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
    SetMaterialColor(\ma, #PB_Material_SelfIlluminationColor, $7394FB)
    ScaleMaterial(\ma, 50, 3)
    \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 1.03, 0, 0)
    RotateEntity(\id, 90, 90, 0)
  EndWith
  With ob\Glass
    \ms = CreateSphere(#PB_Any, 1, 50, 50)
    TransformMesh(\ms, 0, 0, 0, 1, 1, 0.07, 0, 0, 0)
    CompilerIf #PB_Compiler_Version >= 550
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024, "Glass")
    CompilerElse
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024)
    CompilerEndIf
    StartDrawing(TextureOutput(\tx[0]))
    DrawingMode(#PB_2DDrawing_AllChannels)
    Box(0, 0, 1024, 1024, $49F9ED9B)
    StopDrawing()
    \ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
    MaterialBlendingMode(\ma, #PB_Material_AlphaBlend)
    \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0, 0.025)
    RotateEntity(\id, 180, 0, 0) 
  EndWith
  With ob\Back
    \ms = CreateSphere(#PB_Any, 1, 50, 50)
    TransformMesh(\ms, 0, 0, 0, 1, 1, 0.03, 0, 0, 0)
    CompilerIf #PB_Compiler_Version >= 550
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024, "Back")
    CompilerElse
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024)
    CompilerEndIf
    StartDrawing(TextureOutput(\tx[0]))
    DrawingMode(#PB_2DDrawing_AllChannels)
    DrawImage(ImageID(m\gold), 0, 0, OutputWidth(), OutputHeight())
    DrawingMode(#PB_2DDrawing_Transparent)
    DrawingFont(FontID(m\fn))
    DrawText(350, 250, "Too often we give", $111111)
    DrawText(352, 252, "Too often we give", $FFFFFF)
    DrawText(300, 300, "children answers to remember", $111111)
    DrawText(302, 302, "children answers to remember", $FFFFFF)
    DrawText(330, 350, "rather than problems to", $111111)
    DrawText(332, 352, "rather than problems to", $FFFFFF)
    DrawText(450, 400, "solve", $111111)
    DrawText(452, 402, "solve", $FFFFFF)
    StopDrawing()
    \ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
    SetMaterialColor(\ma, #PB_Material_SelfIlluminationColor, $7394FB)
    \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0, -0.025)
  EndWith
  With ob\Secs
    \ms = CreateCube(#PB_Any, 0.1)
    CompilerIf #PB_Compiler_Version >= 550
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024, "Silver1")
    CompilerElse
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024)
    CompilerEndIf
    StartDrawing(TextureOutput(ob\Secs\tx[0]))
    DrawImage(ImageID(m\silver), 0, 0, OutputWidth(), OutputHeight())
    StopDrawing()
    \ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
    SetMaterialColor(\ma, #PB_Material_SelfIlluminationColor, $EEEEEE)
    ScaleMaterial(\ma, 0.3, 30)
    \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0.4, 0.01)
    ScaleEntity(\id, 0.1, 9.2, 0.1)
  EndWith
 
  With ob\Minut
    \ms = CreateCube(#PB_Any, 0.1)
    CompilerIf #PB_Compiler_Version >= 550
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024, "Silver2")
    CompilerElse
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024)
    CompilerEndIf
    StartDrawing(TextureOutput(ob\Minut\tx[0]))
    DrawImage(ImageID(m\silver), 0, 0, OutputWidth(), OutputHeight())
    StopDrawing()
    \ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
    SetMaterialColor(\ma, #PB_Material_SelfIlluminationColor, $EEEEEE)
    \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0.35, 0.01)
    ScaleEntity(\id, 0.16, 8.1, 0.1)
  EndWith
  With ob\Hours
    \ms = CreateCube(#PB_Any, 0.1)
    CompilerIf #PB_Compiler_Version >= 550
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024, "Silver3")
    CompilerElse
      \tx[0] = CreateTexture(#PB_Any, 1024, 1024)
    CompilerEndIf
    StartDrawing(TextureOutput(ob\Hours\tx[0]))
    DrawImage(ImageID(m\silver), 0, 0, OutputWidth(), OutputHeight())
    StopDrawing()
    \ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
    SetMaterialColor(\ma, #PB_Material_SelfIlluminationColor, $EEEEEE)
    \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0.2, 0.01)
    ScaleEntity(\id, 0.25, 6.1, 0.1)
  EndWith
  With ob\dots[0]
    \ms = CreateCube(#PB_Any, 0.03)
    \ma = CopyMaterial(ob\outer\ma, #PB_Any)
    ScaleMaterial(\ma, 0.02, 0.05)
    \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0.9, 0)
    ScaleEntity(\id, 1, 3, 1)
  EndWith
  With ob\dots[1]
    \ms = CreateCube(#PB_Any, 0.03)
    \ma = CopyMaterial(ob\outer\ma, #PB_Any)
    ScaleMaterial(\ma, 0.02, 0.05)
    \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0.9, 0, 0)
    ScaleEntity(\id, 3, 1, 1)
  EndWith
  With ob\dots[2]
    \ms = CreateCube(#PB_Any, 0.03)
    \ma = CopyMaterial(ob\outer\ma, #PB_Any)
    ScaleMaterial(\ma, 0.02, 0.05)
    \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, -0.9, 0)
    ScaleEntity(\id, 1, 3, 1)
  EndWith
  With ob\dots[3]
    \ms = CreateCube(#PB_Any, 0.03)
    \ma = CopyMaterial(ob\outer\ma, #PB_Any)
    ScaleMaterial(\ma, 0.02, 0.05)
    \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), -0.9, 0, 0)
    ScaleEntity(\id, 3, 1, 1)
  EndWith
  ob\nod[0] = CreateNode(#PB_Any, 0, 0, 0)
  ob\nod[1] = CreateNode(#PB_Any, 0, 0, 0)
  ob\nod[2] = CreateNode(#PB_Any, 0, 0, 0)
  ob\nod[3] = CreateNode(#PB_Any, 0, 0, 0)
  AttachNodeObject(ob\nod[0], EntityID(ob\Inner\id))
  AttachNodeObject(ob\nod[0], EntityID(ob\outer\id))
  AttachNodeObject(ob\nod[0], EntityID(ob\Back\id))
  AttachNodeObject(ob\nod[0], EntityID(ob\Glass\id))
  AttachNodeObject(ob\nod[0], EntityID(ob\Knob\id))
  AttachNodeObject(ob\nod[1], EntityID(ob\Secs\id))
  AttachNodeObject(ob\nod[2], EntityID(ob\Minut\id))
  AttachNodeObject(ob\nod[3], EntityID(ob\Hours\id))
  ProcedureReturn #True
EndProcedure


Procedure.i GetData()
  Protected Res.i = 0
  res = ReceiveHTTPFile("https://pixabay.com/static/uploads/photo/2016/09/12/15/13/astronaut-1664814_960_720.jpg", path + "astro.jpg")
  If res > 0
    m\astro = LoadImage(#PB_Any, Path + "astro.jpg")
  Else
    m\astro = CreateImage(#PB_Any, 256, 256, 32)
    StartDrawing(ImageOutput(m\astro))
    FrontColor($FFFFFF) : BackColor($535454)
    CircularGradient(128, 128, 120)
    Circle(128, 128, 110)
    StopDrawing()
  EndIf
  res = ReceiveHTTPFile("http://forum.celestialmatters.org/userpix/4_moon_global_1k_1.jpg", path + "moon.jpg")
  If res > 0
    m\moon = LoadImage(#PB_Any, Path + "moon.jpg")
  Else
    m\moon = CreateImage(#PB_Any, 256, 256, 32)
    StartDrawing(ImageOutput(m\moon))
    Box(0, 0, 256, 256, $C0C0C0)
    StopDrawing()
  EndIf
  res = ReceiveHTTPFile("http://pre00.deviantart.net/45b3/th/pre/f/2007/224/7/6/texture_71___gold_by_wanderingsoul_stox.jpg", path + "gold.jpg")
  If res > 0
    m\gold = LoadImage(#PB_Any, Path + "gold.jpg")
  Else
    m\gold = CreateImage(#PB_Any, 256, 256, 32)
    StartDrawing(ImageOutput(m\gold))
    DrawingMode(#PB_2DDrawing_Gradient)
    FrontColor($1FDAFF) : BackColor($2099B1)
    LinearGradient(128, 0, 128, 256)
    Box(0, 0, 256, 256)
    StopDrawing()
  EndIf
  res = ReceiveHTTPFile("https://images.freecreatives.com/wp-content/uploads/2016/01/Free-Silver-Metal-Texture1.jpg", path + "silver.jpg")
  If Res > 0
    m\silver = LoadImage(#PB_Any, Path + "silver.jpg")
  Else
    m\silver = CreateImage(#PB_Any, 256, 256, 32)
    StartDrawing(ImageOutput(m\silver))
    DrawingMode(#PB_2DDrawing_Gradient)
    FrontColor($FFFFFF) : BackColor($ADADAD)
    LinearGradient(128, 0, 128, 256)
    Box(0, 0, 256, 256)
    StopDrawing()
  EndIf
  CompilerIf #PB_Compiler_Version >= 550
  res = ReceiveHTTPFile("http://dl.dafont.com/dl/?f=blackknightflf", path + "bknight.zip")
  If res > 0
    pck = OpenPack(#PB_Any, path + "bknight.zip")
    If pck > 0
      UncompressPackFile(pck, path + "BlackKnightFLF.ttf", "BlackKnightFLF.ttf")
      RegisterFontFile(path + "BlackKnightFLF.ttf")
      m\fn = LoadFont(#PB_Any, "BlackKnightFLF", 36)
      ClosePack(pck)
    EndIf
  EndIf
  CompilerElse
      m\fn = LoadFont(#PB_Any, "Arial", 24)
  CompilerEndIf
 
  res = ReceiveHTTPFile("https://www.digitalanarchy.com/knollSPK/pix/knoll-starburst-200.jpg", path + "star.jpg")
  If res > 0
    pa\tx = LoadTexture(#PB_Any, "star.jpg")
    pa\ma = CreateMaterial(#PB_Any, TextureID(pa\tx))
    MaterialBlendingMode(pa\ma, #PB_Material_Add)
    pa\id = CreateParticleEmitter(#PB_Any, 500, 0.2, 0.3, #PB_Particle_Box, 0, 0, 0)
    ParticleMaterial(pa\id, MaterialID(pa\ma))
    ParticleEmissionRate(pa\id, 10000)
    ParticleEmitterDirection(pa\id, 0, 0, 1)
    ParticleSize(pa\id, 5, 5)
    ParticleTimeToLive(pa\id, 1, 2)
    CompilerIf #PB_Compiler_Version >= 550
      ParticleVelocity(pa\id, #PB_Particle_MinimumVelocity, 4)
      ParticleVelocity(pa\id, #PB_Particle_Velocity, 10)
      ParticleVelocity(pa\id, #PB_Particle_MaximumVelocity, 20)
    CompilerElse
      ParticleVelocity(pa\id, 4, 20)
    CompilerEndIf
    pa\no = CreateNode(#PB_Any, 0, 0, -100)
    AttachNodeObject(pa\no, ParticleEmitterID(pa\id))
  EndIf
  ProcedureReturn #True
EndProcedure

  Macro LinearlySpacedValue(IncrementID, IncrementMax, MinValue, MaxValue)
    ((MinValue) + ((MaxValue) - (MinValue)) * ((IncrementID) / (IncrementMax)))
  EndMacro
  Macro CalculateTorusVertex(MinorRadius, MajorRadius, Uxx, Vxx)
    MeshVertexPosition((MajorRadius + MinorRadius * Cos(Vxx)) * Cos(Uxx), (MajorRadius + MinorRadius * Cos(Vxx)) * Sin(Uxx), MinorRadius * Sin(Vxx))
    MeshVertexNormal(0, 1, 0)
    MeshVertexTextureCoordinate(Uxx / (2*#PI), Vxx / (2*#PI))
  EndMacro 

  Procedure.i CreateToruss(MinorRadius.f, MajorRadius.f, Meridian = 32, Parallel = 32)
   
    Protected Handle, P00, P01, P02, P03, MeridianID, U00.d, U01.d, ParallelID, V00.d, V01.d
   
    Handle = CreateMesh(#PB_Any)
   
    If Meridian < 3
      Meridian = 3
    EndIf
   
    If Parallel < 3
      Parallel = 3
    EndIf
   
    P00 = 0
    P01 = P00 + 1
    P02 = P01 + 1
    P03 = P02 + 1
   
    For MeridianID = 0 To Meridian - 1
     
      U00 = LinearlySpacedValue(MeridianID, Meridian, 0.0, 2.0 * #PI)
      U01 = LinearlySpacedValue(MeridianID + 1, Meridian, 0.0, 2.0 * #PI)
     
      For ParallelID = 0 To Parallel - 1
       
        V00 = LinearlySpacedValue(ParallelID, Parallel, 0.0, 2.0 * #PI)
        V01 = LinearlySpacedValue(ParallelID + 1, Parallel, 0.0, 2.0 * #PI)
       
        CalculateTorusVertex(MinorRadius, MajorRadius, U00, V00) ; P00
        CalculateTorusVertex(MinorRadius, MajorRadius, U01, V00) ; P01
        CalculateTorusVertex(MinorRadius, MajorRadius, U01, V01) ; P02
        CalculateTorusVertex(MinorRadius, MajorRadius, U00, V01) ; P03
       
        MeshFace(P00, P01, P02)
        MeshFace(P02, P03, P00)
       
        P00 = P03 + 1
        P01 = P00 + 1
        P02 = P01 + 1
        P03 = P02 + 1
       
      Next
     
    Next
   
    FinishMesh(#True)
    NormalizeMesh(Handle)
    BuildMeshTangents(Handle)
    ProcedureReturn Handle
  EndProcedure
Bye.
Last edited by DK_PETER on Thu Sep 22, 2016 10:06 am, edited 7 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.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: The watch

Post by davido »

@DK_PETER,
Very nice, thank you for sharing.

Edit: 20160921 0906 BST

Tested both on Windows 10 and MacBook Pro OS X. PureBasic 5.50 x64.
Works perfectly.
Last edited by davido on Wed Sep 21, 2016 9:08 am, edited 2 times in total.
DE AA EB
Joris
Addict
Addict
Posts: 890
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: The watch

Post by Joris »

I get this error :
[09:55:43] Waiting for executable to start...
[09:55:43] Executable type: Windows - x86 (32bit, Unicode)
[09:55:43] Executable started.
[09:55:53] [ERROR] Line: 127
[09:55:53] [ERROR] The specified #Node is not initialised.
[09:55:58] The Program was killed.
PB 5.50
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5524
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: The watch

Post by Kwai chang caine »

Can't test this great code, i'm behind a proxy :cry:
Thanks when even for sharing 8)
ImageThe happiness is a road...
Not a destination
infratec
Always Here
Always Here
Posts: 7699
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: The watch

Post by infratec »

Hi,

for some testing I'm back on 5.43.
You need:

Code: Select all

CompilerIf #PB_Compiler_Version >= 550
instead of your

Code: Select all

if ver ...
else you get compiler errors.

And in <550 CreateTorus() is not available.

But there are so many things which are not available in <550...
I gave up.

Bernd
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: The watch

Post by DK_PETER »

infratec wrote:Hi,

for some testing I'm back on 5.43.
You need:

Code: Select all

CompilerIf #PB_Compiler_Version >= 550
instead of your

Code: Select all

if ver ...
else you get compiler errors.

And in <550 CreateTorus() is not available.

But there are so many things which are not available in <550...
I gave up.

Bernd
You're right...ver doesn't do it. Added compilerif(s).

A createTorus example exists in code:
http://www.purebasic.fr/english/viewtop ... reatetorus
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.
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: The watch

Post by applePi »

thanks DK_PETER for the good example , i like the particles flare which resembles the solar flare , the idea of loading files from the web is interesting , in fact this is the first time i know we can change the downloaded file name immediately. purebasic is very big software even it is 30 MB in download size.
here is my notes
in windows xp/32 I'm able to run the code in PB 5.50 if loading the images and files from the current folder not from the web, i have replaced res = ReceiveHTTP... with res = 1;ReceiveHTTP . and changed Add3DArchive(path, #PB_3DArchive_FileSystem) to Add3DArchive(".", #PB_3DArchive_FileSystem)
then removing all occurrences of path +
then downloading the files from links, renaming it and copying it to the current code folder. and then it works . don't know why it does not work otherwise (in winxp); i get error the specified #Node is not initialized :line 127 RotateNode(pa\no, 1, 1, 1, #PB_Relative)
all the files was downloaded to C:\Documents and Settings\Coffee\Local Settings\Temp\ except silver.jpg

2- in windows 7/64 (the same computer) it works without these troubles.
3- in all cases there is a strange lines in Ogre.txt:

Code: Select all

Can't assign material Sphere to SubEntity of E45621768 because this Material does not exist. Have you forgotten to define it in a .material script?
15:13:48: Can't assign material Torus to SubEntity of E45621984 because this Material does not exist. Have you forgotten to define it in a .material script?
and other several lines with same syntax
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: The watch

Post by DK_PETER »

applePi wrote:thanks DK_PETER for the good example , i like the particles flare which resembles the solar flare , the idea of loading files from the web is interesting , in fact this is the first time i know we can change the downloaded file name immediately. purebasic is very big software even it is 30 MB in download size.
here is my notes
in windows xp/32 I'm able to run the code in PB 5.50 if loading the images and files from the current folder not from the web, i have replaced res = ReceiveHTTP... with res = 1;ReceiveHTTP . and changed Add3DArchive(path, #PB_3DArchive_FileSystem) to Add3DArchive(".", #PB_3DArchive_FileSystem)
then removing all occurrences of path +
then downloading the files from links, renaming it and copying it to the current code folder. and then it works . don't know why it does not work otherwise (in winxp); i get error the specified #Node is not initialized :line 127 RotateNode(pa\no, 1, 1, 1, #PB_Relative)
all the files was downloaded to C:\Documents and Settings\Coffee\Local Settings\Temp\ except silver.jpg

2- in windows 7/64 (the same computer) it works without these troubles.
3- in all cases there is a strange lines in Ogre.txt:

Code: Select all

Can't assign material Sphere to SubEntity of E45621768 because this Material does not exist. Have you forgotten to define it in a .material script?
15:13:48: Can't assign material Torus to SubEntity of E45621984 because this Material does not exist. Have you forgotten to define it in a .material script?
and other several lines with same syntax
@applePi
Thanks for the info.
The 'material does not exist' is a simple path problem. Fixed in the above example.
Works for me in windows 7, 8.1, 10 without errors.
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
falsam
Enthusiast
Enthusiast
Posts: 635
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: The watch

Post by falsam »

Very nice DK_PETER. Thank you for sharing.

➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect 🤪
Post Reply