very good !! can you tell me ? how you made

this galaxy…

Thanks

Hi mate.

```
I modified a script I found on the web for generating a galaxy. What it does is spit out a bunch of vertices, distributed to form a rough 3D galaxy. I then textured the resulting mesh using a halo material. To get something that has more colour and depth I generated a few more galaxy meshs and gave them a halo material with different colours. I also offset them slightly by rotating them about the origin.
Anyway just:
1. paste the below into a text file and save it as galaxy_gen.py or similar extension,
2. Go to blender, open the text editor in a blender window, and then open the galaxy_gen.py file
3. Click in the text editor window, then press alt+p to generate a galaxy mesh.
4. Add a default halo material to the galaxy mesh.
Tweak the settings in the script to get different types of galaxies. Also, look into using the new volumetric rendering engine, it may be applicable to what you want to achieve.
#!/usr/bin/python
#
# This script generates a 3D galaxy from a number of parameters and stores
# it in an array. You can modify this script to store the data in a database
# or whatever your purpose is.
#
# The algorithm used to generate the galaxy is borrowed from Ben Motz
# <[email protected]>. The original C source code for DOS (including a 3D
# viewer) can be downloaded here:
#
# http://bits.bristol.ac.uk/motz/tep/galaxy.html
#
# Generation parameters:
# Number of stars in the core (Example: 2000)
NUMHUB = 10000
# Number of stars in the disk (Example: 4000)
NUMDISK = 20000
# Radius of the disk (Example: 90.0)
DISKRAD = 20.0
# Radius of the hub (Example: 45.0)
HUBRAD = 11.0
# Number of arms (Example: 3)
NUMARMS = 3
# Tightness of winding (Example: 0.5)
ARMROTS = 1.5
# Arm width in degrees (Not affected by number of arms or rotations)
# Exammple: 65.0
ARMWIDTH = 30
# Maximum depth of arms (Example: 2.0)
MAXDISKZ = 2.5
# Maximum depth of core (Example: 16.0)
MAXHUBZ = 4.5
# Maximum outlier distance from arms (Example: 25.0)
FUZZ = 15
# ---------------------------------------------------------------------------
from Blender import *
import random
import math
import sys
mesh = NMesh.New()
def generateStars():
# omega is the separation (in degrees) between each arm
# Prevent div by zero error:
if NUMARMS:
omega = 360.0 / NUMARMS
else:
omega = 0.0
i = 0
while i < NUMDISK:
# Choose a random distance from center
dist = HUBRAD + random.random() * DISKRAD
# This is the 'clever' bit, that puts a star at a given distance
# into an arm: First, it wraps the star round by the number of
# rotations specified. By multiplying the distance by the number of
# rotations the rotation is proportional to the distance from the
# center, to give curvature
theta = ( ( 360.0 * ARMROTS * ( dist / DISKRAD ) )
# Then move the point further around by a random factor up to
# ARMWIDTH
+ random.random() * ARMWIDTH
# Then multiply the angle by a factor of omega, putting the
# point into one of the arms
#+ (omega * random.random() * NUMARMS )
+ omega * random.randrange( 0, NUMARMS )
# Then add a further random factor, 'fuzzin' the edge of the arms
+ random.random() * FUZZ * 2.0 - FUZZ
#+ random.randrange( -FUZZ, FUZZ )
)
# Convert to cartesian
x = math.cos( theta * math.pi / 180.0 ) * dist
y = math.sin( theta * math.pi / 180.0 ) * dist
z = random.random() * MAXDISKZ * 2.0 - MAXDISKZ
# z = z * (MAXDISKEDGEZ + DISKRAD - math.sqrt(x * x + y * y) )
z = z * (DISKRAD + HUBRAD - dist)/(DISKRAD + HUBRAD)
# Add star to the stars array
newVert = NMesh.Vert(x,y,z)
mesh.verts.append(newVert)
# Process next star
i = i + 1
# Now generate the Hub. This places a point on or under the curve
# maxHubZ - s d^2 where s is a scale factor calculated so that z = 0 is
# at maxHubR (s = maxHubZ / maxHubR^2) AND so that minimum hub Z is at
# maximum disk Z. (Avoids edge of hub being below edge of disk)
scale = MAXHUBZ / ( HUBRAD * HUBRAD )
i = 0
while i < NUMHUB:
# Choose a random distance from center
dist = random.random() * HUBRAD
# Any rotation (points are not on arms)
theta = random.random() * 360
# Convert to cartesian
x = math.cos( theta * math.pi / 180.0) * dist
y = math.sin( theta * math.pi / 180.0) * dist
z = ( random.random() * 2 - 1 ) * ( MAXHUBZ - scale * dist * dist )
# Add star to the stars array
newVert = NMesh.Vert(x,y,z)
mesh.verts.append(newVert)
# Process next star
i = i + 1
# Generate the galaxy
generateStars()
NMesh.PutRaw(mesh)
Redraw()
```