mirror of
https://github.com/quantum5/punyverse.git
synced 2025-04-24 13:11:57 -04:00
Used mass to calculate orbital speed. Added phobos.
This commit is contained in:
parent
8236efcffc
commit
a034975928
|
@ -1,4 +1,4 @@
|
||||||
/* Generated by Cython 0.18 on Sat Oct 26 13:44:10 2013 */
|
/* Generated by Cython 0.18 on Sat Oct 26 16:08:45 2013 */
|
||||||
|
|
||||||
#define PY_SSIZE_T_CLEAN
|
#define PY_SSIZE_T_CLEAN
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
@ -9084,14 +9084,44 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
||||||
* point(f, model, tex_id, sx, sy, sz, 0)
|
* point(f, model, tex_id, sx, sy, sz, 0)
|
||||||
* glEnd() # <<<<<<<<<<<<<<
|
* glEnd() # <<<<<<<<<<<<<<
|
||||||
*
|
*
|
||||||
* glPopAttrib()
|
* if tex_id:
|
||||||
*/
|
*/
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
/* "punyverse\_model.pyx":341
|
||||||
|
* glEnd()
|
||||||
|
*
|
||||||
|
* if tex_id: # <<<<<<<<<<<<<<
|
||||||
|
* glBindTexture(GL_TEXTURE_2D, 0)
|
||||||
|
* glDisable(GL_TEXTURE_2D)
|
||||||
|
*/
|
||||||
|
if (__pyx_v_tex_id) {
|
||||||
|
|
||||||
|
/* "punyverse\_model.pyx":342
|
||||||
|
*
|
||||||
|
* if tex_id:
|
||||||
|
* glBindTexture(GL_TEXTURE_2D, 0) # <<<<<<<<<<<<<<
|
||||||
|
* glDisable(GL_TEXTURE_2D)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
glBindTexture(__pyx_e_9punyverse_6_model_GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
/* "punyverse\_model.pyx":343
|
||||||
|
* if tex_id:
|
||||||
|
* glBindTexture(GL_TEXTURE_2D, 0)
|
||||||
|
* glDisable(GL_TEXTURE_2D) # <<<<<<<<<<<<<<
|
||||||
|
*
|
||||||
|
* glPopAttrib()
|
||||||
|
*/
|
||||||
|
glDisable(__pyx_e_9punyverse_6_model_GL_TEXTURE_2D);
|
||||||
|
goto __pyx_L25;
|
||||||
|
}
|
||||||
|
__pyx_L25:;
|
||||||
}
|
}
|
||||||
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
|
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
|
||||||
|
|
||||||
/* "punyverse\_model.pyx":341
|
/* "punyverse\_model.pyx":345
|
||||||
* glEnd()
|
* glDisable(GL_TEXTURE_2D)
|
||||||
*
|
*
|
||||||
* glPopAttrib() # <<<<<<<<<<<<<<
|
* glPopAttrib() # <<<<<<<<<<<<<<
|
||||||
* glPopMatrix()
|
* glPopMatrix()
|
||||||
|
@ -9099,7 +9129,7 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
||||||
*/
|
*/
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
|
|
||||||
/* "punyverse\_model.pyx":342
|
/* "punyverse\_model.pyx":346
|
||||||
*
|
*
|
||||||
* glPopAttrib()
|
* glPopAttrib()
|
||||||
* glPopMatrix() # <<<<<<<<<<<<<<
|
* glPopMatrix() # <<<<<<<<<<<<<<
|
||||||
|
@ -9108,7 +9138,7 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
||||||
*/
|
*/
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
/* "punyverse\_model.pyx":344
|
/* "punyverse\_model.pyx":348
|
||||||
* glPopMatrix()
|
* glPopMatrix()
|
||||||
*
|
*
|
||||||
* glEndList() # <<<<<<<<<<<<<<
|
* glEndList() # <<<<<<<<<<<<<<
|
||||||
|
@ -9116,7 +9146,7 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
||||||
*/
|
*/
|
||||||
glEndList();
|
glEndList();
|
||||||
|
|
||||||
/* "punyverse\_model.pyx":345
|
/* "punyverse\_model.pyx":349
|
||||||
*
|
*
|
||||||
* glEndList()
|
* glEndList()
|
||||||
* return display # <<<<<<<<<<<<<<
|
* return display # <<<<<<<<<<<<<<
|
||||||
|
|
|
@ -338,6 +338,10 @@ cpdef int model_list(WavefrontObject model, float sx=1, float sy=1, float sz=1,
|
||||||
point(f, model, tex_id, sx, sy, sz, 0)
|
point(f, model, tex_id, sx, sy, sz, 0)
|
||||||
glEnd()
|
glEnd()
|
||||||
|
|
||||||
|
if tex_id:
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0)
|
||||||
|
glDisable(GL_TEXTURE_2D)
|
||||||
|
|
||||||
glPopAttrib()
|
glPopAttrib()
|
||||||
glPopMatrix()
|
glPopMatrix()
|
||||||
|
|
||||||
|
|
BIN
punyverse/assets/models/satellites/phobos.jpg
Normal file
BIN
punyverse/assets/models/satellites/phobos.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 100 KiB |
20
punyverse/assets/models/satellites/phobos.mtl
Normal file
20
punyverse/assets/models/satellites/phobos.mtl
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Ns = Phong specular component. Ranges from 0 to 1000. (I've seen various statements about this range (see below))
|
||||||
|
# Kd = Diffuse color weighted by the diffuse coefficient.
|
||||||
|
# Ka = Ambient color weighted by the ambient coefficient.
|
||||||
|
# Ks = Specular color weighted by the specular coefficient.
|
||||||
|
# d = Dissolve factor (pseudo-transparency). Values are from 0-1. 0 is completely transparent, 1 is opaque.
|
||||||
|
# Ni = Refraction index. Values range from 1 upwards. A value of 1 will cause no refraction. A higher value implies refraction.
|
||||||
|
# illum = (0, 1, or 2) 0 to disable lighting, 1 for ambient & diffuse only (specular color set to black), 2 for full lighting (see below)
|
||||||
|
# sharpness = ? (see below)
|
||||||
|
# c
|
||||||
|
# map_Bump = Bump texture map.
|
||||||
|
# map_d = Opacity texture map.
|
||||||
|
# refl = reflection type and filename (?)
|
||||||
|
|
||||||
|
newmtl white
|
||||||
|
Ka 1 1 1
|
||||||
|
Kd 1 1 1
|
||||||
|
Ks 0 0 0
|
||||||
|
map_Kd phobos.jpg
|
||||||
|
illum 2
|
||||||
|
Ns 8
|
|
@ -35,6 +35,7 @@ class Planet(Entity):
|
||||||
self.atmosphere = kwargs.pop('atmosphere', 0)
|
self.atmosphere = kwargs.pop('atmosphere', 0)
|
||||||
self.cloudmap = kwargs.pop('cloudmap', 0)
|
self.cloudmap = kwargs.pop('cloudmap', 0)
|
||||||
self.last_tick = 0
|
self.last_tick = 0
|
||||||
|
self.mass = kwargs.pop('mass', None)
|
||||||
super(Planet, self).__init__(*args, **kwargs)
|
super(Planet, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
{
|
{
|
||||||
|
"au": "greatly shrunk so planets can actually be seen",
|
||||||
"au": 10000,
|
"au": 10000,
|
||||||
|
"tick": 4320,
|
||||||
|
"length": "kilometre per world units for satellite distance, note that this is approx 10x smaller than AU",
|
||||||
|
"length": 637,
|
||||||
"planets": {
|
"planets": {
|
||||||
"earth": {
|
"earth": {
|
||||||
"texture": ["earth.jpg", "earth_medium.jpg", "earth_small.jpg", [0, 0.28, 1, 1]],
|
"texture": ["earth.jpg", "earth_medium.jpg", "earth_small.jpg", [0, 0.28, 1, 1]],
|
||||||
|
@ -8,6 +12,7 @@
|
||||||
"pitch": -90,
|
"pitch": -90,
|
||||||
"yaw": 23.4,
|
"yaw": 23.4,
|
||||||
"roll": -90,
|
"roll": -90,
|
||||||
|
"mass": 5.97219e+24,
|
||||||
"atmosphere": {
|
"atmosphere": {
|
||||||
"cloud_texture": "cloudmap.png",
|
"cloud_texture": "cloudmap.png",
|
||||||
"diffuse_texture": "atmosphere_earth.png",
|
"diffuse_texture": "atmosphere_earth.png",
|
||||||
|
@ -17,8 +22,7 @@
|
||||||
"moon": {
|
"moon": {
|
||||||
"texture": ["moon.jpg", "moon_medium.jpg", "moon_small.jpg", [0.53, 0.53, 0.53, 1]],
|
"texture": ["moon.jpg", "moon_medium.jpg", "moon_small.jpg", [0.53, 0.53, 0.53, 1]],
|
||||||
"radius": 27.25,
|
"radius": 27.25,
|
||||||
"distance": 603.357,
|
"distance": 384399,
|
||||||
"orbit_speed": 1,
|
|
||||||
"eccentricity": 0.0549,
|
"eccentricity": 0.0549,
|
||||||
"inclination": 5.145,
|
"inclination": 5.145,
|
||||||
"pitch": -90,
|
"pitch": -90,
|
||||||
|
@ -27,7 +31,7 @@
|
||||||
"iss": {
|
"iss": {
|
||||||
"model": "satellites/iss.obj",
|
"model": "satellites/iss.obj",
|
||||||
"inclination": 51.65,
|
"inclination": 51.65,
|
||||||
"distance": 110,
|
"distance": 68000,
|
||||||
"scale": 5
|
"scale": 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +41,14 @@
|
||||||
"radius": 53.3,
|
"radius": 53.3,
|
||||||
"z": "1.524 * AU",
|
"z": "1.524 * AU",
|
||||||
"pitch": -90,
|
"pitch": -90,
|
||||||
"yaw": 25.19
|
"yaw": 25.19,
|
||||||
|
"mass": 6.4185e+23,
|
||||||
|
"satellites": {
|
||||||
|
"phobos": {
|
||||||
|
"distance": 93770,
|
||||||
|
"model": "satellites/phobos.obj"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"jupiter": {
|
"jupiter": {
|
||||||
"texture": ["jupiter.jpg", "jupiter_medium.jpg", "jupiter_small.jpg", [0.65, 0.36, 0.19, 1]],
|
"texture": ["jupiter.jpg", "jupiter_medium.jpg", "jupiter_small.jpg", [0.65, 0.36, 0.19, 1]],
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
from bisect import bisect_left
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from operator import itemgetter
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import hashlib
|
|
||||||
import os.path
|
import os.path
|
||||||
import random
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
@ -23,7 +19,9 @@ from punyverse.glgeom import *
|
||||||
from punyverse.entity import *
|
from punyverse.entity import *
|
||||||
from punyverse.texture import *
|
from punyverse.texture import *
|
||||||
|
|
||||||
AU = 2000
|
from math import pi, sqrt
|
||||||
|
|
||||||
|
G = 6.67384e-11 # Gravitation Constant
|
||||||
|
|
||||||
|
|
||||||
def get_best_texture(info, optional=False):
|
def get_best_texture(info, optional=False):
|
||||||
|
@ -62,6 +60,8 @@ def load_world(file):
|
||||||
|
|
||||||
world = World()
|
world = World()
|
||||||
e = lambda x: eval(str(x), {'__builtins__': None}, {'AU': root.get('au', 2000)})
|
e = lambda x: eval(str(x), {'__builtins__': None}, {'AU': root.get('au', 2000)})
|
||||||
|
tick = root.get('tick', 4320) # How many second is a tick?
|
||||||
|
length = root.get('length', 4320) # Satellite distance is in km, divide by this gets in world units
|
||||||
|
|
||||||
if 'start' in root:
|
if 'start' in root:
|
||||||
info = root['start']
|
info = root['start']
|
||||||
|
@ -95,22 +95,30 @@ def load_world(file):
|
||||||
else:
|
else:
|
||||||
object_id = compile(sphere, radius, int(radius / 2), int(radius / 2), texture, lighting=lighting)
|
object_id = compile(sphere, radius, int(radius / 2), int(radius / 2), texture, lighting=lighting)
|
||||||
elif 'model' in info:
|
elif 'model' in info:
|
||||||
scale = info.get('scale', 10)
|
scale = info.get('scale', 1)
|
||||||
object_id = model_list(load_model(info['model']), info.get('sx', scale), info.get('sy', scale),
|
object_id = model_list(load_model(info['model']), info.get('sx', scale), info.get('sy', scale),
|
||||||
info.get('sz', scale), (0, 0, 0))
|
info.get('sz', scale), (0, 0, 0))
|
||||||
else:
|
else:
|
||||||
print 'Nothing to load for %s.' % name
|
print 'Nothing to load for %s.' % name
|
||||||
|
|
||||||
|
params = {}
|
||||||
if parent is None:
|
if parent is None:
|
||||||
type = Planet
|
type = Planet
|
||||||
else:
|
else:
|
||||||
x, y, z = parent.location
|
x, y, z = parent.location
|
||||||
distance = e(info.get('distance', 100))
|
distance = e(info.get('distance', 100)) # Distance here means semi-major axis
|
||||||
x -= distance
|
if hasattr(parent, 'mass') and parent.mass is not None:
|
||||||
type = partial(Satellite, parent=parent, orbit_speed=info.get('orbit_speed', 1),
|
speed = 360 / (2 * pi * sqrt((distance * 1000) ** 3 / (G * parent.mass)) / tick)
|
||||||
distance=distance, eccentricity=info.get('eccentricity', 0),
|
else:
|
||||||
inclination=info.get('inclination', 0), longitude=info.get('longitude', 0),
|
speed = info.get('orbit_speed', 1)
|
||||||
argument=info.get('argument', 0))
|
type = Satellite
|
||||||
|
params.update(parent=parent, orbit_speed=speed,
|
||||||
|
distance=distance / length, eccentricity=info.get('eccentricity', 0),
|
||||||
|
inclination=info.get('inclination', 0), longitude=info.get('longitude', 0),
|
||||||
|
argument=info.get('argument', 0))
|
||||||
|
|
||||||
|
if 'mass' in info:
|
||||||
|
params['mass'] = info['mass']
|
||||||
|
|
||||||
atmosphere_id = 0
|
atmosphere_id = 0
|
||||||
cloudmap_id = 0
|
cloudmap_id = 0
|
||||||
|
@ -128,7 +136,7 @@ def load_world(file):
|
||||||
atmosphere_id = compile(disk, radius, radius + size, 30, atm_texture)
|
atmosphere_id = compile(disk, radius, radius + size, 30, atm_texture)
|
||||||
|
|
||||||
object = type(object_id, (x, y, z), (pitch, yaw, roll), delta=delta,
|
object = type(object_id, (x, y, z), (pitch, yaw, roll), delta=delta,
|
||||||
atmosphere=atmosphere_id, cloudmap=cloudmap_id, background=background)
|
atmosphere=atmosphere_id, cloudmap=cloudmap_id, background=background, **params)
|
||||||
world.tracker.append(object)
|
world.tracker.append(object)
|
||||||
|
|
||||||
if 'ring' in info:
|
if 'ring' in info:
|
||||||
|
|
Loading…
Reference in a new issue