New asteroids and scaling.

This commit is contained in:
Quantum 2013-11-14 12:39:55 -05:00
parent 6fa6bf0429
commit df3126e232
5 changed files with 125 additions and 20 deletions

View file

@ -1,11 +1,11 @@
# Blender MTL File: 'mainbeltastroid.blend' # Blender MTL File: 'None'
# Material Count: 1 # Material Count: 1
newmtl Material newmtl Material
Ns 96.078431 Ns 92.156863
Ka 0.000000 0.000000 0.000000 Ka 0.000000 0.000000 0.000000
Kd 0.254837 0.254837 0.254837 Kd 0.389517 0.389517 0.389517
Ks 0.159273 0.159273 0.159273 Ks 0.303197 0.303197 0.303197
Ni 1.000000 Ni 1.000000
d 1.000000 d 1.000000
illum 2 illum 2

View file

@ -0,0 +1,103 @@
# Blender v2.66 (sub 1) OBJ File: ''
# www.blender.org
mtllib mainbelt.mtl
g Cube.002
v -0.289079 -0.829861 0.215310
v 0.057641 -0.817976 -0.343786
v 0.543391 -0.663372 0.025647
v -0.097897 -0.384127 -0.766643
v 0.545964 -0.487153 -0.565775
v 0.504985 -0.681732 0.425810
v 0.124050 -0.113115 0.938530
v -0.706349 -0.467985 0.350889
v -0.654122 -0.523922 -0.388949
v 0.176965 0.828195 -0.359842
v -0.383487 0.292923 -0.693979
v -0.738214 0.373419 -0.411660
v -0.714335 0.466863 0.124949
v -0.398389 0.720367 0.469422
v 0.451232 0.721178 0.355306
v 0.882521 0.137464 -0.019655
v 0.520709 0.162782 -0.672326
v 0.692252 0.151771 0.606789
v 0.088118 0.461316 0.717918
v -0.701579 0.121702 0.577301
v 0.132479 0.283880 -0.909159
vn 0.220116 -0.968562 0.115914
vn 0.121188 -0.670211 -0.732209
vn 0.190171 -0.981386 -0.026776
vn -0.062026 -0.690971 0.720217
vn -0.653070 -0.757215 0.011149
vn -0.323725 0.721233 -0.612393
vn -0.462979 0.861322 -0.209224
vn 0.018021 0.989816 0.141208
vn 0.872936 -0.045704 -0.485690
vn 0.912617 -0.392863 -0.113086
vn 0.731293 0.657305 -0.182098
vn 0.733716 0.559838 -0.385022
vn 0.919930 -0.268686 0.285545
vn 0.580622 -0.295204 0.758771
vn 0.400075 0.506643 0.763710
vn -0.295046 0.312154 0.903055
vn -0.794843 0.471399 0.382109
vn -0.998990 0.017376 0.041429
vn -0.999351 -0.005584 0.035599
vn -0.993512 -0.094698 -0.062975
vn -0.266191 0.695397 -0.667507
vn 0.273402 -0.145262 -0.950868
vn -0.385081 -0.063621 -0.920687
vn 0.461921 -0.850540 -0.251416
vn -0.256648 -0.720214 -0.644534
vn -0.357494 -0.902317 -0.240879
vn 0.550017 0.570541 -0.609888
vn -0.434722 0.890284 -0.135687
vn 0.084553 0.767893 0.634973
vn 0.848402 0.468199 0.246991
vn 0.919967 -0.385585 0.070604
vn 0.342132 0.355460 0.869824
vn -0.299721 0.325644 0.896730
vn -0.275650 -0.599397 0.751492
vn -0.454304 -0.316110 0.832876
vn -0.547764 -0.072427 -0.833492
vn 0.416633 -0.324827 -0.849061
vn -0.637398 -0.188684 -0.747076
usemtl Material
s off
f 1//1 2//1 3//1
f 4//2 5//2 2//2
f 6//3 1//3 3//3
f 7//4 1//4 6//4
f 1//5 8//5 9//5
f 10//6 11//6 12//6
f 10//7 13//7 14//7
f 10//8 14//8 15//8
f 16//9 5//9 17//9
f 3//10 5//10 16//10
f 16//11 10//11 15//11
f 16//12 17//12 10//12
f 16//13 18//13 6//13
f 7//14 6//14 18//14
f 19//15 18//15 15//15
f 19//16 14//16 20//16
f 20//17 14//17 13//17
f 20//18 13//18 12//18
f 20//19 12//19 8//19
f 12//20 9//20 8//20
f 11//21 10//21 21//21
f 17//22 5//22 4//22
f 21//23 4//23 11//23
f 3//24 2//24 5//24
f 2//25 9//25 4//25
f 2//26 1//26 9//26
f 21//27 10//27 17//27
f 13//28 10//28 12//28
f 15//29 14//29 19//29
f 18//30 16//30 15//30
f 3//31 16//31 6//31
f 7//32 18//32 19//32
f 20//33 7//33 19//33
f 1//34 7//34 8//34
f 7//35 20//35 8//35
f 9//36 12//36 4//36
f 4//37 21//37 17//37
f 11//38 4//38 12//38

View file

@ -1,6 +1,6 @@
from math import * from math import *
from pyglet.gl import * from pyglet.gl import *
from random import random, uniform from random import random, uniform, gauss, choice
TWOPI = pi * 2 TWOPI = pi * 2
@ -163,19 +163,16 @@ def colourball(r, lats, longs, colour, fv4=GLfloat * 4):
def belt(radius, cross, object, count): def belt(radius, cross, object, count):
for i in xrange(count): for i in xrange(count):
theta = TWOPI * random() theta = TWOPI * random()
x, y, z = cos(theta) * radius, 0, sin(theta) * radius r = gauss(radius, cross)
# Pretend to move horizontally around the x-axis by delta x, y, z = cos(theta) * r, gauss(0, cross), sin(theta) * r
# then I multiply it by a rotation matrix about angle theta
# the z-axis need not to be multiplied by the matrix, as it's 0
# Do note the rotation is counter clockwise
delta = cross * uniform(-1, 1)
x += cos(theta) * delta
z += sin(theta) * delta
y += cross * uniform(-1, 1)
glPushMatrix() glPushMatrix()
glTranslatef(x, y, z) glTranslatef(x, y, z)
glCallList(object) scale = gauss(1, 0.5)
if scale < 0:
scale = 1
glScalef(scale, scale, scale)
glCallList(choice(object))
glPopMatrix() glPopMatrix()

View file

@ -288,11 +288,11 @@
}, },
"belts": { "belts": {
"main": { "main": {
"model": "asteroids/mainbelt.obj", "model": ["asteroids/mainbelt.obj", "asteroids/mainbelt2.obj"],
"radius": "2.362 * AU", "radius": "2.362 * AU",
"cross": 1000, "cross": 1000,
"scale": 30, "scale": 30,
"count": 1024, "count": 2048,
"rotation": 114536500 "rotation": 114536500
} }
}, },

View file

@ -201,10 +201,15 @@ def load_world(file):
rotation = info.get('period', 31536000) rotation = info.get('period', 31536000)
theta = 360 / (rotation + .0) if rotation else 0 theta = 360 / (rotation + .0) if rotation else 0
object_id = model_list(load_model(info['model']), info.get('sx', scale), info.get('sy', scale), models = info['model']
info.get('sz', scale), (0, 0, 0)) if not isinstance(models, list):
models = [models]
objects = []
for model in models:
objects.append(model_list(load_model(model), info.get('sx', scale), info.get('sy', scale),
info.get('sz', scale), (0, 0, 0)))
world.tracker.append(Belt(compile(belt, radius, cross, object_id, count), world.tracker.append(Belt(compile(belt, radius, cross, objects, count),
(x, y, z), (inclination, longitude, argument), (x, y, z), (inclination, longitude, argument),
rotation_angle=theta, world=world)) rotation_angle=theta, world=world))