Galaxy Shape from points collection

Everything related to 3D programming
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: Galaxy Shape from points collection

Post by Olliv »

Hello... Excuse me to be a little bit weight but, normally, it seems that we can exchange code simply. Imagine, I make a code of galaxy.

I prefer "follow" to keep a team spirit, and a functionnal coherence.

1st stop, my browser : Do want to use this as browser by default ?!?
No... I just want to upload a code.

2nd stop, my search engine : Your search engine uses cookie etc...
No. I just want to upload my f.. !

3th stop, the forum : Do you know tapatalk ? Do you want to...
NO. I just want to...

4th stop, the forum : Ad... LA MARINE NATIONALE RECRUTE.
Noo! I just want share my w... ! Sh...

Okay now, I reach the dialog I do not describe to you, such it is shame or ergonomy...

We are in 2020, and the law of Moore I do not see the progress
of the net...

I just wanted to say you this little message, dear contributors above : none of your links are available, no image, nothing...

Sure I am able to communicate with you privately, or not. Sure my work below is not the best code of the century. Sure it is not the first equation I discover before the best mathematician. But just it represents MY pleasure I want to share with you : simple !!!

1) you copy the code from here and paste it on your IDE
2) you paste it, execute it, and it is okaaaay !

Just a fly in the dark of the space.
I drew 2 galaxies. And KCC asked me if the speed should be rightly accelerated. So I multiplied by 100 the initial.

Now all the physicians on the world want to kill me because the speed is wildly over the light speed, but... It was his wish to KCC...

You fly in the only with the mouse.

Left, right, front and back mouse direction to rotate.( z and x axis)
Left and right click to rotate (y axis)
Wheel up and down to speed.


Have a good fly !!
Thank you !

Code: Select all

;***************************************************************************************************************************************************************************************************************************************************
Global.D cg, ZZ = 1000.0, PowMount = 80.0, Radius, Teta, Anti, Teta2, Rho2, axCam, ayCam, azCam, vxCam, vyCam, vzCam
Global BackGC = 31
InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops()
OpenScreen(DesktopWidth(0), DesktopHeight(0), 32, "", #PB_Screen_SmartSynchronization, DesktopFrequency(0) )
CreateTexture(1, 1, 1, "")
If StartDrawing(TextureOutput(1) ) 
       Box(0, 0, 1, 1, RGB(255, 255, 255) )
       StopDrawing()
EndIf
CreateMaterial(0, TextureID(1) )
DisableMaterialLighting(0, #True)
For J = 1 To 2
       CreateMesh(J, #PB_Mesh_PointList, #PB_Mesh_Dynamic)
       SetMeshMaterial(J, MaterialID(0))              
       For i = 1 To 3 * (300000 - ((J - 1) * 295000) )
              Radius = 1.0 + Random(Random(10000) ) / 100.0
              Teta = Random(1) * #PI
              Teta2.D = Random(628) / 100.0
              Rho2.D = Random(1500) / 100.0
              MeshVertexPosition((Cos(Radius / 8.0 + Teta) * Radius + (Cos(Teta2) * Rho2))*ZZ, (Random(8000.0 / Sqr(Sqr(Radius) ) ) / 1000.0 * ((Random(1) * 2.0) - 1.0))*ZZ, (Sin(Radius / 8.0 + Teta) * Radius + (Sin(Teta2) * Rho2)) *ZZ)
              cg = BackGC + Pow(Random(100)/100, PowMount)*(255 - BackGC)
              MeshVertexColor(RGBA(cg,cg, cg, cg))
       Next i 
       FinishMesh(#False)
       CreateNode(J)
       AttachNodeObject(J, MeshID(J))
Next       
MoveNode(2, 100000, 1000000, 0, #PB_Absolute)
RotateNode(2, 0, 30, 0)
CreateCamera(0, 0, 0, 100, 100)
cams = CreateNode(#PB_Any)
AttachNodeObject(cams, CameraID(0))
CameraRange(0, 1, 1000000000)
MoveNode(cams, 0, 40, 150, #PB_Absolute)
CameraFOV(0, 90)
NodeLookAt(cams, NodeX(1),  NodeY(1),  NodeZ(1))
MoveNode(cams, 0.0, 0.0, -100)
Repeat
       ExamineKeyboard()
       ExamineMouse()
       vyCam + 0.01 * (Bool(MouseButton(1) ) - Bool(MouseButton(2) ) )
       vyCam * 0.99
       RotateNode(cams, 0.0, vyCam, 0.0, #PB_Relative)
       NodeFixedYawAxis(cams, #False)
       axCam = MouseDeltaY() / 100.0
       vxCam + axCam
       vxCam * 0.9
       RotateNode(cams, vxCam, 0.0,  0.0, #PB_Relative)                                     
       NodeFixedYawAxis(cams, #False)
       azCam = - MouseDeltaX() / 100.0
       vzCam + azCam
       vzCam * 0.9
       RotateNode(cams, 0.0,  0.0, vzCam, #PB_Relative)
       NodeFixedYawAxis(cams, #False)
       camz.D - MouseWheel() * 10.0
       MoveNode(cams, 0.0, 0.0, camz, #PB_Absolute | #PB_Local)                     
       RenderWorld()
       FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1 Or MouseButton(3)
and where is f... button to submit : it is behind the dialog box!!! (I must turn the smartphone to get it... Unable to use clipboard... 6 gigabytes of updating datas 2020... 2020 progress...)
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Galaxy Shape from points collection

Post by DK_PETER »

Nice example Olliv..
It is easy to substitute the images used. look at the materials and
create/download images to your liking with the same filenames.
Anyway: here's my galaxy with all images..
https://www.dropbox.com/s/hy7myie3x3f2c ... Y.rar?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.
User avatar
pf shadoko
Enthusiast
Enthusiast
Posts: 385
Joined: Thu Jul 09, 2015 9:07 am

Re: Galaxy Shape from points collection

Post by pf shadoko »

very impressive

I've made some modifications

PS: I didn't know that you could display a mesh without an entity.

Code: Select all

Global.D cg, ZZ = 1000.0, PowMount = 80.0, Radius, Teta, Anti, Teta2, Rho2
Global.d starnb,px,py,pz,dist,vit
Global BackGC = 31
InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops()
OpenScreen(DesktopWidth(0), DesktopHeight(0), 32, "", #PB_Screen_SmartSynchronization, DesktopFrequency(0) )
CreateTexture(1, 1, 1, "")
If StartDrawing(TextureOutput(1) )
    Box(0, 0, 1, 1, RGB(255, 255, 255) )
    StopDrawing()
EndIf
CreateMaterial(0, TextureID(1) )
DisableMaterialLighting(0, #True)
RandomSeed(0)
For J = 1 To 100
    If j>1
    px=Random(2000000)-1000000
    py=Random(2000000)-1000000
    pz=Random(2000000)-1000000
    dist=Sqr(px*px+py*py+pz*pz)
    EndIf
    CreateMesh(J, #PB_Mesh_PointList)
    SetMeshMaterial(J, MaterialID(0))  
    starnb=2000000000/(1000+dist)
    For i = 1 To starnb
        Radius = 1.0 + Random(10000) / 100.0
        Teta = Random(1) * #PI
        Teta2.D = Random(628) / 100.0
        Rho2.D = Random(1500) / 100.0
        MeshVertexPosition((Cos(Radius / 8.0 + Teta) * Radius + (Cos(Teta2) * Rho2))*ZZ, (Random(8000.0 / Sqr(Sqr(Radius) ) ) / 1000.0 * ((Random(1) * 2.0) - 1.0))*ZZ, (Sin(Radius / 8.0 + Teta) * Radius + (Sin(Teta2) * Rho2)) *ZZ)
        cg = BackGC + Pow(Random(100)/100, PowMount)*(255 - BackGC)
        MeshVertexColor(RGBA(cg,cg, cg, cg))
    Next i
    FinishMesh(1)
    CreateEntity(j,MeshID(j),#PB_Material_None)
    MoveEntity(j, px, py, pz, #PB_Absolute)
    RotateEntity(j, Random(360), Random(360), Random(360))
Next       
CreateCamera(0, 0, 0, 100, 100)
CameraRange(0, 1, 1000000000)
CameraFOV(0, 90)
CreateNode(0)
AttachNodeObject(0,CameraID(0))
vit=100
Repeat
    ExamineKeyboard()
    ExamineMouse()
    RotateNode(0,MouseDeltaY()*0.1,  0.5 * (Bool(MouseButton(2) ) - Bool(MouseButton(1) )), -MouseDeltaX()*0.1,#PB_Relative)
    vit+MouseWheel()*10
    MoveNode(0,0,0,-vit,#PB_Local)
    RenderWorld()
    FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1 Or MouseButton(3)
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: Galaxy Shape from points collection

Post by Olliv »

@Shadoku

I got your version and will test it... Many difficulties to link on line codes and lockdown IDE...
Post Reply