Compare commits
169 commits
launcher0.
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
e77d4661cc | ||
|
7cb34c9142 | ||
|
e72a3bc623 | ||
|
9cdf3b8513 | ||
|
885194c7a0 | ||
|
8739120036 | ||
|
d5297d3619 | ||
|
4d58450429 | ||
|
2a9eacf37e | ||
|
98b894c846 | ||
|
7c3c644a6a | ||
|
85d4bd4efc | ||
|
52c1a328aa | ||
|
4430eb7d75 | ||
|
8317201492 | ||
|
b4c96ebf90 | ||
|
f70a725a58 | ||
|
e91bc2c21c | ||
|
674289a8b3 | ||
|
7023ed83ea | ||
|
9e65004128 | ||
|
4857b5487c | ||
|
91fce520b9 | ||
|
9d73059ad0 | ||
|
f11e0b6fc7 | ||
|
168434ce37 | ||
|
d41fcb7d7f | ||
|
1319514cdc | ||
|
a28074558b | ||
|
9608d30462 | ||
|
f7797949d9 | ||
|
3770ec617b | ||
|
ac7a4d0f13 | ||
|
04758850f5 | ||
|
25e28c3c12 | ||
|
c3176ce7f6 | ||
|
3f927427ae | ||
|
fbcdb4d9b0 | ||
|
66c54a9dbb | ||
|
999dc78410 | ||
|
517a7584ca | ||
|
0607ab4d4c | ||
|
bfdefe43ef | ||
|
a2620fc3bc | ||
|
8b070726c3 | ||
|
dde4e1541d | ||
|
825e2ecf6a | ||
|
338b7fb66c | ||
|
1524a6f27e | ||
|
9193f1bc57 | ||
|
13e247bea3 | ||
|
e579086ec5 | ||
|
cbe3c3dd7e | ||
|
054721fc0f | ||
|
1b6d422447 | ||
|
b094dd8905 | ||
|
e33fad8bbb | ||
|
13867d7fd0 | ||
|
b54601f9f7 | ||
|
a862302408 | ||
|
2aed23c4ae | ||
|
3079c612f6 | ||
|
f9d83a2add | ||
|
63d42bca55 | ||
|
1b973b0082 | ||
|
50b8d39b71 | ||
|
2dfab195f1 | ||
|
2baeaa5752 | ||
|
2705dff909 | ||
|
f6fda9b31e | ||
|
ffd036277b | ||
|
951825ce87 | ||
|
358027eee1 | ||
|
b26cde687a | ||
|
ff78a2d8a7 | ||
|
b4dce48fa7 | ||
|
bb928b6c55 | ||
|
aa9bd685ef | ||
|
0fea259382 | ||
|
6d1e52ae76 | ||
|
7e40363898 | ||
|
973988b911 | ||
|
69884816ca | ||
|
f1c961384c | ||
|
c7659c06f7 | ||
|
2348e1d275 | ||
|
83d8baeb8e | ||
|
44889fbf11 | ||
|
af65c9cc6e | ||
|
f961b43675 | ||
|
54d9841d02 | ||
|
4151622b91 | ||
|
34d316726f | ||
|
19da810af2 | ||
|
2350fc7d26 | ||
|
678938ab10 | ||
|
55ee2ee3d2 | ||
|
dc6d0c6c67 | ||
|
db61f5cb59 | ||
|
0794cad88b | ||
|
6d1506926d | ||
|
bb855ec759 | ||
|
d1599eb511 | ||
|
6138402b01 | ||
|
e138e2d382 | ||
|
20b2141ffe | ||
|
a2198937c3 | ||
|
1b2bd928cc | ||
|
8416ed64e6 | ||
|
0198fba591 | ||
|
8900255b4d | ||
|
321f0582fa | ||
|
df3126e232 | ||
|
6fa6bf0429 | ||
|
c6ba1ffdc8 | ||
|
f15af40729 | ||
|
c0f4807d88 | ||
|
59b6f2c7c0 | ||
|
06dd46588c | ||
|
d2a6230eb3 | ||
|
b3a2a9c298 | ||
|
2dc3a2e0c7 | ||
|
3361904aa4 | ||
|
08c12d3b4d | ||
|
3b221e4339 | ||
|
672b5c0462 | ||
|
a069c94dab | ||
|
a03b172aa0 | ||
|
08f108a5fa | ||
|
972e716d00 | ||
|
46ca669ecb | ||
|
1c3abeeaa7 | ||
|
0ae75da2a7 | ||
|
7e25a79968 | ||
|
e5d55f125c | ||
|
5fd914438f | ||
|
f7ba375e22 | ||
|
598132cfd6 | ||
|
ad1970d2d2 | ||
|
617d4913d7 | ||
|
e0e1a619f0 | ||
|
4e51fdaff3 | ||
|
614ac617cf | ||
|
2c1344d799 | ||
|
a8bb6dfd34 | ||
|
c3ec78ecce | ||
|
b1eebd1769 | ||
|
2746338e22 | ||
|
e79321c8a9 | ||
|
d1bd66f463 | ||
|
b4ef56a2c0 | ||
|
8c03a9250b | ||
|
22e17fbde6 | ||
|
debd37e908 | ||
|
6176a7f8cb | ||
|
fb70fcf797 | ||
|
2a7103b25d | ||
|
efedc3c981 | ||
|
7c92bc1315 | ||
|
ada6ae9121 | ||
|
43636c1eb7 | ||
|
5312c4f1dd | ||
|
4074118e6d | ||
|
e95e805551 | ||
|
cc3fe078a6 | ||
|
e8942d925c | ||
|
fc7c8601e6 | ||
|
412387cc71 | ||
|
f87524916e |
32
.gitignore
vendored
|
@ -34,3 +34,35 @@ nosetests.xml
|
||||||
.mr.developer.cfg
|
.mr.developer.cfg
|
||||||
.project
|
.project
|
||||||
.pydevproject
|
.pydevproject
|
||||||
|
|
||||||
|
.idea
|
||||||
|
punyverse/*.obj
|
||||||
|
punyverse/*.c
|
||||||
|
*.html
|
||||||
|
*.exp
|
||||||
|
*.lib
|
||||||
|
/punyverse/assets/textures/*_large.*
|
||||||
|
/punyverse/assets/textures/*_medium.*
|
||||||
|
/punyverse/assets/textures/*_small.*
|
||||||
|
/punyverse/assets/textures/*/*_large.*
|
||||||
|
/punyverse/assets/textures/*/*_medium.*
|
||||||
|
/punyverse/assets/textures/*/*_small.*
|
||||||
|
temp
|
||||||
|
|
||||||
|
# There is a py2exe package that can execute punyverse directly
|
||||||
|
library.zip
|
||||||
|
*.exe
|
||||||
|
*.log
|
||||||
|
*.dll
|
||||||
|
|
||||||
|
# virtualenvs
|
||||||
|
/env
|
||||||
|
/env2
|
||||||
|
/env3
|
||||||
|
|
||||||
|
# Our special launcher
|
||||||
|
!/punyverse/launcher.c
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
.DS_Store
|
||||||
|
._.DS_Store
|
||||||
|
|
17
.travis-wheels.sh
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e -x
|
||||||
|
|
||||||
|
# Install a system package required by our library
|
||||||
|
yum install -y atlas-devel mesa-libGL-devel mesa-libGLU-devel
|
||||||
|
|
||||||
|
# Compile wheels
|
||||||
|
for PYBIN in /opt/python/*/bin; do
|
||||||
|
"${PYBIN}/pip" install -r /io/dev-requirements.txt
|
||||||
|
"${PYBIN}/pip" wheel /io/ -w wheelhouse/
|
||||||
|
done
|
||||||
|
|
||||||
|
# Bundle external shared libraries into the wheels
|
||||||
|
for whl in wheelhouse/punyverse*.whl; do
|
||||||
|
auditwheel repair "$whl" -w /io/wheelhouse/
|
||||||
|
done
|
||||||
|
|
27
.travis.yml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- /^v\d+\./
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- sudo: required
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
env: DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
|
||||||
|
- sudo: required
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
env: DOCKER_IMAGE=quay.io/pypa/manylinux1_i686 PRE_CMD=linux32
|
||||||
|
install:
|
||||||
|
- docker pull $DOCKER_IMAGE
|
||||||
|
script:
|
||||||
|
- docker run --rm -v `pwd`:/io $DOCKER_IMAGE $PRE_CMD /io/.travis-wheels.sh
|
||||||
|
- ls wheelhouse/
|
||||||
|
deploy:
|
||||||
|
provider: releases
|
||||||
|
api_key:
|
||||||
|
secure: kNH5YcvrRmDmFI61Wu0tS4QdKrCbLIJQrVsiU5Cyzqz+hP9FG64uGVHN+J/IJ6Dbt2ny8rnk47pPln8kigfEY3EtnvvFsxexJ1JuefFqZXRPlvzqSm4BEcti5Iui7jMTHczK2eUOY6M2bjC0X4CHMa2dGh16JmfG0RAdUaAhvDCSXkbanoMkOkqyN3go7CAny7aZpyRYwv0GGBDAjXBom4kh5C8wqpXcXlVCmdvrvnmIr2EvMKzvup7FV4FlCkSr03F1APdvTK+GgIE8pLjI9sOw3zo8+tm7krwQsItbqTmPRb0TwL4CD4m2zQTREsLWtYHMy5Z+nqAhADWQqhO0mZDZSozs0TLevasmYdirsPaIufjwE3njWCud/7Mq2ahiBjDhTPHDPk1LzVyrMLo6SVpYru37Ft+Be9oWldz8m+t53RiusfFUVh6MH4+crS+FpdgL9FnQsiNiB+wpb8m6c4tDTWBvsNn2PF2w9NCTlu4u4B+EicM4QoZDK0Pmyg29d6nkEx6EI6Ts6Oz9WIE/z0ZLI3JhTZFZO7be8+xGQ8C3UrCNVS5BOlnyyjcXvnO1Vz56iXKjNLWybeLtMqw7DH58qmSBkRcPcl2+oMdqqIH53BdMHxTfSc9IoCbD1gXekpYPbfo7E2bA/9o4QiphnojWsMw1Yzxs4sXy4vMoxNY=
|
||||||
|
file_glob: true
|
||||||
|
file: wheelhouse/*
|
||||||
|
on:
|
||||||
|
tags: true
|
9
MANIFEST.in
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
include MANIFEST.in
|
||||||
|
include LICENSE
|
||||||
|
include README.md
|
||||||
|
include punyverse/world.json
|
||||||
|
graft punyverse/assets
|
||||||
|
include punyverse/shaders/*.glsl
|
||||||
|
include punyverse/*.c
|
||||||
|
include punyverse/*.h
|
||||||
|
exclude punyverse/*.pyx
|
42
README.md
|
@ -1,4 +1,40 @@
|
||||||
punyverse
|
# punyverse [](https://travis-ci.org/quantum5/punyverse) [](https://ci.appveyor.com/project/quantum5/punyverse) [](https://pypi.org/project/punyverse/) [](https://pypi.org/project/punyverse/) [](https://pypi.org/project/punyverse/)
|
||||||
=========
|
|
||||||
|
|
||||||
Python simulator of a puny universe. (How many words can i stick into one?)
|
Python simulator of a puny universe. (How many words can I stick into one?)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
To install, run `pip install punyverse`.
|
||||||
|
|
||||||
|
If you are on Windows, run `punyverse_make_launcher`. This should create special launchers that runs `punyverse` on
|
||||||
|
your dedicated graphics card, should it exist.
|
||||||
|
|
||||||
|
Your graphics card might not support some of the larger textures used by `punyverse`, and so startup might fail.
|
||||||
|
To solve this problem, run `punyverse_small_images`. It will do nothing if your graphics card supports all the
|
||||||
|
textures, so when in doubt, run `punyverse_small_images` after installation.
|
||||||
|
|
||||||
|
Then, run `punyverse` to launch the simulator, or `punyversew` to launch without the console.
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install punyverse
|
||||||
|
punyverse_make_launcher
|
||||||
|
punyverse_small_images
|
||||||
|
# Installation finished. Run:
|
||||||
|
punyverse
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
If `punyverse` does not work, try upgrading your graphics card drivers.
|
||||||
|
|
||||||
|
If your graphics card does not appear to support OpenGL 3.3, then you cannot run the latest version of `punyverse`.
|
||||||
|
You can try `pip install -U punyverse==0.5` to install the last version of `punyverse` to support legacy devices.
|
||||||
|
You can download the wheels manually from [the PyPI page](https://pypi.org/project/punyverse/0.5/).
|
||||||
|
|
||||||
|
If the problem is unrelated to your graphics card, and it persists, try running punyverse under debug mode. To do this,
|
||||||
|
run `punyverse` as `punyverse --debug`. Then paste the entirety of the output into a new GitHub issue
|
||||||
|
[here](https://github.com/quantum5/punyverse/issues/new).
|
||||||
|
|
1
dev-requirements.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
cython
|
1
punyverse/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
4
punyverse/__main__.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
from punyverse.main import main
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
4
punyverse/__main__.pyw
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
from punyverse.main import main
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
987
punyverse/_cyopengl.pxi
Normal file
|
@ -0,0 +1,987 @@
|
||||||
|
cdef extern from "glwrapper.h":
|
||||||
|
ctypedef unsigned int GLenum
|
||||||
|
ctypedef unsigned char GLboolean
|
||||||
|
ctypedef unsigned int GLbitfield
|
||||||
|
ctypedef void GLvoid
|
||||||
|
ctypedef signed char GLbyte
|
||||||
|
ctypedef short GLshort
|
||||||
|
ctypedef int GLint
|
||||||
|
ctypedef unsigned char GLubyte
|
||||||
|
ctypedef unsigned short GLushort
|
||||||
|
ctypedef unsigned int GLuint
|
||||||
|
ctypedef int GLsizei
|
||||||
|
ctypedef float GLfloat
|
||||||
|
ctypedef float GLclampf
|
||||||
|
ctypedef double GLdouble
|
||||||
|
ctypedef double GLclampd
|
||||||
|
|
||||||
|
# Miscellaneous
|
||||||
|
void glClearIndex(GLfloat c) nogil
|
||||||
|
void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) nogil
|
||||||
|
void glClear(GLbitfield mask) nogil
|
||||||
|
void glIndexMask(GLuint mask) nogil
|
||||||
|
void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) nogil
|
||||||
|
void glAlphaFunc(GLenum func, GLclampf ref) nogil
|
||||||
|
void glBlendFunc(GLenum sfactor, GLenum dfactor) nogil
|
||||||
|
void glLogicOp(GLenum opcode) nogil
|
||||||
|
void glCullFace(GLenum mode) nogil
|
||||||
|
void glFrontFace(GLenum mode) nogil
|
||||||
|
void glPointSize(GLfloat size) nogil
|
||||||
|
void glLineWidth(GLfloat width) nogil
|
||||||
|
void glLineStipple(GLint factor, GLushort pattern) nogil
|
||||||
|
void glPolygonMode(GLenum face, GLenum mode) nogil
|
||||||
|
void glPolygonOffset(GLfloat factor, GLfloat units) nogil
|
||||||
|
void glPolygonStipple(GLubyte *mask) nogil
|
||||||
|
void glGetPolygonStipple(GLubyte *mask) nogil
|
||||||
|
void glEdgeFlag(GLboolean flag) nogil
|
||||||
|
void glEdgeFlagv(GLboolean *flag) nogil
|
||||||
|
void glScissor(GLint x, GLint y, GLsizei width, GLsizei height) nogil
|
||||||
|
void glClipPlane(GLenum plane, GLdouble *equation) nogil
|
||||||
|
void glGetClipPlane(GLenum plane, GLdouble *equation) nogil
|
||||||
|
void glDrawBuffer(GLenum mode) nogil
|
||||||
|
void glReadBuffer(GLenum mode) nogil
|
||||||
|
void glEnable(GLenum cap) nogil
|
||||||
|
void glDisable(GLenum cap) nogil
|
||||||
|
GLboolean glIsEnabled(GLenum cap)
|
||||||
|
void glEnableClientState(GLenum cap) nogil # 1.1
|
||||||
|
void glDisableClientState(GLenum cap) nogil # 1.1
|
||||||
|
void glGetBooleanv(GLenum pname, GLboolean *params) nogil
|
||||||
|
void glGetDoublev(GLenum pname, GLdouble *params) nogil
|
||||||
|
void glGetFloatv(GLenum pname, GLfloat *params) nogil
|
||||||
|
void glGetIntegerv(GLenum pname, GLint *params) nogil
|
||||||
|
void glPushAttrib(GLbitfield mask) nogil
|
||||||
|
void glPopAttrib() nogil
|
||||||
|
void glPushClientAttrib(GLbitfield mask) nogil # 1.1
|
||||||
|
void glPopClientAttrib() nogil # 1.1
|
||||||
|
GLint glRenderMode(GLenum mode)
|
||||||
|
GLenum glGetError()
|
||||||
|
GLubyte* glGetString(GLenum name)
|
||||||
|
void glFinish() nogil
|
||||||
|
void glFlush() nogil
|
||||||
|
void glHint(GLenum target, GLenum mode) nogil
|
||||||
|
|
||||||
|
# Depth Buffer
|
||||||
|
void glClearDepth(GLclampd depth) nogil
|
||||||
|
void glDepthFunc(GLenum func) nogil
|
||||||
|
void glDepthMask(GLboolean flag) nogil
|
||||||
|
void glDepthRange(GLclampd near_val, GLclampd far_val) nogil
|
||||||
|
|
||||||
|
# Accumulation Buffer
|
||||||
|
void glClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) nogil
|
||||||
|
void glAccum(GLenum op, GLfloat value) nogil
|
||||||
|
|
||||||
|
# Transformation
|
||||||
|
void glMatrixMode(GLenum mode) nogil
|
||||||
|
void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val) nogil
|
||||||
|
void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val) nogil
|
||||||
|
void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) nogil
|
||||||
|
void glPushMatrix() nogil
|
||||||
|
void glPopMatrix() nogil
|
||||||
|
void glLoadIdentity() nogil
|
||||||
|
void glLoadMatrixd(GLdouble *m) nogil
|
||||||
|
void glLoadMatrixf(GLfloat *m) nogil
|
||||||
|
void glMultMatrixd(GLdouble *m) nogil
|
||||||
|
void glMultMatrixf(GLfloat *m) nogil
|
||||||
|
void glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) nogil
|
||||||
|
void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) nogil
|
||||||
|
void glScaled(GLdouble x, GLdouble y, GLdouble z) nogil
|
||||||
|
void glScalef(GLfloat x, GLfloat y, GLfloat z) nogil
|
||||||
|
void glTranslated(GLdouble x, GLdouble y, GLdouble z) nogil
|
||||||
|
void glTranslatef(GLfloat x, GLfloat y, GLfloat z) nogil
|
||||||
|
|
||||||
|
# Display Lists
|
||||||
|
GLboolean glIsList(GLuint list)
|
||||||
|
void glDeleteLists(GLuint list, GLsizei range) nogil
|
||||||
|
GLuint glGenLists(GLsizei range)
|
||||||
|
void glNewList(GLuint list, GLenum mode) nogil
|
||||||
|
void glEndList() nogil
|
||||||
|
void glCallList(GLuint list) nogil
|
||||||
|
void glCallLists(GLsizei n, GLenum type, GLvoid *lists) nogil
|
||||||
|
void glListBase(GLuint base) nogil
|
||||||
|
|
||||||
|
# Drawing Functions
|
||||||
|
void glBegin(GLenum mode) nogil
|
||||||
|
void glEnd() nogil
|
||||||
|
void glVertex2d(GLdouble x, GLdouble y) nogil
|
||||||
|
void glVertex2f(GLfloat x, GLfloat y) nogil
|
||||||
|
void glVertex2i(GLint x, GLint y) nogil
|
||||||
|
void glVertex2s(GLshort x, GLshort y) nogil
|
||||||
|
void glVertex3d(GLdouble x, GLdouble y, GLdouble z) nogil
|
||||||
|
void glVertex3f(GLfloat x, GLfloat y, GLfloat z) nogil
|
||||||
|
void glVertex3i(GLint x, GLint y, GLint z) nogil
|
||||||
|
void glVertex3s(GLshort x, GLshort y, GLshort z) nogil
|
||||||
|
void glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) nogil
|
||||||
|
void glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) nogil
|
||||||
|
void glVertex4i(GLint x, GLint y, GLint z, GLint w) nogil
|
||||||
|
void glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w) nogil
|
||||||
|
void glVertex2dv(GLdouble *v) nogil
|
||||||
|
void glVertex2fv(GLfloat *v) nogil
|
||||||
|
void glVertex2iv(GLint *v) nogil
|
||||||
|
void glVertex2sv(GLshort *v) nogil
|
||||||
|
void glVertex3dv(GLdouble *v) nogil
|
||||||
|
void glVertex3fv(GLfloat *v) nogil
|
||||||
|
void glVertex3iv(GLint *v) nogil
|
||||||
|
void glVertex3sv(GLshort *v) nogil
|
||||||
|
void glVertex4dv(GLdouble *v) nogil
|
||||||
|
void glVertex4fv(GLfloat *v) nogil
|
||||||
|
void glVertex4iv(GLint *v) nogil
|
||||||
|
void glVertex4sv(GLshort *v) nogil
|
||||||
|
void glNormal3b(GLbyte nx, GLbyte ny, GLbyte nz) nogil
|
||||||
|
void glNormal3d(GLdouble nx, GLdouble ny, GLdouble nz) nogil
|
||||||
|
void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz) nogil
|
||||||
|
void glNormal3i(GLint nx, GLint ny, GLint nz) nogil
|
||||||
|
void glNormal3s(GLshort nx, GLshort ny, GLshort nz) nogil
|
||||||
|
void glNormal3bv(GLbyte *v) nogil
|
||||||
|
void glNormal3dv(GLdouble *v) nogil
|
||||||
|
void glNormal3fv(GLfloat *v) nogil
|
||||||
|
void glNormal3iv(GLint *v) nogil
|
||||||
|
void glNormal3sv(GLshort *v) nogil
|
||||||
|
void glIndexd(GLdouble c) nogil
|
||||||
|
void glIndexf(GLfloat c) nogil
|
||||||
|
void glIndexi(GLint c) nogil
|
||||||
|
void glIndexs(GLshort c) nogil
|
||||||
|
void glIndexub(GLubyte c) nogil # 1.1
|
||||||
|
void glIndexdv(GLdouble *c) nogil
|
||||||
|
void glIndexfv(GLfloat *c) nogil
|
||||||
|
void glIndexiv(GLint *c) nogil
|
||||||
|
void glIndexsv(GLshort *c) nogil
|
||||||
|
void glIndexubv(GLubyte *c) nogil # 1.1
|
||||||
|
void glColor3b(GLbyte red, GLbyte green, GLbyte blue) nogil
|
||||||
|
void glColor3d(GLdouble red, GLdouble green, GLdouble blue) nogil
|
||||||
|
void glColor3f(GLfloat red, GLfloat green, GLfloat blue) nogil
|
||||||
|
void glColor3i(GLint red, GLint green, GLint blue) nogil
|
||||||
|
void glColor3s(GLshort red, GLshort green, GLshort blue) nogil
|
||||||
|
void glColor3ub(GLubyte red, GLubyte green, GLubyte blue) nogil
|
||||||
|
void glColor3ui(GLuint red, GLuint green, GLuint blue) nogil
|
||||||
|
void glColor3us(GLushort red, GLushort green, GLushort blue) nogil
|
||||||
|
void glColor4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha) nogil
|
||||||
|
void glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha) nogil
|
||||||
|
void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) nogil
|
||||||
|
void glColor4i(GLint red, GLint green, GLint blue, GLint alpha) nogil
|
||||||
|
void glColor4s(GLshort red, GLshort green, GLshort blue, GLshort alpha) nogil
|
||||||
|
void glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) nogil
|
||||||
|
void glColor4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha) nogil
|
||||||
|
void glColor4us(GLushort red, GLushort green, GLushort blue, GLushort alpha) nogil
|
||||||
|
void glColor3bv(GLbyte *v) nogil
|
||||||
|
void glColor3dv(GLdouble *v) nogil
|
||||||
|
void glColor3fv(GLfloat *v) nogil
|
||||||
|
void glColor3iv(GLint *v) nogil
|
||||||
|
void glColor3sv(GLshort *v) nogil
|
||||||
|
void glColor3ubv(GLubyte *v) nogil
|
||||||
|
void glColor3uiv(GLuint *v) nogil
|
||||||
|
void glColor3usv(GLushort *v) nogil
|
||||||
|
void glColor4bv(GLbyte *v) nogil
|
||||||
|
void glColor4dv(GLdouble *v) nogil
|
||||||
|
void glColor4fv(GLfloat *v) nogil
|
||||||
|
void glColor4iv(GLint *v) nogil
|
||||||
|
void glColor4sv(GLshort *v) nogil
|
||||||
|
void glColor4ubv(GLubyte *v) nogil
|
||||||
|
void glColor4uiv(GLuint *v) nogil
|
||||||
|
void glColor4usv(GLushort *v) nogil
|
||||||
|
void glTexCoord1d(GLdouble s) nogil
|
||||||
|
void glTexCoord1f(GLfloat s) nogil
|
||||||
|
void glTexCoord1i(GLint s) nogil
|
||||||
|
void glTexCoord1s(GLshort s) nogil
|
||||||
|
void glTexCoord2d(GLdouble s, GLdouble t) nogil
|
||||||
|
void glTexCoord2f(GLfloat s, GLfloat t) nogil
|
||||||
|
void glTexCoord2i(GLint s, GLint t) nogil
|
||||||
|
void glTexCoord2s(GLshort s, GLshort t) nogil
|
||||||
|
void glTexCoord3d(GLdouble s, GLdouble t, GLdouble r) nogil
|
||||||
|
void glTexCoord3f(GLfloat s, GLfloat t, GLfloat r) nogil
|
||||||
|
void glTexCoord3i(GLint s, GLint t, GLint r) nogil
|
||||||
|
void glTexCoord3s(GLshort s, GLshort t, GLshort r) nogil
|
||||||
|
void glTexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q) nogil
|
||||||
|
void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q) nogil
|
||||||
|
void glTexCoord4i(GLint s, GLint t, GLint r, GLint q) nogil
|
||||||
|
void glTexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q) nogil
|
||||||
|
void glTexCoord1dv(GLdouble *v) nogil
|
||||||
|
void glTexCoord1fv(GLfloat *v) nogil
|
||||||
|
void glTexCoord1iv(GLint *v) nogil
|
||||||
|
void glTexCoord1sv(GLshort *v) nogil
|
||||||
|
void glTexCoord2dv(GLdouble *v) nogil
|
||||||
|
void glTexCoord2fv(GLfloat *v) nogil
|
||||||
|
void glTexCoord2iv(GLint *v) nogil
|
||||||
|
void glTexCoord2sv(GLshort *v) nogil
|
||||||
|
void glTexCoord3dv(GLdouble *v) nogil
|
||||||
|
void glTexCoord3fv(GLfloat *v) nogil
|
||||||
|
void glTexCoord3iv(GLint *v) nogil
|
||||||
|
void glTexCoord3sv(GLshort *v) nogil
|
||||||
|
void glTexCoord4dv(GLdouble *v) nogil
|
||||||
|
void glTexCoord4fv(GLfloat *v) nogil
|
||||||
|
void glTexCoord4iv(GLint *v) nogil
|
||||||
|
void glTexCoord4sv(GLshort *v) nogil
|
||||||
|
void glRasterPos2d(GLdouble x, GLdouble y) nogil
|
||||||
|
void glRasterPos2f(GLfloat x, GLfloat y) nogil
|
||||||
|
void glRasterPos2i(GLint x, GLint y) nogil
|
||||||
|
void glRasterPos2s(GLshort x, GLshort y) nogil
|
||||||
|
void glRasterPos3d(GLdouble x, GLdouble y, GLdouble z) nogil
|
||||||
|
void glRasterPos3f(GLfloat x, GLfloat y, GLfloat z) nogil
|
||||||
|
void glRasterPos3i(GLint x, GLint y, GLint z) nogil
|
||||||
|
void glRasterPos3s(GLshort x, GLshort y, GLshort z) nogil
|
||||||
|
void glRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) nogil
|
||||||
|
void glRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) nogil
|
||||||
|
void glRasterPos4i(GLint x, GLint y, GLint z, GLint w) nogil
|
||||||
|
void glRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) nogil
|
||||||
|
void glRasterPos2dv(GLdouble *v) nogil
|
||||||
|
void glRasterPos2fv(GLfloat *v) nogil
|
||||||
|
void glRasterPos2iv(GLint *v) nogil
|
||||||
|
void glRasterPos2sv(GLshort *v) nogil
|
||||||
|
void glRasterPos3dv(GLdouble *v) nogil
|
||||||
|
void glRasterPos3fv(GLfloat *v) nogil
|
||||||
|
void glRasterPos3iv(GLint *v) nogil
|
||||||
|
void glRasterPos3sv(GLshort *v) nogil
|
||||||
|
void glRasterPos4dv(GLdouble *v) nogil
|
||||||
|
void glRasterPos4fv(GLfloat *v) nogil
|
||||||
|
void glRasterPos4iv(GLint *v) nogil
|
||||||
|
void glRasterPos4sv(GLshort *v) nogil
|
||||||
|
void glRectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) nogil
|
||||||
|
void glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) nogil
|
||||||
|
void glRecti(GLint x1, GLint y1, GLint x2, GLint y2) nogil
|
||||||
|
void glRects(GLshort x1, GLshort y1, GLshort x2, GLshort y2) nogil
|
||||||
|
void glRectdv(GLdouble *v1, GLdouble *v2) nogil
|
||||||
|
void glRectfv(GLfloat *v1, GLfloat *v2) nogil
|
||||||
|
void glRectiv(GLint *v1, GLint *v2) nogil
|
||||||
|
void glRectsv(GLshort *v1, GLshort *v2) nogil
|
||||||
|
|
||||||
|
# Lighting
|
||||||
|
void glShadeModel(GLenum mode) nogil
|
||||||
|
void glLightf(GLenum light, GLenum pname, GLfloat param) nogil
|
||||||
|
void glLighti(GLenum light, GLenum pname, GLint param) nogil
|
||||||
|
void glLightfv(GLenum light, GLenum pname, GLfloat *params) nogil
|
||||||
|
void glLightiv(GLenum light, GLenum pname, GLint *params) nogil
|
||||||
|
void glGetLightfv(GLenum light, GLenum pname, GLfloat *params) nogil
|
||||||
|
void glGetLightiv(GLenum light, GLenum pname, GLint *params) nogil
|
||||||
|
void glLightModelf(GLenum pname, GLfloat param) nogil
|
||||||
|
void glLightModeli(GLenum pname, GLint param) nogil
|
||||||
|
void glLightModelfv(GLenum pname, GLfloat *params) nogil
|
||||||
|
void glLightModeliv(GLenum pname, GLint *params) nogil
|
||||||
|
void glMaterialf(GLenum face, GLenum pname, GLfloat param) nogil
|
||||||
|
void glMateriali(GLenum face, GLenum pname, GLint param) nogil
|
||||||
|
void glMaterialfv(GLenum face, GLenum pname, GLfloat *params) nogil
|
||||||
|
void glMaterialiv(GLenum face, GLenum pname, GLint *params) nogil
|
||||||
|
void glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params) nogil
|
||||||
|
void glGetMaterialiv(GLenum face, GLenum pname, GLint *params) nogil
|
||||||
|
void glColorMaterial(GLenum face, GLenum mode) nogil
|
||||||
|
|
||||||
|
# Raster functions
|
||||||
|
void glPixelZoom(GLfloat xfactor, GLfloat yfactor) nogil
|
||||||
|
void glPixelStoref(GLenum pname, GLfloat param) nogil
|
||||||
|
void glPixelStorei(GLenum pname, GLint param) nogil
|
||||||
|
void glPixelTransferf(GLenum pname, GLfloat param) nogil
|
||||||
|
void glPixelTransferi(GLenum pname, GLint param) nogil
|
||||||
|
void glPixelMapfv(GLenum map, GLint mapsize, GLfloat *values) nogil
|
||||||
|
void glPixelMapuiv(GLenum map, GLint mapsize, GLuint *values) nogil
|
||||||
|
void glPixelMapusv(GLenum map, GLint mapsize, GLushort *values) nogil
|
||||||
|
void glGetPixelMapfv(GLenum map, GLfloat *values) nogil
|
||||||
|
void glGetPixelMapuiv(GLenum map, GLuint *values) nogil
|
||||||
|
void glGetPixelMapusv(GLenum map, GLushort *values) nogil
|
||||||
|
void glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, GLubyte *bitmap) nogil
|
||||||
|
void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) nogil
|
||||||
|
void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) nogil
|
||||||
|
void glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type) nogil
|
||||||
|
|
||||||
|
# Stenciling
|
||||||
|
void glStencilFunc(GLenum func, GLint ref, GLuint mask) nogil
|
||||||
|
void glStencilMask(GLuint mask) nogil
|
||||||
|
void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) nogil
|
||||||
|
void glClearStencil(GLint s) nogil
|
||||||
|
|
||||||
|
# Texture mapping
|
||||||
|
void glTexGend(GLenum coord, GLenum pname, GLdouble param) nogil
|
||||||
|
void glTexGenf(GLenum coord, GLenum pname, GLfloat param) nogil
|
||||||
|
void glTexGeni(GLenum coord, GLenum pname, GLint param) nogil
|
||||||
|
void glTexGendv(GLenum coord, GLenum pname, GLdouble *params) nogil
|
||||||
|
void glTexGenfv(GLenum coord, GLenum pname, GLfloat *params) nogil
|
||||||
|
void glTexGeniv(GLenum coord, GLenum pname, GLint *params) nogil
|
||||||
|
void glGetTexGendv(GLenum coord, GLenum pname, GLdouble *params) nogil
|
||||||
|
void glGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) nogil
|
||||||
|
void glGetTexGeniv(GLenum coord, GLenum pname, GLint *params) nogil
|
||||||
|
void glTexEnvf(GLenum target, GLenum pname, GLfloat param) nogil
|
||||||
|
void glTexEnvi(GLenum target, GLenum pname, GLint param) nogil
|
||||||
|
void glTexEnvfv(GLenum target, GLenum pname, GLfloat *params) nogil
|
||||||
|
void glTexEnviv(GLenum target, GLenum pname, GLint *params) nogil
|
||||||
|
void glGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params) nogil
|
||||||
|
void glGetTexEnviv(GLenum target, GLenum pname, GLint *params) nogil
|
||||||
|
void glTexParameterf(GLenum target, GLenum pname, GLfloat param) nogil
|
||||||
|
void glTexParameteri(GLenum target, GLenum pname, GLint param) nogil
|
||||||
|
void glTexParameterfv(GLenum target, GLenum pname, GLfloat *params) nogil
|
||||||
|
void glTexParameteriv(GLenum target, GLenum pname, GLint *params) nogil
|
||||||
|
void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) nogil
|
||||||
|
void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params) nogil
|
||||||
|
void glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params) nogil
|
||||||
|
void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params) nogil
|
||||||
|
void glTexImage1D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, GLvoid *pixels) nogil
|
||||||
|
void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid *pixels) nogil
|
||||||
|
void glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels) nogil
|
||||||
|
|
||||||
|
# Evaluators
|
||||||
|
void glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, GLdouble *points) nogil
|
||||||
|
void glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, GLfloat *points) nogil
|
||||||
|
void glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble *points) nogil
|
||||||
|
void glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat *points) nogil
|
||||||
|
void glGetMapdv(GLenum target, GLenum query, GLdouble *v) nogil
|
||||||
|
void glGetMapfv(GLenum target, GLenum query, GLfloat *v) nogil
|
||||||
|
void glGetMapiv(GLenum target, GLenum query, GLint *v) nogil
|
||||||
|
void glEvalCoord1d(GLdouble u) nogil
|
||||||
|
void glEvalCoord1f(GLfloat u) nogil
|
||||||
|
void glEvalCoord1dv(GLdouble *u) nogil
|
||||||
|
void glEvalCoord1fv(GLfloat *u) nogil
|
||||||
|
void glEvalCoord2d(GLdouble u, GLdouble v) nogil
|
||||||
|
void glEvalCoord2f(GLfloat u, GLfloat v) nogil
|
||||||
|
void glEvalCoord2dv(GLdouble *u) nogil
|
||||||
|
void glEvalCoord2fv(GLfloat *u) nogil
|
||||||
|
void glMapGrid1d(GLint un, GLdouble u1, GLdouble u2) nogil
|
||||||
|
void glMapGrid1f(GLint un, GLfloat u1, GLfloat u2) nogil
|
||||||
|
void glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2) nogil
|
||||||
|
void glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2) nogil
|
||||||
|
void glEvalPoint1(GLint i) nogil
|
||||||
|
void glEvalPoint2(GLint i, GLint j) nogil
|
||||||
|
void glEvalMesh1(GLenum mode, GLint i1, GLint i2) nogil
|
||||||
|
void glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) nogil
|
||||||
|
|
||||||
|
# Fog
|
||||||
|
void glFogf(GLenum pname, GLfloat param) nogil
|
||||||
|
void glFogi(GLenum pname, GLint param) nogil
|
||||||
|
void glFogfv(GLenum pname, GLfloat *params) nogil
|
||||||
|
void glFogiv(GLenum pname, GLint *params) nogil
|
||||||
|
|
||||||
|
# Selection and Feedback
|
||||||
|
void glFeedbackBuffer(GLsizei size, GLenum type, GLfloat *buffer) nogil
|
||||||
|
void glPassThrough(GLfloat token) nogil
|
||||||
|
void glSelectBuffer(GLsizei size, GLuint *buffer) nogil
|
||||||
|
void glInitNames() nogil
|
||||||
|
void glLoadName(GLuint name) nogil
|
||||||
|
void glPushName(GLuint name) nogil
|
||||||
|
void glPopName() nogil
|
||||||
|
|
||||||
|
|
||||||
|
# 1.1 functions
|
||||||
|
# texture objects
|
||||||
|
void glGenTextures(GLsizei n, GLuint *textures) nogil
|
||||||
|
void glDeleteTextures(GLsizei n, GLuint *textures) nogil
|
||||||
|
void glBindTexture(GLenum target, GLuint texture) nogil
|
||||||
|
void glPrioritizeTextures(GLsizei n, GLuint *textures, GLclampf *priorities) nogil
|
||||||
|
GLboolean glAreTexturesResident(GLsizei n, GLuint *textures, GLboolean *residences)
|
||||||
|
GLboolean glIsTexture(GLuint texture)
|
||||||
|
# texture mapping
|
||||||
|
void glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, GLvoid *pixels) nogil
|
||||||
|
void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) nogil
|
||||||
|
void glCopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border) nogil
|
||||||
|
void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) nogil
|
||||||
|
void glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) nogil
|
||||||
|
void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) nogil
|
||||||
|
# vertex arrays
|
||||||
|
void glVertexPointer(GLint size, GLenum type, GLsizei stride, GLvoid *ptr) nogil
|
||||||
|
void glNormalPointer(GLenum type, GLsizei stride, GLvoid *ptr) nogil
|
||||||
|
void glColorPointer(GLint size, GLenum type, GLsizei stride, GLvoid *ptr) nogil
|
||||||
|
void glIndexPointer(GLenum type, GLsizei stride, GLvoid *ptr) nogil
|
||||||
|
void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLvoid *ptr) nogil
|
||||||
|
void glEdgeFlagPointer(GLsizei stride, GLvoid *ptr) nogil
|
||||||
|
void glGetPointerv(GLenum pname, GLvoid **params) nogil
|
||||||
|
void glArrayElement(GLint i) nogil
|
||||||
|
void glDrawArrays(GLenum mode, GLint first, GLsizei count) nogil
|
||||||
|
void glDrawElements(GLenum mode, GLsizei count, GLenum type, GLvoid *indices) nogil
|
||||||
|
void glInterleavedArrays(GLenum format, GLsizei stride, GLvoid *pointer) nogil
|
||||||
|
|
||||||
|
cdef enum:
|
||||||
|
GL_FALSE = 0x0
|
||||||
|
GL_TRUE = 0x1
|
||||||
|
|
||||||
|
# Data types
|
||||||
|
GL_BYTE = 0x1400
|
||||||
|
GL_UNSIGNED_BYTE = 0x1401
|
||||||
|
GL_SHORT = 0x1402
|
||||||
|
GL_UNSIGNED_SHORT = 0x1403
|
||||||
|
GL_INT = 0x1404
|
||||||
|
GL_UNSIGNED_INT = 0x1405
|
||||||
|
GL_FLOAT = 0x1406
|
||||||
|
GL_DOUBLE = 0x140A
|
||||||
|
GL_2_BYTES = 0x1407
|
||||||
|
GL_3_BYTES = 0x1408
|
||||||
|
GL_4_BYTES = 0x1409
|
||||||
|
|
||||||
|
# Primitives
|
||||||
|
GL_POINTS = 0x0000
|
||||||
|
GL_LINES = 0x0001
|
||||||
|
GL_LINE_LOOP = 0x0002
|
||||||
|
GL_LINE_STRIP = 0x0003
|
||||||
|
GL_TRIANGLES = 0x0004
|
||||||
|
GL_TRIANGLE_STRIP = 0x0005
|
||||||
|
GL_TRIANGLE_FAN = 0x0006
|
||||||
|
GL_QUADS = 0x0007
|
||||||
|
GL_QUAD_STRIP = 0x0008
|
||||||
|
GL_POLYGON = 0x0009
|
||||||
|
|
||||||
|
# Vertex Arrays
|
||||||
|
GL_VERTEX_ARRAY = 0x8074
|
||||||
|
GL_NORMAL_ARRAY = 0x8075
|
||||||
|
GL_COLOR_ARRAY = 0x8076
|
||||||
|
GL_INDEX_ARRAY = 0x8077
|
||||||
|
GL_TEXTURE_COORD_ARRAY = 0x8078
|
||||||
|
GL_EDGE_FLAG_ARRAY = 0x8079
|
||||||
|
GL_VERTEX_ARRAY_SIZE = 0x807A
|
||||||
|
GL_VERTEX_ARRAY_TYPE = 0x807B
|
||||||
|
GL_VERTEX_ARRAY_STRIDE = 0x807C
|
||||||
|
GL_NORMAL_ARRAY_TYPE = 0x807E
|
||||||
|
GL_NORMAL_ARRAY_STRIDE = 0x807F
|
||||||
|
GL_COLOR_ARRAY_SIZE = 0x8081
|
||||||
|
GL_COLOR_ARRAY_TYPE = 0x8082
|
||||||
|
GL_COLOR_ARRAY_STRIDE = 0x8083
|
||||||
|
GL_INDEX_ARRAY_TYPE = 0x8085
|
||||||
|
GL_INDEX_ARRAY_STRIDE = 0x8086
|
||||||
|
GL_TEXTURE_COORD_ARRAY_SIZE = 0x8088
|
||||||
|
GL_TEXTURE_COORD_ARRAY_TYPE = 0x8089
|
||||||
|
GL_TEXTURE_COORD_ARRAY_STRIDE = 0x808A
|
||||||
|
GL_EDGE_FLAG_ARRAY_STRIDE = 0x808C
|
||||||
|
GL_VERTEX_ARRAY_POINTER = 0x808E
|
||||||
|
GL_NORMAL_ARRAY_POINTER = 0x808F
|
||||||
|
GL_COLOR_ARRAY_POINTER = 0x8090
|
||||||
|
GL_INDEX_ARRAY_POINTER = 0x8091
|
||||||
|
GL_TEXTURE_COORD_ARRAY_POINTER = 0x8092
|
||||||
|
GL_EDGE_FLAG_ARRAY_POINTER = 0x8093
|
||||||
|
GL_V2F = 0x2A20
|
||||||
|
GL_V3F = 0x2A21
|
||||||
|
GL_C4UB_V2F = 0x2A22
|
||||||
|
GL_C4UB_V3F = 0x2A23
|
||||||
|
GL_C3F_V3F = 0x2A24
|
||||||
|
GL_N3F_V3F = 0x2A25
|
||||||
|
GL_C4F_N3F_V3F = 0x2A26
|
||||||
|
GL_T2F_V3F = 0x2A27
|
||||||
|
GL_T4F_V4F = 0x2A28
|
||||||
|
GL_T2F_C4UB_V3F = 0x2A29
|
||||||
|
GL_T2F_C3F_V3F = 0x2A2A
|
||||||
|
GL_T2F_N3F_V3F = 0x2A2B
|
||||||
|
GL_T2F_C4F_N3F_V3F = 0x2A2C
|
||||||
|
GL_T4F_C4F_N3F_V4F = 0x2A2D
|
||||||
|
|
||||||
|
# Matrix Mode
|
||||||
|
GL_MATRIX_MODE = 0x0BA0
|
||||||
|
GL_MODELVIEW = 0x1700
|
||||||
|
GL_PROJECTION = 0x1701
|
||||||
|
GL_TEXTURE = 0x1702
|
||||||
|
|
||||||
|
# Points
|
||||||
|
GL_POINT_SMOOTH = 0x0B10
|
||||||
|
GL_POINT_SIZE = 0x0B11
|
||||||
|
GL_POINT_SIZE_GRANULARITY = 0x0B13
|
||||||
|
GL_POINT_SIZE_RANGE = 0x0B12
|
||||||
|
|
||||||
|
# Lines
|
||||||
|
GL_LINE_SMOOTH = 0x0B20
|
||||||
|
GL_LINE_STIPPLE = 0x0B24
|
||||||
|
GL_LINE_STIPPLE_PATTERN = 0x0B25
|
||||||
|
GL_LINE_STIPPLE_REPEAT = 0x0B26
|
||||||
|
GL_LINE_WIDTH = 0x0B21
|
||||||
|
GL_LINE_WIDTH_GRANULARITY = 0x0B23
|
||||||
|
GL_LINE_WIDTH_RANGE = 0x0B22
|
||||||
|
|
||||||
|
# Polygons
|
||||||
|
GL_POINT = 0x1B00
|
||||||
|
GL_LINE = 0x1B01
|
||||||
|
GL_FILL = 0x1B02
|
||||||
|
GL_CW = 0x0900
|
||||||
|
GL_CCW = 0x0901
|
||||||
|
GL_FRONT = 0x0404
|
||||||
|
GL_BACK = 0x0405
|
||||||
|
GL_POLYGON_MODE = 0x0B40
|
||||||
|
GL_POLYGON_SMOOTH = 0x0B41
|
||||||
|
GL_POLYGON_STIPPLE = 0x0B42
|
||||||
|
GL_EDGE_FLAG = 0x0B43
|
||||||
|
GL_CULL_FACE = 0x0B44
|
||||||
|
GL_CULL_FACE_MODE = 0x0B45
|
||||||
|
GL_FRONT_FACE = 0x0B46
|
||||||
|
GL_POLYGON_OFFSET_FACTOR = 0x8038
|
||||||
|
GL_POLYGON_OFFSET_UNITS = 0x2A00
|
||||||
|
GL_POLYGON_OFFSET_POINT = 0x2A01
|
||||||
|
GL_POLYGON_OFFSET_LINE = 0x2A02
|
||||||
|
GL_POLYGON_OFFSET_FILL = 0x8037
|
||||||
|
|
||||||
|
# Display Lists
|
||||||
|
GL_COMPILE = 0x1300
|
||||||
|
GL_COMPILE_AND_EXECUTE = 0x1301
|
||||||
|
GL_LIST_BASE = 0x0B32
|
||||||
|
GL_LIST_INDEX = 0x0B33
|
||||||
|
GL_LIST_MODE = 0x0B30
|
||||||
|
|
||||||
|
# Depth buffer
|
||||||
|
GL_NEVER = 0x0200
|
||||||
|
GL_LESS = 0x0201
|
||||||
|
GL_EQUAL = 0x0202
|
||||||
|
GL_LEQUAL = 0x0203
|
||||||
|
GL_GREATER = 0x0204
|
||||||
|
GL_NOTEQUAL = 0x0205
|
||||||
|
GL_GEQUAL = 0x0206
|
||||||
|
GL_ALWAYS = 0x0207
|
||||||
|
GL_DEPTH_TEST = 0x0B71
|
||||||
|
GL_DEPTH_BITS = 0x0D56
|
||||||
|
GL_DEPTH_CLEAR_VALUE = 0x0B73
|
||||||
|
GL_DEPTH_FUNC = 0x0B74
|
||||||
|
GL_DEPTH_RANGE = 0x0B70
|
||||||
|
GL_DEPTH_WRITEMASK = 0x0B72
|
||||||
|
GL_DEPTH_COMPONENT = 0x1902
|
||||||
|
|
||||||
|
# Lighting
|
||||||
|
GL_LIGHTING = 0x0B50
|
||||||
|
GL_LIGHT0 = 0x4000
|
||||||
|
GL_LIGHT1 = 0x4001
|
||||||
|
GL_LIGHT2 = 0x4002
|
||||||
|
GL_LIGHT3 = 0x4003
|
||||||
|
GL_LIGHT4 = 0x4004
|
||||||
|
GL_LIGHT5 = 0x4005
|
||||||
|
GL_LIGHT6 = 0x4006
|
||||||
|
GL_LIGHT7 = 0x4007
|
||||||
|
GL_SPOT_EXPONENT = 0x1205
|
||||||
|
GL_SPOT_CUTOFF = 0x1206
|
||||||
|
GL_CONSTANT_ATTENUATION = 0x1207
|
||||||
|
GL_LINEAR_ATTENUATION = 0x1208
|
||||||
|
GL_QUADRATIC_ATTENUATION = 0x1209
|
||||||
|
GL_AMBIENT = 0x1200
|
||||||
|
GL_DIFFUSE = 0x1201
|
||||||
|
GL_SPECULAR = 0x1202
|
||||||
|
GL_SHININESS = 0x1601
|
||||||
|
GL_EMISSION = 0x1600
|
||||||
|
GL_POSITION = 0x1203
|
||||||
|
GL_SPOT_DIRECTION = 0x1204
|
||||||
|
GL_AMBIENT_AND_DIFFUSE = 0x1602
|
||||||
|
GL_COLOR_INDEXES = 0x1603
|
||||||
|
GL_LIGHT_MODEL_TWO_SIDE = 0x0B52
|
||||||
|
GL_LIGHT_MODEL_LOCAL_VIEWER = 0x0B51
|
||||||
|
GL_LIGHT_MODEL_AMBIENT = 0x0B53
|
||||||
|
GL_FRONT_AND_BACK = 0x0408
|
||||||
|
GL_SHADE_MODEL = 0x0B54
|
||||||
|
GL_FLAT = 0x1D00
|
||||||
|
GL_SMOOTH = 0x1D01
|
||||||
|
GL_COLOR_MATERIAL = 0x0B57
|
||||||
|
GL_COLOR_MATERIAL_FACE = 0x0B55
|
||||||
|
GL_COLOR_MATERIAL_PARAMETER = 0x0B56
|
||||||
|
GL_NORMALIZE = 0x0BA1
|
||||||
|
|
||||||
|
# User clipping planes
|
||||||
|
GL_CLIP_PLANE0 = 0x3000
|
||||||
|
GL_CLIP_PLANE1 = 0x3001
|
||||||
|
GL_CLIP_PLANE2 = 0x3002
|
||||||
|
GL_CLIP_PLANE3 = 0x3003
|
||||||
|
GL_CLIP_PLANE4 = 0x3004
|
||||||
|
GL_CLIP_PLANE5 = 0x3005
|
||||||
|
|
||||||
|
# Accumulation buffer
|
||||||
|
GL_ACCUM_RED_BITS = 0x0D58
|
||||||
|
GL_ACCUM_GREEN_BITS = 0x0D59
|
||||||
|
GL_ACCUM_BLUE_BITS = 0x0D5A
|
||||||
|
GL_ACCUM_ALPHA_BITS = 0x0D5B
|
||||||
|
GL_ACCUM_CLEAR_VALUE = 0x0B80
|
||||||
|
GL_ACCUM = 0x0100
|
||||||
|
GL_ADD = 0x0104
|
||||||
|
GL_LOAD = 0x0101
|
||||||
|
GL_MULT = 0x0103
|
||||||
|
GL_RETURN = 0x0102
|
||||||
|
|
||||||
|
# Alpha testing
|
||||||
|
GL_ALPHA_TEST = 0x0BC0
|
||||||
|
GL_ALPHA_TEST_REF = 0x0BC2
|
||||||
|
GL_ALPHA_TEST_FUNC = 0x0BC1
|
||||||
|
|
||||||
|
# Blending
|
||||||
|
GL_BLEND = 0x0BE2
|
||||||
|
GL_BLEND_SRC = 0x0BE1
|
||||||
|
GL_BLEND_DST = 0x0BE0
|
||||||
|
GL_ZERO = 0x0
|
||||||
|
GL_ONE = 0x1
|
||||||
|
GL_SRC_COLOR = 0x0300
|
||||||
|
GL_ONE_MINUS_SRC_COLOR = 0x0301
|
||||||
|
GL_SRC_ALPHA = 0x0302
|
||||||
|
GL_ONE_MINUS_SRC_ALPHA = 0x0303
|
||||||
|
GL_DST_ALPHA = 0x0304
|
||||||
|
GL_ONE_MINUS_DST_ALPHA = 0x0305
|
||||||
|
GL_DST_COLOR = 0x0306
|
||||||
|
GL_ONE_MINUS_DST_COLOR = 0x0307
|
||||||
|
GL_SRC_ALPHA_SATURATE = 0x0308
|
||||||
|
GL_CONSTANT_COLOR = 0x8001
|
||||||
|
GL_ONE_MINUS_CONSTANT_COLOR = 0x8002
|
||||||
|
GL_CONSTANT_ALPHA = 0x8003
|
||||||
|
GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004
|
||||||
|
|
||||||
|
# Render Mode
|
||||||
|
GL_FEEDBACK = 0x1C01
|
||||||
|
GL_RENDER = 0x1C00
|
||||||
|
GL_SELECT = 0x1C02
|
||||||
|
|
||||||
|
# Feedback
|
||||||
|
GL_2D = 0x0600
|
||||||
|
GL_3D = 0x0601
|
||||||
|
GL_3D_COLOR = 0x0602
|
||||||
|
GL_3D_COLOR_TEXTURE = 0x0603
|
||||||
|
GL_4D_COLOR_TEXTURE = 0x0604
|
||||||
|
GL_POINT_TOKEN = 0x0701
|
||||||
|
GL_LINE_TOKEN = 0x0702
|
||||||
|
GL_LINE_RESET_TOKEN = 0x0707
|
||||||
|
GL_POLYGON_TOKEN = 0x0703
|
||||||
|
GL_BITMAP_TOKEN = 0x0704
|
||||||
|
GL_DRAW_PIXEL_TOKEN = 0x0705
|
||||||
|
GL_COPY_PIXEL_TOKEN = 0x0706
|
||||||
|
GL_PASS_THROUGH_TOKEN = 0x0700
|
||||||
|
GL_FEEDBACK_BUFFER_POINTER = 0x0DF0
|
||||||
|
GL_FEEDBACK_BUFFER_SIZE = 0x0DF1
|
||||||
|
GL_FEEDBACK_BUFFER_TYPE = 0x0DF2
|
||||||
|
|
||||||
|
# Selection
|
||||||
|
GL_SELECTION_BUFFER_POINTER = 0x0DF3
|
||||||
|
GL_SELECTION_BUFFER_SIZE = 0x0DF4
|
||||||
|
|
||||||
|
# Fog
|
||||||
|
GL_FOG = 0x0B60
|
||||||
|
GL_FOG_MODE = 0x0B65
|
||||||
|
GL_FOG_DENSITY = 0x0B62
|
||||||
|
GL_FOG_COLOR = 0x0B66
|
||||||
|
GL_FOG_INDEX = 0x0B61
|
||||||
|
GL_FOG_START = 0x0B63
|
||||||
|
GL_FOG_END = 0x0B64
|
||||||
|
GL_LINEAR = 0x2601
|
||||||
|
GL_EXP = 0x0800
|
||||||
|
GL_EXP2 = 0x0801
|
||||||
|
|
||||||
|
# Logic Ops
|
||||||
|
GL_LOGIC_OP = 0x0BF1
|
||||||
|
GL_INDEX_LOGIC_OP = 0x0BF1
|
||||||
|
GL_COLOR_LOGIC_OP = 0x0BF2
|
||||||
|
GL_LOGIC_OP_MODE = 0x0BF0
|
||||||
|
GL_CLEAR = 0x1500
|
||||||
|
GL_SET = 0x150F
|
||||||
|
GL_COPY = 0x1503
|
||||||
|
GL_COPY_INVERTED = 0x150C
|
||||||
|
GL_NOOP = 0x1505
|
||||||
|
GL_INVERT = 0x150A
|
||||||
|
GL_AND = 0x1501
|
||||||
|
GL_NAND = 0x150E
|
||||||
|
GL_OR = 0x1507
|
||||||
|
GL_NOR = 0x1508
|
||||||
|
GL_XOR = 0x1506
|
||||||
|
GL_EQUIV = 0x1509
|
||||||
|
GL_AND_REVERSE = 0x1502
|
||||||
|
GL_AND_INVERTED = 0x1504
|
||||||
|
GL_OR_REVERSE = 0x150B
|
||||||
|
GL_OR_INVERTED = 0x150D
|
||||||
|
|
||||||
|
# Stencil
|
||||||
|
GL_STENCIL_TEST = 0x0B90
|
||||||
|
GL_STENCIL_WRITEMASK = 0x0B98
|
||||||
|
GL_STENCIL_BITS = 0x0D57
|
||||||
|
GL_STENCIL_FUNC = 0x0B92
|
||||||
|
GL_STENCIL_VALUE_MASK = 0x0B93
|
||||||
|
GL_STENCIL_REF = 0x0B97
|
||||||
|
GL_STENCIL_FAIL = 0x0B94
|
||||||
|
GL_STENCIL_PASS_DEPTH_PASS = 0x0B96
|
||||||
|
GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95
|
||||||
|
GL_STENCIL_CLEAR_VALUE = 0x0B91
|
||||||
|
GL_STENCIL_INDEX = 0x1901
|
||||||
|
GL_KEEP = 0x1E00
|
||||||
|
GL_REPLACE = 0x1E01
|
||||||
|
GL_INCR = 0x1E02
|
||||||
|
GL_DECR = 0x1E03
|
||||||
|
|
||||||
|
# Buffers, Pixel Drawing/Reading
|
||||||
|
GL_NONE = 0x0
|
||||||
|
GL_LEFT = 0x0406
|
||||||
|
GL_RIGHT = 0x0407
|
||||||
|
#GL_FRONT 0x0404
|
||||||
|
#GL_BACK 0x0405
|
||||||
|
#GL_FRONT_AND_BACK 0x0408
|
||||||
|
GL_FRONT_LEFT = 0x0400
|
||||||
|
GL_FRONT_RIGHT = 0x0401
|
||||||
|
GL_BACK_LEFT = 0x0402
|
||||||
|
GL_BACK_RIGHT = 0x0403
|
||||||
|
GL_AUX0 = 0x0409
|
||||||
|
GL_AUX1 = 0x040A
|
||||||
|
GL_AUX2 = 0x040B
|
||||||
|
GL_AUX3 = 0x040C
|
||||||
|
GL_COLOR_INDEX = 0x1900
|
||||||
|
GL_RED = 0x1903
|
||||||
|
GL_GREEN = 0x1904
|
||||||
|
GL_BLUE = 0x1905
|
||||||
|
GL_ALPHA = 0x1906
|
||||||
|
GL_LUMINANCE = 0x1909
|
||||||
|
GL_LUMINANCE_ALPHA = 0x190A
|
||||||
|
GL_ALPHA_BITS = 0x0D55
|
||||||
|
GL_RED_BITS = 0x0D52
|
||||||
|
GL_GREEN_BITS = 0x0D53
|
||||||
|
GL_BLUE_BITS = 0x0D54
|
||||||
|
GL_INDEX_BITS = 0x0D51
|
||||||
|
GL_SUBPIXEL_BITS = 0x0D50
|
||||||
|
GL_AUX_BUFFERS = 0x0C00
|
||||||
|
GL_READ_BUFFER = 0x0C02
|
||||||
|
GL_DRAW_BUFFER = 0x0C01
|
||||||
|
GL_DOUBLEBUFFER = 0x0C32
|
||||||
|
GL_STEREO = 0x0C33
|
||||||
|
GL_BITMAP = 0x1A00
|
||||||
|
GL_COLOR = 0x1800
|
||||||
|
GL_DEPTH = 0x1801
|
||||||
|
GL_STENCIL = 0x1802
|
||||||
|
GL_DITHER = 0x0BD0
|
||||||
|
GL_RGB = 0x1907
|
||||||
|
GL_RGBA = 0x1908
|
||||||
|
|
||||||
|
# Implementation limits
|
||||||
|
GL_MAX_LIST_NESTING = 0x0B31
|
||||||
|
GL_MAX_ATTRIB_STACK_DEPTH = 0x0D35
|
||||||
|
GL_MAX_MODELVIEW_STACK_DEPTH = 0x0D36
|
||||||
|
GL_MAX_NAME_STACK_DEPTH = 0x0D37
|
||||||
|
GL_MAX_PROJECTION_STACK_DEPTH = 0x0D38
|
||||||
|
GL_MAX_TEXTURE_STACK_DEPTH = 0x0D39
|
||||||
|
GL_MAX_EVAL_ORDER = 0x0D30
|
||||||
|
GL_MAX_LIGHTS = 0x0D31
|
||||||
|
GL_MAX_CLIP_PLANES = 0x0D32
|
||||||
|
GL_MAX_TEXTURE_SIZE = 0x0D33
|
||||||
|
GL_MAX_PIXEL_MAP_TABLE = 0x0D34
|
||||||
|
GL_MAX_VIEWPORT_DIMS = 0x0D3A
|
||||||
|
GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = 0x0D3B
|
||||||
|
|
||||||
|
# Gets
|
||||||
|
GL_ATTRIB_STACK_DEPTH = 0x0BB0
|
||||||
|
GL_CLIENT_ATTRIB_STACK_DEPTH = 0x0BB1
|
||||||
|
GL_COLOR_CLEAR_VALUE = 0x0C22
|
||||||
|
GL_COLOR_WRITEMASK = 0x0C23
|
||||||
|
GL_CURRENT_INDEX = 0x0B01
|
||||||
|
GL_CURRENT_COLOR = 0x0B00
|
||||||
|
GL_CURRENT_NORMAL = 0x0B02
|
||||||
|
GL_CURRENT_RASTER_COLOR = 0x0B04
|
||||||
|
GL_CURRENT_RASTER_DISTANCE = 0x0B09
|
||||||
|
GL_CURRENT_RASTER_INDEX = 0x0B05
|
||||||
|
GL_CURRENT_RASTER_POSITION = 0x0B07
|
||||||
|
GL_CURRENT_RASTER_TEXTURE_COORDS = 0x0B06
|
||||||
|
GL_CURRENT_RASTER_POSITION_VALID = 0x0B08
|
||||||
|
GL_CURRENT_TEXTURE_COORDS = 0x0B03
|
||||||
|
GL_INDEX_CLEAR_VALUE = 0x0C20
|
||||||
|
GL_INDEX_MODE = 0x0C30
|
||||||
|
GL_INDEX_WRITEMASK = 0x0C21
|
||||||
|
GL_MODELVIEW_MATRIX = 0x0BA6
|
||||||
|
GL_MODELVIEW_STACK_DEPTH = 0x0BA3
|
||||||
|
GL_NAME_STACK_DEPTH = 0x0D70
|
||||||
|
GL_PROJECTION_MATRIX = 0x0BA7
|
||||||
|
GL_PROJECTION_STACK_DEPTH = 0x0BA4
|
||||||
|
GL_RENDER_MODE = 0x0C40
|
||||||
|
GL_RGBA_MODE = 0x0C31
|
||||||
|
GL_TEXTURE_MATRIX = 0x0BA8
|
||||||
|
GL_TEXTURE_STACK_DEPTH = 0x0BA5
|
||||||
|
GL_VIEWPORT = 0x0BA2
|
||||||
|
|
||||||
|
# Evaluators
|
||||||
|
GL_AUTO_NORMAL = 0x0D80
|
||||||
|
GL_MAP1_COLOR_4 = 0x0D90
|
||||||
|
GL_MAP1_GRID_DOMAIN = 0x0DD0
|
||||||
|
GL_MAP1_GRID_SEGMENTS = 0x0DD1
|
||||||
|
GL_MAP1_INDEX = 0x0D91
|
||||||
|
GL_MAP1_NORMAL = 0x0D92
|
||||||
|
GL_MAP1_TEXTURE_COORD_1 = 0x0D93
|
||||||
|
GL_MAP1_TEXTURE_COORD_2 = 0x0D94
|
||||||
|
GL_MAP1_TEXTURE_COORD_3 = 0x0D95
|
||||||
|
GL_MAP1_TEXTURE_COORD_4 = 0x0D96
|
||||||
|
GL_MAP1_VERTEX_3 = 0x0D97
|
||||||
|
GL_MAP1_VERTEX_4 = 0x0D98
|
||||||
|
GL_MAP2_COLOR_4 = 0x0DB0
|
||||||
|
GL_MAP2_GRID_DOMAIN = 0x0DD2
|
||||||
|
GL_MAP2_GRID_SEGMENTS = 0x0DD3
|
||||||
|
GL_MAP2_INDEX = 0x0DB1
|
||||||
|
GL_MAP2_NORMAL = 0x0DB2
|
||||||
|
GL_MAP2_TEXTURE_COORD_1 = 0x0DB3
|
||||||
|
GL_MAP2_TEXTURE_COORD_2 = 0x0DB4
|
||||||
|
GL_MAP2_TEXTURE_COORD_3 = 0x0DB5
|
||||||
|
GL_MAP2_TEXTURE_COORD_4 = 0x0DB6
|
||||||
|
GL_MAP2_VERTEX_3 = 0x0DB7
|
||||||
|
GL_MAP2_VERTEX_4 = 0x0DB8
|
||||||
|
GL_COEFF = 0x0A00
|
||||||
|
GL_DOMAIN = 0x0A02
|
||||||
|
GL_ORDER = 0x0A01
|
||||||
|
|
||||||
|
# Hints
|
||||||
|
GL_FOG_HINT = 0x0C54
|
||||||
|
GL_LINE_SMOOTH_HINT = 0x0C52
|
||||||
|
GL_PERSPECTIVE_CORRECTION_HINT = 0x0C50
|
||||||
|
GL_POINT_SMOOTH_HINT = 0x0C51
|
||||||
|
GL_POLYGON_SMOOTH_HINT = 0x0C53
|
||||||
|
GL_DONT_CARE = 0x1100
|
||||||
|
GL_FASTEST = 0x1101
|
||||||
|
GL_NICEST = 0x1102
|
||||||
|
|
||||||
|
# Scissor box
|
||||||
|
GL_SCISSOR_TEST = 0x0C11
|
||||||
|
GL_SCISSOR_BOX = 0x0C10
|
||||||
|
|
||||||
|
# Pixel Mode / Transfer
|
||||||
|
GL_MAP_COLOR = 0x0D10
|
||||||
|
GL_MAP_STENCIL = 0x0D11
|
||||||
|
GL_INDEX_SHIFT = 0x0D12
|
||||||
|
GL_INDEX_OFFSET = 0x0D13
|
||||||
|
GL_RED_SCALE = 0x0D14
|
||||||
|
GL_RED_BIAS = 0x0D15
|
||||||
|
GL_GREEN_SCALE = 0x0D18
|
||||||
|
GL_GREEN_BIAS = 0x0D19
|
||||||
|
GL_BLUE_SCALE = 0x0D1A
|
||||||
|
GL_BLUE_BIAS = 0x0D1B
|
||||||
|
GL_ALPHA_SCALE = 0x0D1C
|
||||||
|
GL_ALPHA_BIAS = 0x0D1D
|
||||||
|
GL_DEPTH_SCALE = 0x0D1E
|
||||||
|
GL_DEPTH_BIAS = 0x0D1F
|
||||||
|
GL_PIXEL_MAP_S_TO_S_SIZE = 0x0CB1
|
||||||
|
GL_PIXEL_MAP_I_TO_I_SIZE = 0x0CB0
|
||||||
|
GL_PIXEL_MAP_I_TO_R_SIZE = 0x0CB2
|
||||||
|
GL_PIXEL_MAP_I_TO_G_SIZE = 0x0CB3
|
||||||
|
GL_PIXEL_MAP_I_TO_B_SIZE = 0x0CB4
|
||||||
|
GL_PIXEL_MAP_I_TO_A_SIZE = 0x0CB5
|
||||||
|
GL_PIXEL_MAP_R_TO_R_SIZE = 0x0CB6
|
||||||
|
GL_PIXEL_MAP_G_TO_G_SIZE = 0x0CB7
|
||||||
|
GL_PIXEL_MAP_B_TO_B_SIZE = 0x0CB8
|
||||||
|
GL_PIXEL_MAP_A_TO_A_SIZE = 0x0CB9
|
||||||
|
GL_PIXEL_MAP_S_TO_S = 0x0C71
|
||||||
|
GL_PIXEL_MAP_I_TO_I = 0x0C70
|
||||||
|
GL_PIXEL_MAP_I_TO_R = 0x0C72
|
||||||
|
GL_PIXEL_MAP_I_TO_G = 0x0C73
|
||||||
|
GL_PIXEL_MAP_I_TO_B = 0x0C74
|
||||||
|
GL_PIXEL_MAP_I_TO_A = 0x0C75
|
||||||
|
GL_PIXEL_MAP_R_TO_R = 0x0C76
|
||||||
|
GL_PIXEL_MAP_G_TO_G = 0x0C77
|
||||||
|
GL_PIXEL_MAP_B_TO_B = 0x0C78
|
||||||
|
GL_PIXEL_MAP_A_TO_A = 0x0C79
|
||||||
|
GL_PACK_ALIGNMENT = 0x0D05
|
||||||
|
GL_PACK_LSB_FIRST = 0x0D01
|
||||||
|
GL_PACK_ROW_LENGTH = 0x0D02
|
||||||
|
GL_PACK_SKIP_PIXELS = 0x0D04
|
||||||
|
GL_PACK_SKIP_ROWS = 0x0D03
|
||||||
|
GL_PACK_SWAP_BYTES = 0x0D00
|
||||||
|
GL_UNPACK_ALIGNMENT = 0x0CF5
|
||||||
|
GL_UNPACK_LSB_FIRST = 0x0CF1
|
||||||
|
GL_UNPACK_ROW_LENGTH = 0x0CF2
|
||||||
|
GL_UNPACK_SKIP_PIXELS = 0x0CF4
|
||||||
|
GL_UNPACK_SKIP_ROWS = 0x0CF3
|
||||||
|
GL_UNPACK_SWAP_BYTES = 0x0CF0
|
||||||
|
GL_ZOOM_X = 0x0D16
|
||||||
|
GL_ZOOM_Y = 0x0D17
|
||||||
|
|
||||||
|
# Texture mapping
|
||||||
|
GL_TEXTURE_ENV = 0x2300
|
||||||
|
GL_TEXTURE_ENV_MODE = 0x2200
|
||||||
|
GL_TEXTURE_1D = 0x0DE0
|
||||||
|
GL_TEXTURE_2D = 0x0DE1
|
||||||
|
GL_TEXTURE_WRAP_S = 0x2802
|
||||||
|
GL_TEXTURE_WRAP_T = 0x2803
|
||||||
|
GL_TEXTURE_MAG_FILTER = 0x2800
|
||||||
|
GL_TEXTURE_MIN_FILTER = 0x2801
|
||||||
|
GL_TEXTURE_ENV_COLOR = 0x2201
|
||||||
|
GL_TEXTURE_GEN_S = 0x0C60
|
||||||
|
GL_TEXTURE_GEN_T = 0x0C61
|
||||||
|
GL_TEXTURE_GEN_MODE = 0x2500
|
||||||
|
GL_TEXTURE_BORDER_COLOR = 0x1004
|
||||||
|
GL_TEXTURE_WIDTH = 0x1000
|
||||||
|
GL_TEXTURE_HEIGHT = 0x1001
|
||||||
|
GL_TEXTURE_BORDER = 0x1005
|
||||||
|
GL_TEXTURE_COMPONENTS = 0x1003
|
||||||
|
GL_TEXTURE_RED_SIZE = 0x805C
|
||||||
|
GL_TEXTURE_GREEN_SIZE = 0x805D
|
||||||
|
GL_TEXTURE_BLUE_SIZE = 0x805E
|
||||||
|
GL_TEXTURE_ALPHA_SIZE = 0x805F
|
||||||
|
GL_TEXTURE_LUMINANCE_SIZE = 0x8060
|
||||||
|
GL_TEXTURE_INTENSITY_SIZE = 0x8061
|
||||||
|
GL_NEAREST_MIPMAP_NEAREST = 0x2700
|
||||||
|
GL_NEAREST_MIPMAP_LINEAR = 0x2702
|
||||||
|
GL_LINEAR_MIPMAP_NEAREST = 0x2701
|
||||||
|
GL_LINEAR_MIPMAP_LINEAR = 0x2703
|
||||||
|
GL_OBJECT_LINEAR = 0x2401
|
||||||
|
GL_OBJECT_PLANE = 0x2501
|
||||||
|
GL_EYE_LINEAR = 0x2400
|
||||||
|
GL_EYE_PLANE = 0x2502
|
||||||
|
GL_SPHERE_MAP = 0x2402
|
||||||
|
GL_DECAL = 0x2101
|
||||||
|
GL_MODULATE = 0x2100
|
||||||
|
GL_NEAREST = 0x2600
|
||||||
|
GL_REPEAT = 0x2901
|
||||||
|
GL_CLAMP = 0x2900
|
||||||
|
GL_S = 0x2000
|
||||||
|
GL_T = 0x2001
|
||||||
|
GL_R = 0x2002
|
||||||
|
GL_Q = 0x2003
|
||||||
|
GL_TEXTURE_GEN_R = 0x0C62
|
||||||
|
GL_TEXTURE_GEN_Q = 0x0C63
|
||||||
|
|
||||||
|
# Utility
|
||||||
|
GL_VENDOR = 0x1F00
|
||||||
|
GL_RENDERER = 0x1F01
|
||||||
|
GL_VERSION = 0x1F02
|
||||||
|
GL_EXTENSIONS = 0x1F03
|
||||||
|
|
||||||
|
# Errors
|
||||||
|
GL_NO_ERROR = 0x0
|
||||||
|
GL_INVALID_VALUE = 0x0501
|
||||||
|
GL_INVALID_ENUM = 0x0500
|
||||||
|
GL_INVALID_OPERATION = 0x0502
|
||||||
|
GL_STACK_OVERFLOW = 0x0503
|
||||||
|
GL_STACK_UNDERFLOW = 0x0504
|
||||||
|
GL_OUT_OF_MEMORY = 0x0505
|
||||||
|
|
||||||
|
# glPush/PopAttrib bits
|
||||||
|
GL_CURRENT_BIT = 0x00000001
|
||||||
|
GL_POINT_BIT = 0x00000002
|
||||||
|
GL_LINE_BIT = 0x00000004
|
||||||
|
GL_POLYGON_BIT = 0x00000008
|
||||||
|
GL_POLYGON_STIPPLE_BIT = 0x00000010
|
||||||
|
GL_PIXEL_MODE_BIT = 0x00000020
|
||||||
|
GL_LIGHTING_BIT = 0x00000040
|
||||||
|
GL_FOG_BIT = 0x00000080
|
||||||
|
GL_DEPTH_BUFFER_BIT = 0x00000100
|
||||||
|
GL_ACCUM_BUFFER_BIT = 0x00000200
|
||||||
|
GL_STENCIL_BUFFER_BIT = 0x00000400
|
||||||
|
GL_VIEWPORT_BIT = 0x00000800
|
||||||
|
GL_TRANSFORM_BIT = 0x00001000
|
||||||
|
GL_ENABLE_BIT = 0x00002000
|
||||||
|
GL_COLOR_BUFFER_BIT = 0x00004000
|
||||||
|
GL_HINT_BIT = 0x00008000
|
||||||
|
GL_EVAL_BIT = 0x00010000
|
||||||
|
GL_LIST_BIT = 0x00020000
|
||||||
|
GL_TEXTURE_BIT = 0x00040000
|
||||||
|
GL_SCISSOR_BIT = 0x00080000
|
||||||
|
GL_ALL_ATTRIB_BITS = 0x000FFFFF
|
||||||
|
|
||||||
|
|
||||||
|
# OpenGL 1.1
|
||||||
|
GL_PROXY_TEXTURE_1D = 0x8063
|
||||||
|
GL_PROXY_TEXTURE_2D = 0x8064
|
||||||
|
GL_TEXTURE_PRIORITY = 0x8066
|
||||||
|
GL_TEXTURE_RESIDENT = 0x8067
|
||||||
|
GL_TEXTURE_BINDING_1D = 0x8068
|
||||||
|
GL_TEXTURE_BINDING_2D = 0x8069
|
||||||
|
GL_TEXTURE_INTERNAL_FORMAT = 0x1003
|
||||||
|
GL_ALPHA4 = 0x803B
|
||||||
|
GL_ALPHA8 = 0x803C
|
||||||
|
GL_ALPHA12 = 0x803D
|
||||||
|
GL_ALPHA16 = 0x803E
|
||||||
|
GL_LUMINANCE4 = 0x803F
|
||||||
|
GL_LUMINANCE8 = 0x8040
|
||||||
|
GL_LUMINANCE12 = 0x8041
|
||||||
|
GL_LUMINANCE16 = 0x8042
|
||||||
|
GL_LUMINANCE4_ALPHA4 = 0x8043
|
||||||
|
GL_LUMINANCE6_ALPHA2 = 0x8044
|
||||||
|
GL_LUMINANCE8_ALPHA8 = 0x8045
|
||||||
|
GL_LUMINANCE12_ALPHA4 = 0x8046
|
||||||
|
GL_LUMINANCE12_ALPHA12 = 0x8047
|
||||||
|
GL_LUMINANCE16_ALPHA16 = 0x8048
|
||||||
|
GL_INTENSITY = 0x8049
|
||||||
|
GL_INTENSITY4 = 0x804A
|
||||||
|
GL_INTENSITY8 = 0x804B
|
||||||
|
GL_INTENSITY12 = 0x804C
|
||||||
|
GL_INTENSITY16 = 0x804D
|
||||||
|
GL_R3_G3_B2 = 0x2A10
|
||||||
|
GL_RGB4 = 0x804F
|
||||||
|
GL_RGB5 = 0x8050
|
||||||
|
GL_RGB8 = 0x8051
|
||||||
|
GL_RGB10 = 0x8052
|
||||||
|
GL_RGB12 = 0x8053
|
||||||
|
GL_RGB16 = 0x8054
|
||||||
|
GL_RGBA2 = 0x8055
|
||||||
|
GL_RGBA4 = 0x8056
|
||||||
|
GL_RGB5_A1 = 0x8057
|
||||||
|
GL_RGBA8 = 0x8058
|
||||||
|
GL_RGB10_A2 = 0x8059
|
||||||
|
GL_RGBA12 = 0x805A
|
||||||
|
GL_RGBA16 = 0x805B
|
||||||
|
GL_CLIENT_PIXEL_STORE_BIT = 0x00000001
|
||||||
|
GL_CLIENT_VERTEX_ARRAY_BIT = 0x00000002
|
||||||
|
GL_ALL_CLIENT_ATTRIB_BITS = 0xFFFFFFFF
|
||||||
|
GL_CLIENT_ALL_ATTRIB_BITS = 0xFFFFFFFF
|
39
punyverse/_glgeom.pyx
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
from libc.string cimport memcpy
|
||||||
|
|
||||||
|
include "_cyopengl.pxi"
|
||||||
|
cdef float PI = 3.1415926535897932324626
|
||||||
|
cdef float TWOPI = PI * 2
|
||||||
|
|
||||||
|
cdef extern from "Python.h":
|
||||||
|
object PyBytes_FromStringAndSize(const char *s, Py_ssize_t len)
|
||||||
|
const char* PyBytes_AsString(bytes o)
|
||||||
|
|
||||||
|
|
||||||
|
cpdef bytes bgr_to_rgb(bytes buffer, int width, int height, bint alpha=0):
|
||||||
|
cdef int length = len(buffer)
|
||||||
|
cdef int depth = length / (width * height)
|
||||||
|
cdef int depth2 = depth - alpha
|
||||||
|
cdef object final = PyBytes_FromStringAndSize(NULL, length)
|
||||||
|
cdef char *result = PyBytes_AsString(final)
|
||||||
|
cdef const char *source = PyBytes_AsString(buffer)
|
||||||
|
cdef int x, y, offset, i, row = width * depth
|
||||||
|
for y in xrange(height):
|
||||||
|
for x in xrange(width):
|
||||||
|
offset = y * row + x * depth
|
||||||
|
for i in xrange(depth2):
|
||||||
|
result[offset+i] = source[offset+depth2-i-1]
|
||||||
|
if alpha:
|
||||||
|
result[offset+depth2] = source[offset+depth2]
|
||||||
|
return final
|
||||||
|
|
||||||
|
|
||||||
|
cpdef bytes flip_vertical(bytes buffer, int width, int height):
|
||||||
|
cdef int length = len(buffer)
|
||||||
|
cdef object final = PyBytes_FromStringAndSize(NULL, length)
|
||||||
|
cdef char *result = PyBytes_AsString(final)
|
||||||
|
cdef const char *source = PyBytes_AsString(buffer)
|
||||||
|
cdef int y1, y2, row = length / height
|
||||||
|
for y1 in xrange(height):
|
||||||
|
y2 = height - y1 - 1
|
||||||
|
memcpy(result + y1 * row, source + y2 * row, row)
|
||||||
|
return final
|
4619
punyverse/assets/models/asteroids/01.obj
Normal file
18443
punyverse/assets/models/asteroids/02.obj
Normal file
18443
punyverse/assets/models/asteroids/03.obj
Normal file
11
punyverse/assets/models/asteroids/asteroid.mtl
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# Blender MTL File: 'None'
|
||||||
|
# Material Count: 1
|
||||||
|
|
||||||
|
newmtl Material
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.520996 0.473531 0.337164
|
||||||
|
Ks 0.079916 0.069096 0.039636
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
11
punyverse/assets/models/asteroids/mainbelt.mtl
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# Blender MTL File: 'None'
|
||||||
|
# Material Count: 1
|
||||||
|
|
||||||
|
newmtl Material
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.389517 0.389517 0.389517
|
||||||
|
Ks 0.303197 0.303197 0.303197
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
188
punyverse/assets/models/asteroids/mainbelt.obj
Normal file
|
@ -0,0 +1,188 @@
|
||||||
|
# Blender v2.68 (sub 0) OBJ File: 'mainbeltastroid.blend'
|
||||||
|
# www.blender.org
|
||||||
|
mtllib mainbelt.mtl
|
||||||
|
g Cube
|
||||||
|
v 0.290193 -0.983926 0.474791
|
||||||
|
v 0.437387 -1.185402 -0.058906
|
||||||
|
v -0.278179 0.795311 -0.169923
|
||||||
|
v -0.176207 0.961698 -0.576060
|
||||||
|
v -0.749408 0.677473 -0.403865
|
||||||
|
v -0.843249 1.101376 0.368964
|
||||||
|
v 0.921024 0.543359 -0.373421
|
||||||
|
v 1.228522 0.313481 -0.796992
|
||||||
|
v 1.413710 0.491171 0.016800
|
||||||
|
v 0.824964 -0.186862 -0.430968
|
||||||
|
v 0.169830 0.339481 0.955115
|
||||||
|
v 0.788238 0.224175 0.864338
|
||||||
|
v 0.579672 -0.319492 0.985489
|
||||||
|
v -0.850858 0.163566 0.318706
|
||||||
|
v 0.631733 -0.588108 -0.649624
|
||||||
|
v -0.094402 -0.322324 -1.249913
|
||||||
|
v -0.249124 -1.065447 -0.286061
|
||||||
|
v -0.020992 -0.954752 -0.765611
|
||||||
|
v -0.632247 -1.107953 -0.512581
|
||||||
|
v 0.124837 1.315392 0.134372
|
||||||
|
v 0.577110 0.882123 0.035559
|
||||||
|
v 0.730517 0.855449 0.648931
|
||||||
|
v -0.248585 0.742805 0.757662
|
||||||
|
v 0.897809 -0.004470 0.247323
|
||||||
|
v 0.947047 -0.715323 0.120538
|
||||||
|
v 0.998978 -0.476379 0.574922
|
||||||
|
v -0.353813 -0.204947 1.105379
|
||||||
|
v -0.981584 -0.532307 0.798081
|
||||||
|
v -0.690767 0.347252 0.944776
|
||||||
|
v -1.260799 -0.267750 -0.576518
|
||||||
|
v -0.903255 -0.554117 -0.072930
|
||||||
|
v -0.873585 -0.350903 -0.897106
|
||||||
|
v -1.083754 0.162032 -0.623495
|
||||||
|
v -0.679472 0.071680 -0.834524
|
||||||
|
v -0.150468 0.605678 -1.224164
|
||||||
|
v -0.292701 -0.962443 0.791399
|
||||||
|
v 0.496173 1.124109 -0.437672
|
||||||
|
v 0.278706 -0.267373 1.389388
|
||||||
|
vn 0.529098 -0.735317 0.423514
|
||||||
|
vn 0.695321 -0.606928 -0.384925
|
||||||
|
vn 0.383061 -0.662029 0.644190
|
||||||
|
vn 0.511064 -0.783451 0.353579
|
||||||
|
vn -0.138461 0.908731 -0.393746
|
||||||
|
vn 0.593966 0.354629 -0.722110
|
||||||
|
vn -0.359523 0.891682 0.275039
|
||||||
|
vn 0.500172 0.865296 0.033023
|
||||||
|
vn 0.619478 -0.019645 -0.784768
|
||||||
|
vn 0.619649 0.775456 -0.121254
|
||||||
|
vn 0.983189 0.132696 0.125425
|
||||||
|
vn 0.171122 0.151303 0.973563
|
||||||
|
vn 0.197398 0.332706 0.922139
|
||||||
|
vn -0.945107 0.286186 0.157704
|
||||||
|
vn -0.676128 0.735533 -0.042912
|
||||||
|
vn 0.472294 -0.437683 -0.765096
|
||||||
|
vn 0.304249 0.044783 -0.951539
|
||||||
|
vn 0.283559 0.913995 -0.290184
|
||||||
|
vn 0.830567 -0.515214 0.211455
|
||||||
|
vn -0.311526 -0.600264 -0.736637
|
||||||
|
vn 0.483338 -0.690051 -0.538714
|
||||||
|
vn -0.198815 -0.976318 0.085294
|
||||||
|
vn -0.529631 -0.847817 -0.026400
|
||||||
|
vn -0.165780 0.630247 0.758489
|
||||||
|
vn 0.699114 0.677982 0.227114
|
||||||
|
vn 0.259894 0.628514 0.733093
|
||||||
|
vn 0.677448 -0.097416 0.729091
|
||||||
|
vn 0.987177 0.091683 -0.130671
|
||||||
|
vn 0.891772 -0.211464 -0.400032
|
||||||
|
vn -0.233827 -0.388331 0.891361
|
||||||
|
vn -0.437396 -0.005360 0.899253
|
||||||
|
vn 0.072347 -0.376917 0.923417
|
||||||
|
vn -0.408216 0.016368 0.912739
|
||||||
|
vn -0.926227 -0.356903 -0.121344
|
||||||
|
vn -0.988224 0.122316 -0.091933
|
||||||
|
vn -0.501469 0.749738 -0.431766
|
||||||
|
vn -0.483647 -0.150069 -0.862302
|
||||||
|
vn -0.612900 0.611035 -0.500988
|
||||||
|
vn -0.774342 0.425106 -0.468699
|
||||||
|
vn 0.338886 -0.661704 0.668808
|
||||||
|
vn 0.178682 -0.903205 0.390248
|
||||||
|
vn -0.801728 0.596145 0.042935
|
||||||
|
vn -0.110776 0.869208 -0.481877
|
||||||
|
vn -0.805509 0.589632 0.059074
|
||||||
|
vn 0.018409 0.877560 -0.479114
|
||||||
|
vn 0.759682 -0.149805 0.632805
|
||||||
|
vn 0.713637 -0.691918 0.109416
|
||||||
|
vn 0.786427 0.594041 0.169258
|
||||||
|
vn 0.282085 0.931005 -0.231641
|
||||||
|
vn 0.583533 -0.247678 0.773398
|
||||||
|
vn 0.732741 0.478045 0.484317
|
||||||
|
vn -0.004524 0.581410 0.813598
|
||||||
|
vn -0.006905 0.433901 0.900934
|
||||||
|
vn -0.991584 0.014936 -0.128596
|
||||||
|
vn -0.563344 -0.039656 0.825270
|
||||||
|
vn -0.858666 0.466868 0.211488
|
||||||
|
vn 0.423569 -0.519252 -0.742271
|
||||||
|
vn 0.187865 -0.972846 -0.135191
|
||||||
|
vn -0.222629 -0.496977 -0.838719
|
||||||
|
vn -0.081738 -0.961894 -0.260919
|
||||||
|
vn 0.052827 -0.993867 0.097149
|
||||||
|
vn -0.766365 -0.585261 0.264864
|
||||||
|
vn 0.669742 0.730079 -0.135756
|
||||||
|
vn 0.981787 0.097127 -0.163283
|
||||||
|
vn 0.963043 0.258645 0.075174
|
||||||
|
vn -0.116467 -0.992337 0.041265
|
||||||
|
vn -0.385386 -0.892604 -0.233959
|
||||||
|
vn -0.546778 0.362906 -0.754541
|
||||||
|
vn -0.849251 -0.203792 0.487075
|
||||||
|
vn -0.445795 0.086256 -0.890970
|
||||||
|
vn -0.893227 0.392020 0.220152
|
||||||
|
vn -0.412489 0.000355 -0.910963
|
||||||
|
usemtl Material
|
||||||
|
s off
|
||||||
|
f 1//1 2//1 25//1
|
||||||
|
f 2//2 15//2 25//2
|
||||||
|
f 1//3 26//3 13//3
|
||||||
|
f 1//4 25//4 26//4
|
||||||
|
f 20//5 37//5 4//5
|
||||||
|
f 37//6 7//6 35//6
|
||||||
|
f 4//7 5//7 3//7
|
||||||
|
f 3//8 6//8 23//8
|
||||||
|
f 7//9 9//9 10//9
|
||||||
|
f 7//10 21//10 22//10
|
||||||
|
f 22//11 12//11 24//11
|
||||||
|
f 11//12 13//12 12//12
|
||||||
|
f 11//13 12//13 22//13
|
||||||
|
f 14//14 28//14 29//14
|
||||||
|
f 14//15 29//15 23//15
|
||||||
|
f 16//16 8//16 15//16
|
||||||
|
f 16//17 35//17 8//17
|
||||||
|
f 35//18 7//18 8//18
|
||||||
|
f 15//19 8//19 10//19
|
||||||
|
f 16//20 18//20 32//20
|
||||||
|
f 18//21 15//21 2//21
|
||||||
|
f 17//22 2//22 36//22
|
||||||
|
f 36//23 28//23 31//23
|
||||||
|
f 20//24 11//24 22//24
|
||||||
|
f 21//25 37//25 20//25
|
||||||
|
f 20//26 23//26 11//26
|
||||||
|
f 26//27 12//27 13//27
|
||||||
|
f 24//28 25//28 10//28
|
||||||
|
f 25//29 15//29 10//29
|
||||||
|
f 27//30 28//30 36//30
|
||||||
|
f 27//31 29//31 28//31
|
||||||
|
f 36//32 13//32 27//32
|
||||||
|
f 27//33 38//33 29//33
|
||||||
|
f 32//34 19//34 31//34
|
||||||
|
f 31//35 28//35 14//35
|
||||||
|
f 35//36 5//36 4//36
|
||||||
|
f 34//37 33//37 35//37
|
||||||
|
f 35//38 33//38 5//38
|
||||||
|
f 34//39 35//39 32//39
|
||||||
|
f 36//40 1//40 13//40
|
||||||
|
f 2//41 1//41 36//41
|
||||||
|
f 3//42 20//42 4//42
|
||||||
|
f 4//43 37//43 35//43
|
||||||
|
f 20//44 3//44 23//44
|
||||||
|
f 3//45 5//45 6//45
|
||||||
|
f 8//46 7//46 10//46
|
||||||
|
f 9//47 24//47 10//47
|
||||||
|
f 21//48 7//48 37//48
|
||||||
|
f 9//49 7//49 22//49
|
||||||
|
f 9//50 22//50 24//50
|
||||||
|
f 11//51 38//51 13//51
|
||||||
|
f 38//52 11//52 29//52
|
||||||
|
f 11//53 23//53 29//53
|
||||||
|
f 5//54 14//54 6//54
|
||||||
|
f 6//55 14//55 23//55
|
||||||
|
f 14//56 5//56 33//56
|
||||||
|
f 15//57 18//57 16//57
|
||||||
|
f 17//58 19//58 18//58
|
||||||
|
f 18//59 19//59 32//59
|
||||||
|
f 17//60 18//60 2//60
|
||||||
|
f 19//61 17//61 36//61
|
||||||
|
f 19//62 36//62 31//62
|
||||||
|
f 21//63 20//63 22//63
|
||||||
|
f 25//64 24//64 26//64
|
||||||
|
f 26//65 24//65 12//65
|
||||||
|
f 38//66 27//66 13//66
|
||||||
|
f 31//67 30//67 32//67
|
||||||
|
f 30//68 34//68 32//68
|
||||||
|
f 30//69 31//69 14//69
|
||||||
|
f 30//70 33//70 34//70
|
||||||
|
f 30//71 14//71 33//71
|
||||||
|
f 35//72 16//72 32//72
|
103
punyverse/assets/models/asteroids/mainbelt2.obj
Normal 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
|
125
punyverse/assets/models/satellites/cassini.mtl
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
# Blender MTL File: 'Cassini_tiny.blend'
|
||||||
|
# Material Count: 13
|
||||||
|
|
||||||
|
newmtl None
|
||||||
|
Ns 0.000000
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.640000 0.640000 0.640000
|
||||||
|
Ks 0.800000 0.800000 0.800000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl aluminum
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.317021 0.317021 0.317021
|
||||||
|
Ks 1.000000 1.000000 1.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl black_krinkle
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.117961 0.117961 0.117961
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd cassini/foil.jpg
|
||||||
|
|
||||||
|
newmtl black_krinkle_NONE
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.117961 0.117961 0.117961
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd cassini/foil.jpg
|
||||||
|
|
||||||
|
newmtl black_krinkle_cassini_01_.psd.001
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.117961 0.117961 0.117961
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl dish_AO
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.512000 0.512000 0.512000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl dish_AO_dish_AO.png
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.512000 0.512000 0.512000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl foil_gold
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 1.0 1.0 1.0
|
||||||
|
Ks 0.5 0.5 0.5
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd cassini/tex.jpg
|
||||||
|
|
||||||
|
newmtl foil_gold_2
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 1.0 1.0 1.0
|
||||||
|
Ks 0.5 0.5 0.5
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd cassini/tex.jpg
|
||||||
|
|
||||||
|
newmtl plastic_dark
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.132862 0.132862 0.132862
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl plastic_white
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.593267 0.593267 0.593267
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl tex_01
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.512000 0.512000 0.512000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd cassini/tex.jpg
|
||||||
|
|
||||||
|
newmtl tex_01_NONE
|
||||||
|
Ns 92.156863
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.512000 0.512000 0.512000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd cassini/tex.jpg
|
12235
punyverse/assets/models/satellites/cassini.obj
Normal file
BIN
punyverse/assets/models/satellites/cassini/foil.jpg
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
punyverse/assets/models/satellites/cassini/tex.jpg
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
punyverse/assets/models/satellites/hbltel_1.jpg
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
punyverse/assets/models/satellites/hbltel_2.jpg
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
punyverse/assets/models/satellites/hbltel_3.jpg
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
punyverse/assets/models/satellites/hbltel_4.jpg
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
punyverse/assets/models/satellites/hbltel_w.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
52
punyverse/assets/models/satellites/hst.mtl
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# Blender MTL File: 'None'
|
||||||
|
# Material Count: 5
|
||||||
|
|
||||||
|
newmtl hbltel_1
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.467451 0.467451 0.467451
|
||||||
|
Ks 0.449020 0.449020 0.449020
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd hbltel_1.jpg
|
||||||
|
|
||||||
|
newmtl hbltel_2
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.467451 0.467451 0.467451
|
||||||
|
Ks 0.449020 0.449020 0.449020
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd hbltel_2.jpg
|
||||||
|
|
||||||
|
newmtl hbltel_3
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.467451 0.467451 0.467451
|
||||||
|
Ks 0.449020 0.449020 0.449020
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd hbltel_3.jpg
|
||||||
|
|
||||||
|
newmtl hbltel_4
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.467451 0.467451 0.467451
|
||||||
|
Ks 0.449020 0.449020 0.449020
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd hbltel_4.jpg
|
||||||
|
|
||||||
|
newmtl hbltel_wfc_1
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.467451 0.467451 0.467451
|
||||||
|
Ks 0.449020 0.449020 0.449020
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd hbltel_w.jpg
|
12321
punyverse/assets/models/satellites/hst.obj
Normal file
110
punyverse/assets/models/satellites/iss.mtl
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
# Blender MTL File: 'None'
|
||||||
|
# Material Count: 12
|
||||||
|
|
||||||
|
newmtl Brown
|
||||||
|
Ns 25
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.238431 0.189074 0.102853
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl ISSDarkMetal
|
||||||
|
Ns 25
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.070138 0.070138 0.070138
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl ISSGray2
|
||||||
|
Ns 25
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.241098 0.241098 0.241098
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl ISSMetal1
|
||||||
|
Ns 25
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.381373 0.381373 0.381373
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl ISSSolarPanels
|
||||||
|
Ns 25
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.043620 0.023622 0.301177
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl ISSWhiteMetal
|
||||||
|
Ns 25
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.561093 0.561093 0.561093
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl _Brown
|
||||||
|
Ns 25
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.238431 0.189074 0.102853
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl _ISSDarkMetal
|
||||||
|
Ns 25
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.070138 0.070138 0.070138
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl _ISSGray2
|
||||||
|
Ns 25
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.241098 0.241098 0.241098
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl _ISSMetal1
|
||||||
|
Ns 25
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.381373 0.381373 0.381373
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl _ISSSolarPanels
|
||||||
|
Ns 25
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.043620 0.023622 0.301177
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl _ISSWhiteMetal
|
||||||
|
Ns 25
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.561093 0.561093 0.561093
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
21459
punyverse/assets/models/satellites/iss.obj
Normal file
BIN
punyverse/assets/models/satellites/phobos.jpg
Normal file
After Width: | Height: | Size: 100 KiB |
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
|
5131
punyverse/assets/models/satellites/phobos.obj
Normal file
34
punyverse/assets/textures.txt
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
# This file contains all the textures that is bigger than the minimum OpenGL texture size
|
||||||
|
# and hence may need to be resized depending on the machine
|
||||||
|
|
||||||
|
sun.jpg
|
||||||
|
mercury.jpg
|
||||||
|
venus.jpg
|
||||||
|
earth.jpg
|
||||||
|
earth_normal.jpg
|
||||||
|
earth_emission.jpg
|
||||||
|
earth_specular.jpg
|
||||||
|
cloudmap.jpg
|
||||||
|
moon.jpg
|
||||||
|
mars.jpg
|
||||||
|
jupiter.jpg
|
||||||
|
saturn.jpg
|
||||||
|
uranus.jpg
|
||||||
|
neptune.jpg
|
||||||
|
sky_px.jpg
|
||||||
|
sky_py.jpg
|
||||||
|
sky_pz.jpg
|
||||||
|
sky_nx.jpg
|
||||||
|
sky_ny.jpg
|
||||||
|
sky_nz.jpg
|
||||||
|
moons/io.jpg
|
||||||
|
moons/europa.jpg
|
||||||
|
moons/ganymede.jpg
|
||||||
|
moons/callisto.jpg
|
||||||
|
moons/titan.jpg
|
||||||
|
moons/rhea.jpg
|
||||||
|
moons/iapetus.jpg
|
||||||
|
moons/dione.jpg
|
||||||
|
moons/tethys.jpg
|
||||||
|
moons/enceladus.jpg
|
||||||
|
moons/mimas.jpg
|
BIN
punyverse/assets/textures/cloudmap.jpg
Normal file
After Width: | Height: | Size: 351 KiB |
BIN
punyverse/assets/textures/constellation_nx.png
Normal file
After Width: | Height: | Size: 104 KiB |
BIN
punyverse/assets/textures/constellation_ny.png
Normal file
After Width: | Height: | Size: 87 KiB |
BIN
punyverse/assets/textures/constellation_nz.png
Normal file
After Width: | Height: | Size: 98 KiB |
BIN
punyverse/assets/textures/constellation_px.png
Normal file
After Width: | Height: | Size: 88 KiB |
BIN
punyverse/assets/textures/constellation_py.png
Normal file
After Width: | Height: | Size: 100 KiB |
BIN
punyverse/assets/textures/constellation_pz.png
Normal file
After Width: | Height: | Size: 108 KiB |
BIN
punyverse/assets/textures/earth.jpg
Normal file
After Width: | Height: | Size: 1.7 MiB |
BIN
punyverse/assets/textures/earth_emission.jpg
Normal file
After Width: | Height: | Size: 328 KiB |
BIN
punyverse/assets/textures/earth_normal.jpg
Normal file
After Width: | Height: | Size: 522 KiB |
BIN
punyverse/assets/textures/earth_specular.jpg
Normal file
After Width: | Height: | Size: 90 KiB |
BIN
punyverse/assets/textures/font.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
punyverse/assets/textures/glow.png
Normal file
After Width: | Height: | Size: 98 B |
BIN
punyverse/assets/textures/jupiter.jpg
Normal file
After Width: | Height: | Size: 482 KiB |
BIN
punyverse/assets/textures/mars.jpg
Normal file
After Width: | Height: | Size: 2 MiB |
BIN
punyverse/assets/textures/mercury.jpg
Normal file
After Width: | Height: | Size: 358 KiB |
BIN
punyverse/assets/textures/moon.jpg
Normal file
After Width: | Height: | Size: 1.3 MiB |
BIN
punyverse/assets/textures/moons/callisto.jpg
Normal file
After Width: | Height: | Size: 364 KiB |
BIN
punyverse/assets/textures/moons/dione.jpg
Normal file
After Width: | Height: | Size: 236 KiB |
BIN
punyverse/assets/textures/moons/enceladus.jpg
Normal file
After Width: | Height: | Size: 206 KiB |
BIN
punyverse/assets/textures/moons/europa.jpg
Normal file
After Width: | Height: | Size: 244 KiB |
BIN
punyverse/assets/textures/moons/ganymede.jpg
Normal file
After Width: | Height: | Size: 284 KiB |
BIN
punyverse/assets/textures/moons/iapetus.jpg
Normal file
After Width: | Height: | Size: 175 KiB |
BIN
punyverse/assets/textures/moons/io.jpg
Normal file
After Width: | Height: | Size: 268 KiB |
BIN
punyverse/assets/textures/moons/mimas.jpg
Normal file
After Width: | Height: | Size: 278 KiB |
BIN
punyverse/assets/textures/moons/rhea.jpg
Normal file
After Width: | Height: | Size: 303 KiB |
BIN
punyverse/assets/textures/moons/tethys.jpg
Normal file
After Width: | Height: | Size: 281 KiB |
BIN
punyverse/assets/textures/moons/titan.jpg
Normal file
After Width: | Height: | Size: 210 KiB |
BIN
punyverse/assets/textures/neptune.jpg
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
punyverse/assets/textures/ring_saturn.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
punyverse/assets/textures/ring_uranus.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
punyverse/assets/textures/saturn.jpg
Normal file
After Width: | Height: | Size: 281 KiB |
BIN
punyverse/assets/textures/sky_nx.jpg
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
punyverse/assets/textures/sky_ny.jpg
Normal file
After Width: | Height: | Size: 1.1 MiB |
BIN
punyverse/assets/textures/sky_nz.jpg
Normal file
After Width: | Height: | Size: 1.3 MiB |
BIN
punyverse/assets/textures/sky_px.jpg
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
punyverse/assets/textures/sky_py.jpg
Normal file
After Width: | Height: | Size: 1.1 MiB |
BIN
punyverse/assets/textures/sky_pz.jpg
Normal file
After Width: | Height: | Size: 1.3 MiB |
BIN
punyverse/assets/textures/sun.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
punyverse/assets/textures/uranus.jpg
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
punyverse/assets/textures/venus.jpg
Normal file
After Width: | Height: | Size: 981 KiB |
89
punyverse/camera.py
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
|
from math import sin, cos, radians, hypot, tan
|
||||||
|
|
||||||
|
from punyverse.glgeom import Matrix4f
|
||||||
|
from punyverse.utils import cached_property
|
||||||
|
|
||||||
|
|
||||||
|
class Camera(object):
|
||||||
|
def __init__(self, x=0, y=0, z=0, pitch=0, yaw=0, roll=0):
|
||||||
|
self.x = x
|
||||||
|
self.y = y
|
||||||
|
self.z = z
|
||||||
|
self.pitch = pitch
|
||||||
|
self.yaw = yaw
|
||||||
|
self.roll = roll
|
||||||
|
|
||||||
|
self.fov = radians(45)
|
||||||
|
self.aspect = 1
|
||||||
|
self.znear = 1
|
||||||
|
self.zfar = 3000000
|
||||||
|
|
||||||
|
self.speed = 0
|
||||||
|
self.roll_left = False
|
||||||
|
self.roll_right = False
|
||||||
|
|
||||||
|
def move(self, speed):
|
||||||
|
dx, dy, dz = self.direction()
|
||||||
|
self.x += dx * speed
|
||||||
|
self.y += dy * speed
|
||||||
|
self.z += dz * speed
|
||||||
|
|
||||||
|
self.view_matrix = None
|
||||||
|
|
||||||
|
def mouse_move(self, dx, dy):
|
||||||
|
if self.pitch > 90 or self.pitch < -90:
|
||||||
|
dx = -dx
|
||||||
|
if self.yaw + dx >= 360:
|
||||||
|
self.yaw = self.yaw + dx - 360
|
||||||
|
elif self.yaw + dx < 0:
|
||||||
|
self.yaw = 360 - self.yaw + dx
|
||||||
|
else:
|
||||||
|
self.yaw += dx
|
||||||
|
|
||||||
|
self.pitch -= dy
|
||||||
|
if self.pitch < -180:
|
||||||
|
self.pitch += 360
|
||||||
|
elif self.pitch > 180:
|
||||||
|
self.pitch -= 360
|
||||||
|
|
||||||
|
self.view_matrix = None
|
||||||
|
|
||||||
|
def direction(self):
|
||||||
|
m = cos(radians(self.pitch))
|
||||||
|
|
||||||
|
dy = -sin(radians(self.pitch))
|
||||||
|
dx = cos(radians(self.yaw - 90)) * m
|
||||||
|
dz = sin(radians(self.yaw - 90)) * m
|
||||||
|
return dx, dy, dz
|
||||||
|
|
||||||
|
def update(self, dt, move):
|
||||||
|
if self.roll_left:
|
||||||
|
self.roll -= 4 * dt * 10
|
||||||
|
self.view_matrix = None
|
||||||
|
if self.roll_right:
|
||||||
|
self.roll += 4 * dt * 10
|
||||||
|
self.view_matrix = None
|
||||||
|
if move:
|
||||||
|
self.move(self.speed * 10 * dt)
|
||||||
|
|
||||||
|
def reset_roll(self):
|
||||||
|
self.roll = 0
|
||||||
|
self.view_matrix = None
|
||||||
|
|
||||||
|
def distance(self, x, y, z):
|
||||||
|
return hypot(hypot(x - self.x, y - self.y), z - self.z)
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def view_matrix(self):
|
||||||
|
return Matrix4f.from_angles((self.x, self.y, self.z), (self.pitch, self.yaw, self.roll), view=True)
|
||||||
|
|
||||||
|
def projection_matrix(self):
|
||||||
|
scale_y = 1 / tan(self.fov / 2)
|
||||||
|
scale_x = scale_y / self.aspect
|
||||||
|
frustrum = self.znear - self.zfar
|
||||||
|
return Matrix4f([scale_x, 0, 0, 0,
|
||||||
|
0, scale_y, 0, 0,
|
||||||
|
0, 0, (self.znear + self.zfar) / frustrum, -1,
|
||||||
|
0, 0, (2 * self.znear * self.zfar) / frustrum, 0])
|
597
punyverse/entity.py
Normal file
|
@ -0,0 +1,597 @@
|
||||||
|
import random
|
||||||
|
from math import sqrt, pi
|
||||||
|
|
||||||
|
from pyglet.gl import *
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
|
from six.moves import range
|
||||||
|
|
||||||
|
from punyverse.glgeom import *
|
||||||
|
from punyverse.model import load_model, WavefrontVBO
|
||||||
|
from punyverse.orbit import KeplerOrbit
|
||||||
|
from punyverse.texture import get_best_texture, load_alpha_mask, get_cube_map, load_texture_1d
|
||||||
|
from punyverse.utils import cached_property
|
||||||
|
|
||||||
|
G = 6.67384e-11 # Gravitation Constant
|
||||||
|
|
||||||
|
|
||||||
|
class Entity(object):
|
||||||
|
background = False
|
||||||
|
|
||||||
|
def __init__(self, world, name, location, rotation=(0, 0, 0), direction=(0, 0, 0)):
|
||||||
|
self.world = world
|
||||||
|
self.name = name
|
||||||
|
self.location = location
|
||||||
|
self.rotation = rotation
|
||||||
|
self.direction = direction
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def model_matrix(self):
|
||||||
|
return Matrix4f.from_angles(self.location, self.rotation)
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def mv_matrix(self):
|
||||||
|
return self.world.view_matrix() * self.model_matrix
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def mvp_matrix(self):
|
||||||
|
return self.world.vp_matrix * self.model_matrix
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
self.model_matrix = None
|
||||||
|
self.mv_matrix = None
|
||||||
|
self.mvp_matrix = None
|
||||||
|
x, y, z = self.location
|
||||||
|
dx, dy, dz = self.direction
|
||||||
|
self.location = x + dx, y + dy, z + dz
|
||||||
|
|
||||||
|
def collides(self, x, y, z):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def draw(self, options):
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
|
class Asteroid(Entity):
|
||||||
|
def __init__(self, world, model, location, direction):
|
||||||
|
super(Asteroid, self).__init__(world, 'Asteroid', location, direction=direction)
|
||||||
|
self.model = model
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
super(Asteroid, self).update()
|
||||||
|
rx, ry, rz = self.rotation
|
||||||
|
# Increment all axis to 'spin'
|
||||||
|
self.rotation = rx + 1, ry + 1, rz + 1
|
||||||
|
|
||||||
|
def draw(self, options):
|
||||||
|
shader = self.world.activate_shader('model')
|
||||||
|
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
|
||||||
|
shader.uniform_mat4('u_mvMatrix', self.mv_matrix)
|
||||||
|
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
|
||||||
|
self.model.draw(shader)
|
||||||
|
|
||||||
|
|
||||||
|
class AsteroidManager(object):
|
||||||
|
def __init__(self, world):
|
||||||
|
self.world = world
|
||||||
|
self.asteroids = []
|
||||||
|
|
||||||
|
def __bool__(self):
|
||||||
|
return bool(self.asteroids)
|
||||||
|
__nonzero__ = __bool__
|
||||||
|
|
||||||
|
def load(self, file):
|
||||||
|
shader = self.world.activate_shader('model')
|
||||||
|
self.asteroids.append(WavefrontVBO(load_model(file), shader, 5, 5, 5))
|
||||||
|
|
||||||
|
def new(self, location, direction):
|
||||||
|
return Asteroid(self.world, random.choice(self.asteroids), location, direction)
|
||||||
|
|
||||||
|
|
||||||
|
class Belt(Entity):
|
||||||
|
def __init__(self, name, world, info):
|
||||||
|
x = world.evaluate(info.get('x', 0))
|
||||||
|
y = world.evaluate(info.get('y', 0))
|
||||||
|
z = world.evaluate(info.get('z', 0))
|
||||||
|
radius = world.evaluate(info.get('radius', 0))
|
||||||
|
cross = world.evaluate(info.get('cross', 0))
|
||||||
|
count = int(world.evaluate(info.get('count', 0)))
|
||||||
|
scale = info.get('scale', 1)
|
||||||
|
longitude = info.get('longitude', 0)
|
||||||
|
inclination = info.get('inclination', 0)
|
||||||
|
argument = info.get('argument', 0)
|
||||||
|
rotation = info.get('period', 31536000)
|
||||||
|
models = info['model']
|
||||||
|
self.rotation_angle = 360.0 / rotation if rotation else 0
|
||||||
|
|
||||||
|
shader = world.activate_shader('belt')
|
||||||
|
if not isinstance(models, list):
|
||||||
|
models = [models]
|
||||||
|
|
||||||
|
self.belt = BeltVBO(radius, cross, len(models), count)
|
||||||
|
self.objects = [
|
||||||
|
WavefrontVBO(load_model(model), shader, info.get('sx', scale),
|
||||||
|
info.get('sy', scale), info.get('sz', scale))
|
||||||
|
for model in models
|
||||||
|
]
|
||||||
|
|
||||||
|
def callback():
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vbo)
|
||||||
|
shader.vertex_attribute('a_translate', self.belt.location_size, self.belt.type, GL_FALSE,
|
||||||
|
self.belt.stride, self.belt.location_offset, divisor=1)
|
||||||
|
shader.vertex_attribute('a_scale', self.belt.scale_size, self.belt.type, GL_FALSE,
|
||||||
|
self.belt.stride, self.belt.scale_offset, divisor=1)
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
|
|
||||||
|
for model, vbo, count in zip(self.objects, self.belt.vbo, self.belt.sizes):
|
||||||
|
model.additional_attributes(callback)
|
||||||
|
|
||||||
|
super(Belt, self).__init__(world, name, (x, y, z), (inclination, longitude, argument))
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
super(Belt, self).update()
|
||||||
|
pitch, yaw, roll = self.rotation
|
||||||
|
self.rotation = pitch, self.world.tick * self.rotation_angle % 360, roll
|
||||||
|
|
||||||
|
def draw(self, options):
|
||||||
|
shader = self.world.activate_shader('belt')
|
||||||
|
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
|
||||||
|
shader.uniform_mat4('u_mvMatrix', self.mv_matrix)
|
||||||
|
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
|
||||||
|
|
||||||
|
for object, vbo, count in zip(self.objects, self.belt.vbo, self.belt.sizes):
|
||||||
|
object.draw(shader, instances=count)
|
||||||
|
|
||||||
|
|
||||||
|
class Sky(Entity):
|
||||||
|
background = True
|
||||||
|
|
||||||
|
def __init__(self, world, info, callback=None):
|
||||||
|
pitch = world.evaluate(info.get('pitch', 0))
|
||||||
|
yaw = world.evaluate(info.get('yaw', 0))
|
||||||
|
roll = world.evaluate(info.get('roll', 0))
|
||||||
|
|
||||||
|
super(Sky, self).__init__(world, 'Sky', (0, 0, 0), [pitch, yaw, roll])
|
||||||
|
|
||||||
|
self.texture = get_best_texture(info['texture'], loader=get_cube_map, callback=callback)
|
||||||
|
self.constellation = get_cube_map(info['constellation'])
|
||||||
|
self.cube = Cube()
|
||||||
|
self.vao = VAO()
|
||||||
|
|
||||||
|
shader = self.world.activate_shader('sky')
|
||||||
|
with self.vao:
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, self.cube.vbo)
|
||||||
|
shader.vertex_attribute('a_direction', self.cube.direction_size, self.cube.type, GL_FALSE,
|
||||||
|
self.cube.stride, self.cube.direction_offset)
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
|
|
||||||
|
def draw(self, options):
|
||||||
|
cam = self.world.cam
|
||||||
|
shader = self.world.activate_shader('sky')
|
||||||
|
shader.uniform_mat4('u_mvpMatrix', self.world.projection_matrix() *
|
||||||
|
Matrix4f.from_angles(rotation=(cam.pitch, cam.yaw, cam.roll)) *
|
||||||
|
Matrix4f.from_angles(rotation=self.rotation))
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_CUBE_MAP, self.texture)
|
||||||
|
shader.uniform_texture('u_skysphere', 0)
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE1)
|
||||||
|
glBindTexture(GL_TEXTURE_CUBE_MAP, self.constellation)
|
||||||
|
shader.uniform_texture('u_constellation', 1)
|
||||||
|
|
||||||
|
shader.uniform_bool('u_lines', options.constellations)
|
||||||
|
|
||||||
|
with self.vao:
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, self.cube.vertex_count)
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0)
|
||||||
|
|
||||||
|
|
||||||
|
class Body(Entity):
|
||||||
|
def __init__(self, name, world, info, parent=None):
|
||||||
|
self.parent = parent
|
||||||
|
self.satellites = []
|
||||||
|
|
||||||
|
x = world.evaluate(info.get('x', 0))
|
||||||
|
y = world.evaluate(info.get('y', 0))
|
||||||
|
z = world.evaluate(info.get('z', 0))
|
||||||
|
pitch = world.evaluate(info.get('pitch', 0))
|
||||||
|
yaw = world.evaluate(info.get('yaw', 0))
|
||||||
|
roll = world.evaluate(info.get('roll', 0))
|
||||||
|
rotation = world.evaluate(info.get('rotation', 86400))
|
||||||
|
|
||||||
|
self.mass = info.get('mass')
|
||||||
|
|
||||||
|
orbit_distance = float(world.evaluate(info.get('orbit_distance', world.au)))
|
||||||
|
self.orbit_show = orbit_distance * 1.25
|
||||||
|
self.orbit_blend = orbit_distance / 4
|
||||||
|
self.orbit_opaque = orbit_distance
|
||||||
|
|
||||||
|
super(Body, self).__init__(world, name, (x, y, z), (pitch, yaw, roll))
|
||||||
|
self.initial_roll = roll
|
||||||
|
|
||||||
|
self.orbit = None
|
||||||
|
self.orbit_speed = None
|
||||||
|
|
||||||
|
if parent:
|
||||||
|
# Semi-major axis when actually displayed in virtual space
|
||||||
|
distance = world.evaluate(info.get('distance', 100))
|
||||||
|
# Semi-major axis used to calculate orbital speed
|
||||||
|
sma = world.evaluate(info.get('sma', distance))
|
||||||
|
|
||||||
|
if hasattr(parent, 'mass') and parent.mass is not None:
|
||||||
|
period = 2 * pi * sqrt((sma * 1000) ** 3 / (G * parent.mass))
|
||||||
|
self.orbit_speed = 360.0 / period
|
||||||
|
if not rotation: # Rotation = 0 assumes tidal lock
|
||||||
|
rotation = period
|
||||||
|
else:
|
||||||
|
self.orbit_speed = info.get('orbit_speed', 1)
|
||||||
|
|
||||||
|
self.orbit = KeplerOrbit(distance / world.length, info.get('eccentricity', 0), info.get('inclination', 0),
|
||||||
|
info.get('longitude', 0), info.get('argument', 0))
|
||||||
|
|
||||||
|
self.rotation_angle = 360.0 / rotation if rotation else 0
|
||||||
|
|
||||||
|
# Orbit calculation
|
||||||
|
self.orbit_vbo = None
|
||||||
|
self.orbit_vao = None
|
||||||
|
self.orbit_cache = None
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def orbit_matrix(self):
|
||||||
|
return self.world.view_matrix() * Matrix4f.from_angles(self.location)
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
super(Body, self).update()
|
||||||
|
|
||||||
|
if self.rotation_angle:
|
||||||
|
pitch, yaw, roll = self.rotation
|
||||||
|
roll = (self.initial_roll + self.world.tick * self.rotation_angle) % 360
|
||||||
|
self.rotation = pitch, yaw, roll
|
||||||
|
|
||||||
|
if self.orbit:
|
||||||
|
px, py, pz = self.parent.location
|
||||||
|
x, z, y = self.orbit.orbit(self.world.tick * self.orbit_speed % 360)
|
||||||
|
self.location = (x + px, y + py, z + pz)
|
||||||
|
self.orbit_matrix = None
|
||||||
|
|
||||||
|
for satellite in self.satellites:
|
||||||
|
satellite.update()
|
||||||
|
|
||||||
|
def get_orbit(self, shader):
|
||||||
|
if not self.orbit:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Cache key is the three orbital plane parameters and eccentricity
|
||||||
|
cache = (self.orbit.eccentricity, self.orbit.longitude, self.orbit.inclination, self.orbit.argument)
|
||||||
|
if self.orbit_cache == cache:
|
||||||
|
return self.orbit_vbo, self.orbit_vao
|
||||||
|
|
||||||
|
if self.orbit_vbo is not None:
|
||||||
|
self.orbit_vbo.close()
|
||||||
|
|
||||||
|
if self.orbit_vao is not None:
|
||||||
|
self.orbit_vao.close()
|
||||||
|
|
||||||
|
self.orbit_vbo = OrbitVBO(self.orbit)
|
||||||
|
self.orbit_vao = VAO()
|
||||||
|
|
||||||
|
with self.orbit_vao:
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, self.orbit_vbo.vbo)
|
||||||
|
shader.vertex_attribute('a_position', self.orbit_vbo.position_size, self.orbit_vbo.type, GL_FALSE,
|
||||||
|
self.orbit_vbo.stride, self.orbit_vbo.position_offset)
|
||||||
|
|
||||||
|
self.orbit_cache = cache
|
||||||
|
return self.orbit_vbo, self.orbit_vao
|
||||||
|
|
||||||
|
def _draw_orbits(self, distance):
|
||||||
|
shader = self.world.activate_shader('line')
|
||||||
|
solid = distance < self.parent.orbit_opaque
|
||||||
|
alpha = 1 if solid else (1 - (distance - self.parent.orbit_opaque) / self.parent.orbit_blend)
|
||||||
|
shader.uniform_vec4('u_color', 1, 1, 1, alpha)
|
||||||
|
shader.uniform_mat4('u_mvpMatrix', self.world.projection_matrix() * self.parent.orbit_matrix)
|
||||||
|
|
||||||
|
if not solid:
|
||||||
|
glEnable(GL_BLEND)
|
||||||
|
|
||||||
|
vbo, vao = self.get_orbit(shader)
|
||||||
|
with vao:
|
||||||
|
glDrawArrays(GL_LINE_LOOP, 0, vbo.vertex_count)
|
||||||
|
|
||||||
|
if not solid:
|
||||||
|
glDisable(GL_BLEND)
|
||||||
|
|
||||||
|
def draw(self, options):
|
||||||
|
self._draw(options)
|
||||||
|
|
||||||
|
if options.orbit and self.orbit:
|
||||||
|
dist = self.world.cam.distance(*self.parent.location)
|
||||||
|
if dist < self.parent.orbit_show:
|
||||||
|
self._draw_orbits(dist)
|
||||||
|
|
||||||
|
for satellite in self.satellites:
|
||||||
|
satellite.draw(options)
|
||||||
|
|
||||||
|
def _draw(self, options):
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def collides(self, x, y, z):
|
||||||
|
return self._collides(x, y, z) or any(satellite.collides(x, y, z) for satellite in self.satellites)
|
||||||
|
|
||||||
|
def _collides(self, x, y, z):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class SphericalBody(Body):
|
||||||
|
_sphere_cache = {}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_sphere(cls, division, tangent=True):
|
||||||
|
if (division, tangent) in cls._sphere_cache:
|
||||||
|
return cls._sphere_cache[division, tangent]
|
||||||
|
cls._sphere_cache[division, tangent] = sphere = \
|
||||||
|
(TangentSphere if tangent else SimpleSphere)(division, division)
|
||||||
|
return sphere
|
||||||
|
|
||||||
|
def __init__(self, name, world, info, parent=None):
|
||||||
|
super(SphericalBody, self).__init__(name, world, info, parent)
|
||||||
|
|
||||||
|
self.radius = world.evaluate(info.get('radius', world.length)) / world.length
|
||||||
|
division = info.get('division', max(min(int(self.radius / 8), 60), 10))
|
||||||
|
|
||||||
|
self.light_source = info.get('light_source', False)
|
||||||
|
self.shininess = info.get('shininess', 0)
|
||||||
|
self.type = info.get('type', 'planet')
|
||||||
|
|
||||||
|
self.texture = get_best_texture(info['texture'])
|
||||||
|
self.normal_texture = None
|
||||||
|
self.specular_texture = None
|
||||||
|
self.emission_texture = None
|
||||||
|
|
||||||
|
self.sphere = self._get_sphere(division, tangent=self.type == 'planet')
|
||||||
|
self.vao = VAO()
|
||||||
|
|
||||||
|
if self.type == 'planet':
|
||||||
|
shader = self.world.activate_shader('planet')
|
||||||
|
with self.vao:
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, self.sphere.vbo)
|
||||||
|
shader.vertex_attribute('a_normal', self.sphere.direction_size, self.sphere.type, GL_FALSE,
|
||||||
|
self.sphere.stride, self.sphere.direction_offset)
|
||||||
|
shader.vertex_attribute('a_tangent', self.sphere.tangent_size, self.sphere.type, GL_FALSE,
|
||||||
|
self.sphere.stride, self.sphere.tangent_offset)
|
||||||
|
shader.vertex_attribute('a_uv', self.sphere.uv_size, self.sphere.type, GL_FALSE,
|
||||||
|
self.sphere.stride, self.sphere.uv_offset)
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
|
elif self.type == 'star':
|
||||||
|
shader = self.world.activate_shader('star')
|
||||||
|
with self.vao:
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, self.sphere.vbo)
|
||||||
|
shader.vertex_attribute('a_normal', self.sphere.direction_size, self.sphere.type, GL_FALSE,
|
||||||
|
self.sphere.stride, self.sphere.direction_offset)
|
||||||
|
shader.vertex_attribute('a_uv', self.sphere.uv_size, self.sphere.type, GL_FALSE,
|
||||||
|
self.sphere.stride, self.sphere.uv_offset)
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
|
else:
|
||||||
|
raise ValueError('Invalid type: %s' % self.type)
|
||||||
|
|
||||||
|
self.atmosphere = None
|
||||||
|
self.clouds = None
|
||||||
|
self.ring = 0
|
||||||
|
|
||||||
|
if 'normal_map' in info:
|
||||||
|
self.normal_texture = get_best_texture(info['normal_map'])
|
||||||
|
|
||||||
|
if 'specular_map' in info:
|
||||||
|
self.specular_texture = get_best_texture(info['specular_map'])
|
||||||
|
|
||||||
|
if 'emission_map' in info:
|
||||||
|
self.emission_texture = get_best_texture(info['emission_map'])
|
||||||
|
|
||||||
|
if 'atmosphere' in info:
|
||||||
|
atmosphere_data = info['atmosphere']
|
||||||
|
atm_size = world.evaluate(atmosphere_data.get('glow_size', None))
|
||||||
|
atm_texture = atmosphere_data.get('glow_texture', None)
|
||||||
|
atm_color = atmosphere_data.get('glow_color', None)
|
||||||
|
cloud_texture = atmosphere_data.get('cloud_texture', None)
|
||||||
|
if cloud_texture is not None:
|
||||||
|
self.cloud_transparency = get_best_texture(cloud_texture, loader=load_alpha_mask)
|
||||||
|
self.cloud_radius = self.radius + 2
|
||||||
|
self.clouds = self._get_sphere(division, tangent=False)
|
||||||
|
self.cloud_vao = VAO()
|
||||||
|
shader = self.world.activate_shader('clouds')
|
||||||
|
with self.cloud_vao:
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, self.clouds.vbo)
|
||||||
|
shader.vertex_attribute('a_normal', self.clouds.direction_size, self.clouds.type, GL_FALSE,
|
||||||
|
self.clouds.stride, self.clouds.direction_offset)
|
||||||
|
shader.vertex_attribute('a_uv', self.clouds.uv_size, self.clouds.type, GL_FALSE,
|
||||||
|
self.clouds.stride, self.clouds.uv_offset)
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
|
|
||||||
|
if atm_texture is not None and atm_color is not None:
|
||||||
|
self.atm_texture = load_texture_1d(atm_texture, clamp=True)
|
||||||
|
self.atm_color = atm_color
|
||||||
|
self.atmosphere = Disk(self.radius, self.radius + atm_size, 30)
|
||||||
|
self.atmosphere_vao = VAO()
|
||||||
|
shader = self.world.activate_shader('atmosphere')
|
||||||
|
with self.atmosphere_vao:
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, self.atmosphere.vbo)
|
||||||
|
shader.vertex_attribute('a_position', self.atmosphere.position_size, self.atmosphere.type, GL_FALSE,
|
||||||
|
self.atmosphere.stride, self.atmosphere.position_offset)
|
||||||
|
shader.vertex_attribute('a_u', self.atmosphere.u_size, self.atmosphere.type, GL_FALSE,
|
||||||
|
self.atmosphere.stride, self.atmosphere.u_offset)
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
|
|
||||||
|
if 'ring' in info:
|
||||||
|
distance = world.evaluate(info['ring'].get('distance', self.radius * 1.2))
|
||||||
|
size = world.evaluate(info['ring'].get('size', self.radius / 2))
|
||||||
|
|
||||||
|
pitch, yaw, roll = self.rotation
|
||||||
|
pitch = world.evaluate(info['ring'].get('pitch', pitch))
|
||||||
|
yaw = world.evaluate(info['ring'].get('yaw', yaw))
|
||||||
|
roll = world.evaluate(info['ring'].get('roll', roll))
|
||||||
|
self.ring_rotation = pitch, yaw, roll
|
||||||
|
|
||||||
|
self.ring_texture = load_texture_1d(info['ring'].get('texture'), clamp=True)
|
||||||
|
self.ring = Disk(distance, distance + size, 30)
|
||||||
|
|
||||||
|
self.ring_vao = VAO()
|
||||||
|
shader = self.world.activate_shader('ring')
|
||||||
|
with self.ring_vao:
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, self.ring.vbo)
|
||||||
|
shader.vertex_attribute('a_position', self.ring.position_size, self.ring.type, GL_FALSE,
|
||||||
|
self.ring.stride, self.ring.position_offset)
|
||||||
|
shader.vertex_attribute('a_u', self.ring.u_size, self.ring.type, GL_FALSE,
|
||||||
|
self.ring.stride, self.ring.u_offset)
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
|
|
||||||
|
def _draw_planet(self):
|
||||||
|
shader = self.world.activate_shader('planet')
|
||||||
|
shader.uniform_float('u_radius', self.radius)
|
||||||
|
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
|
||||||
|
shader.uniform_mat4('u_mvMatrix', self.mv_matrix)
|
||||||
|
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, self.texture)
|
||||||
|
shader.uniform_texture('u_planet.diffuseMap', 0)
|
||||||
|
|
||||||
|
shader.uniform_bool('u_planet.hasNormal', self.normal_texture)
|
||||||
|
if self.normal_texture:
|
||||||
|
glActiveTexture(GL_TEXTURE1)
|
||||||
|
glBindTexture(GL_TEXTURE_2D, self.normal_texture)
|
||||||
|
shader.uniform_texture('u_planet.normalMap', 1)
|
||||||
|
|
||||||
|
shader.uniform_bool('u_planet.hasSpecular', self.specular_texture)
|
||||||
|
if self.specular_texture:
|
||||||
|
glActiveTexture(GL_TEXTURE2)
|
||||||
|
glBindTexture(GL_TEXTURE_2D, self.specular_texture)
|
||||||
|
shader.uniform_texture('u_planet.specularMap', 2)
|
||||||
|
shader.uniform_vec3('u_planet.specular', 1, 1, 1)
|
||||||
|
shader.uniform_float('u_planet.shininess', 10)
|
||||||
|
else:
|
||||||
|
shader.uniform_vec3('u_planet.specular', 0, 0, 0)
|
||||||
|
shader.uniform_float('u_planet.shininess', 0)
|
||||||
|
|
||||||
|
shader.uniform_bool('u_planet.hasEmission', self.emission_texture)
|
||||||
|
if self.emission_texture:
|
||||||
|
glActiveTexture(GL_TEXTURE3)
|
||||||
|
glBindTexture(GL_TEXTURE_2D, self.emission_texture)
|
||||||
|
shader.uniform_texture('u_planet.emissionMap', 3)
|
||||||
|
shader.uniform_vec3('u_planet.ambient', 0, 0, 0)
|
||||||
|
shader.uniform_vec3('u_planet.emission', 1, 1, 1)
|
||||||
|
else:
|
||||||
|
shader.uniform_vec3('u_planet.ambient', 1, 1, 1)
|
||||||
|
shader.uniform_vec3('u_planet.emission', 0, 0, 0)
|
||||||
|
|
||||||
|
shader.uniform_vec3('u_planet.diffuse', 1, 1, 1)
|
||||||
|
|
||||||
|
with self.vao:
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, self.sphere.vertex_count)
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0)
|
||||||
|
|
||||||
|
def _draw_star(self):
|
||||||
|
shader = self.world.activate_shader('star')
|
||||||
|
shader.uniform_float('u_radius', self.radius)
|
||||||
|
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, self.texture)
|
||||||
|
shader.uniform_texture('u_emission', 0)
|
||||||
|
|
||||||
|
with self.vao:
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, self.sphere.vertex_count)
|
||||||
|
|
||||||
|
def _draw_sphere(self):
|
||||||
|
if self.type == 'planet':
|
||||||
|
self._draw_planet()
|
||||||
|
elif self.type == 'star':
|
||||||
|
self._draw_star()
|
||||||
|
|
||||||
|
def _draw_atmosphere(self):
|
||||||
|
glEnable(GL_BLEND)
|
||||||
|
glDisable(GL_CULL_FACE)
|
||||||
|
shader = self.world.activate_shader('atmosphere')
|
||||||
|
|
||||||
|
mv = self.mv_matrix.matrix
|
||||||
|
matrix = Matrix4f([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, mv[12], mv[13], mv[14], 1])
|
||||||
|
shader.uniform_mat4('u_mvpMatrix', self.world.projection_matrix() * matrix)
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_1D, self.atm_texture)
|
||||||
|
shader.uniform_texture('u_transparency', 0)
|
||||||
|
shader.uniform_vec3('u_color', *self.atm_color)
|
||||||
|
|
||||||
|
with self.atmosphere_vao:
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, self.atmosphere.vertex_count)
|
||||||
|
|
||||||
|
glDisable(GL_BLEND)
|
||||||
|
glEnable(GL_CULL_FACE)
|
||||||
|
|
||||||
|
def _draw_clouds(self):
|
||||||
|
glEnable(GL_BLEND)
|
||||||
|
shader = self.world.activate_shader('clouds')
|
||||||
|
shader.uniform_float('u_radius', self.cloud_radius)
|
||||||
|
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
|
||||||
|
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, self.cloud_transparency)
|
||||||
|
shader.uniform_texture('u_transparency', 0)
|
||||||
|
shader.uniform_vec3('u_diffuse', 1, 1, 1)
|
||||||
|
shader.uniform_vec3('u_ambient', 0.1, 0.1, 0.1)
|
||||||
|
|
||||||
|
with self.cloud_vao:
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, self.clouds.vertex_count)
|
||||||
|
|
||||||
|
glDisable(GL_BLEND)
|
||||||
|
|
||||||
|
def _draw_rings(self):
|
||||||
|
glEnable(GL_BLEND)
|
||||||
|
glDisable(GL_CULL_FACE)
|
||||||
|
shader = self.world.activate_shader('ring')
|
||||||
|
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
|
||||||
|
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
|
||||||
|
shader.uniform_vec3('u_planet', *self.location)
|
||||||
|
shader.uniform_vec3('u_sun', 0, 0, 0)
|
||||||
|
shader.uniform_float('u_planetRadius', self.radius)
|
||||||
|
shader.uniform_float('u_ambient', 0.1)
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_1D, self.ring_texture)
|
||||||
|
shader.uniform_texture('u_texture', 0)
|
||||||
|
|
||||||
|
with self.ring_vao:
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, self.ring.vertex_count)
|
||||||
|
|
||||||
|
glDisable(GL_BLEND)
|
||||||
|
glEnable(GL_CULL_FACE)
|
||||||
|
|
||||||
|
def _draw(self, options):
|
||||||
|
self._draw_sphere()
|
||||||
|
|
||||||
|
if options.atmosphere and self.atmosphere:
|
||||||
|
self._draw_atmosphere()
|
||||||
|
|
||||||
|
if options.cloud and self.clouds:
|
||||||
|
self._draw_clouds()
|
||||||
|
|
||||||
|
if self.ring:
|
||||||
|
self._draw_rings()
|
||||||
|
|
||||||
|
def _collides(self, x, y, z):
|
||||||
|
ox, oy, oz = self.location
|
||||||
|
dx, dy, dz = x - ox, y - oy, z - oz
|
||||||
|
distance = sqrt(dx * dx + dy * dy + dz * dz)
|
||||||
|
return distance <= self.radius
|
||||||
|
|
||||||
|
|
||||||
|
class ModelBody(Body):
|
||||||
|
def __init__(self, name, world, info, parent=None):
|
||||||
|
super(ModelBody, self).__init__(name, world, info, parent)
|
||||||
|
|
||||||
|
scale = info.get('scale', 1)
|
||||||
|
shader = world.activate_shader('model')
|
||||||
|
self.vbo = WavefrontVBO(load_model(info['model']), shader, info.get('sx', scale),
|
||||||
|
info.get('sy', scale), info.get('sz', scale))
|
||||||
|
|
||||||
|
def _draw(self, options):
|
||||||
|
shader = self.world.activate_shader('model')
|
||||||
|
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
|
||||||
|
shader.uniform_mat4('u_mvMatrix', self.mv_matrix)
|
||||||
|
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
|
||||||
|
self.vbo.draw(shader)
|
349
punyverse/glgeom.py
Normal file
|
@ -0,0 +1,349 @@
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
|
from array import array
|
||||||
|
from ctypes import c_int, c_float, byref, cast, POINTER, c_uint, c_short, c_ushort
|
||||||
|
from math import *
|
||||||
|
from random import random, gauss, choice
|
||||||
|
|
||||||
|
from pyglet.gl import *
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
|
from six.moves import range
|
||||||
|
|
||||||
|
TWOPI = pi * 2
|
||||||
|
|
||||||
|
__all__ = ['FontEngine', 'Matrix4f', 'Disk', 'OrbitVBO', 'SimpleSphere',
|
||||||
|
'TangentSphere', 'Cube', 'Circle', 'BeltVBO', 'VAO']
|
||||||
|
|
||||||
|
|
||||||
|
def array_to_ctypes(arr):
|
||||||
|
return cast(arr.buffer_info()[0], POINTER({
|
||||||
|
'f': c_float,
|
||||||
|
'i': c_int,
|
||||||
|
'I': c_uint,
|
||||||
|
'h': c_short,
|
||||||
|
'H': c_ushort,
|
||||||
|
}[arr.typecode]))
|
||||||
|
|
||||||
|
|
||||||
|
def array_to_gl_buffer(buffer):
|
||||||
|
vbo = c_uint()
|
||||||
|
glGenBuffers(1, byref(vbo))
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vbo.value)
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, buffer.itemsize * len(buffer), array_to_ctypes(buffer), GL_STATIC_DRAW)
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
|
return vbo.value
|
||||||
|
|
||||||
|
|
||||||
|
def list_to_gl_buffer(buffer, array_type='f'):
|
||||||
|
return array_to_gl_buffer(array(array_type, buffer))
|
||||||
|
|
||||||
|
|
||||||
|
class Matrix4f(object):
|
||||||
|
def __init__(self, matrix):
|
||||||
|
self.matrix = array('f', matrix)
|
||||||
|
assert len(self.matrix) == 16
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_angles(cls, location=(0, 0, 0), rotation=(0, 0, 0), view=False):
|
||||||
|
m = [0] * 16
|
||||||
|
x, y, z = location
|
||||||
|
pitch, yaw, roll = rotation
|
||||||
|
sp, sy, sr = sin(radians(pitch)), sin(radians(yaw)), sin(radians(roll))
|
||||||
|
cp, cy, cr = cos(radians(pitch)), cos(radians(yaw)), cos(radians(roll))
|
||||||
|
|
||||||
|
m[0x0] = cy * cr
|
||||||
|
m[0x1] = sp * sy * cr + cp * sr
|
||||||
|
m[0x2] = sp * sr - cp * sy * cr
|
||||||
|
m[0x3] = 0
|
||||||
|
m[0x4] = -cy * sr
|
||||||
|
m[0x5] = cp * cr - sp * sy * sr
|
||||||
|
m[0x6] = cp * sy * sr + sp * cr
|
||||||
|
m[0x7] = 0
|
||||||
|
m[0x8] = sy
|
||||||
|
m[0x9] = -sp * cy
|
||||||
|
m[0xA] = cp * cy
|
||||||
|
m[0xB] = 0
|
||||||
|
if view:
|
||||||
|
m[0xC] = m[0x0] * -x + m[0x4] * -y + m[0x8] * -z
|
||||||
|
m[0xD] = m[0x1] * -x + m[0x5] * -y + m[0x9] * -z
|
||||||
|
m[0xE] = m[0x2] * -x + m[0x6] * -y + m[0xA] * -z
|
||||||
|
else:
|
||||||
|
m[0xC] = x
|
||||||
|
m[0xD] = y
|
||||||
|
m[0xE] = z
|
||||||
|
m[0xF] = 1
|
||||||
|
return cls(m)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _as_parameter_(self):
|
||||||
|
return array_to_ctypes(self.matrix)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def bytes(self):
|
||||||
|
return self.matrix.itemsize * 16
|
||||||
|
|
||||||
|
def __mul__(self, other):
|
||||||
|
if not isinstance(other, Matrix4f):
|
||||||
|
return NotImplemented
|
||||||
|
|
||||||
|
rows = ((0, 4, 8, 12), (1, 5, 9, 13), (2, 6, 10, 14), (3, 7, 11, 15))
|
||||||
|
cols = ((0, 1, 2, 3), (4, 5, 6, 7), (8, 9, 10, 11), (12, 13, 14, 15))
|
||||||
|
a, b = self.matrix, other.matrix
|
||||||
|
return type(self)(sum(a[i] * b[j] for i, j in zip(r, c)) for c in cols for r in rows)
|
||||||
|
|
||||||
|
|
||||||
|
class Circle(object):
|
||||||
|
type = GL_FLOAT
|
||||||
|
stride = 2 * 4
|
||||||
|
position_offset = 0
|
||||||
|
position_size = 2
|
||||||
|
|
||||||
|
def __init__(self, r, segs, shader):
|
||||||
|
self.vertex_count = segs
|
||||||
|
buffer = segs * 2 * [0]
|
||||||
|
delta = 2 * pi / segs
|
||||||
|
for i in range(segs):
|
||||||
|
theta = delta * i
|
||||||
|
buffer[2*i:2*i+2] = [cos(theta) * r, sin(theta) * r]
|
||||||
|
self.vbo = list_to_gl_buffer(buffer)
|
||||||
|
|
||||||
|
self.vao = VAO()
|
||||||
|
with self.vao:
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, self.vbo)
|
||||||
|
shader.vertex_attribute('a_position', self.position_size, self.type, GL_FALSE,
|
||||||
|
self.stride, self.position_offset)
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
|
|
||||||
|
|
||||||
|
class Disk(object):
|
||||||
|
type = GL_FLOAT
|
||||||
|
stride = 3 * 4
|
||||||
|
position_offset = 0
|
||||||
|
position_size = 2
|
||||||
|
u_offset = position_size * 4
|
||||||
|
u_size = 1
|
||||||
|
|
||||||
|
def __init__(self, rinner, router, segs):
|
||||||
|
res = segs * 5
|
||||||
|
delta = 2 * pi / res
|
||||||
|
self.vertex_count = (res + 1) * 2
|
||||||
|
# Need padding to make the last vertex render correctly... why?
|
||||||
|
buffer = self.vertex_count * 3 * [0]
|
||||||
|
for i in range(res):
|
||||||
|
theta = delta * i
|
||||||
|
x, y = cos(theta), sin(theta)
|
||||||
|
buffer[6*i:6*i+6] = [rinner * x, rinner * y, 0, router * x, router * y, 1]
|
||||||
|
buffer[6*res:6*res+6] = buffer[:6]
|
||||||
|
self.vbo = list_to_gl_buffer(buffer)
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleSphere(object):
|
||||||
|
type = GL_FLOAT
|
||||||
|
stride = 5 * 4
|
||||||
|
direction_offset = 0
|
||||||
|
direction_size = 3
|
||||||
|
uv_offset = direction_size * 4
|
||||||
|
uv_size = 2
|
||||||
|
|
||||||
|
def __init__(self, lats, longs):
|
||||||
|
tau = pi * 2
|
||||||
|
phi_div = tau / longs
|
||||||
|
theta_div = pi / lats
|
||||||
|
|
||||||
|
self.vertex_count = (lats + 1) * (longs + 1) * 2
|
||||||
|
buffer = self.vertex_count * 5 * [0]
|
||||||
|
index = 0
|
||||||
|
reverse = False
|
||||||
|
for i in range(longs + 1):
|
||||||
|
phi1, phi2 = i * phi_div, (i + 1) * phi_div
|
||||||
|
if reverse:
|
||||||
|
phi1, phi2 = phi2, phi1
|
||||||
|
for j in range(lats + 1):
|
||||||
|
theta = j * theta_div
|
||||||
|
if reverse:
|
||||||
|
theta = pi - theta
|
||||||
|
sine = sin(theta)
|
||||||
|
dz = cos(theta)
|
||||||
|
t = 1 - theta / pi
|
||||||
|
buffer[index:index + 10] = [sine * cos(phi2), sine * sin(phi2), dz, phi2 / tau, t,
|
||||||
|
sine * cos(phi1), sine * sin(phi1), dz, phi1 / tau, t]
|
||||||
|
index += 10
|
||||||
|
reverse ^= True
|
||||||
|
|
||||||
|
self.vbo = list_to_gl_buffer(buffer)
|
||||||
|
|
||||||
|
|
||||||
|
class TangentSphere(object):
|
||||||
|
type = GL_FLOAT
|
||||||
|
stride = 7 * 4
|
||||||
|
direction_offset = 0
|
||||||
|
direction_size = 3
|
||||||
|
tangent_offset = direction_size * 4
|
||||||
|
tangent_size = 2
|
||||||
|
uv_offset = tangent_offset + tangent_size * 4
|
||||||
|
uv_size = 2
|
||||||
|
|
||||||
|
def __init__(self, lats, longs):
|
||||||
|
tau = pi * 2
|
||||||
|
phi_div = tau / longs
|
||||||
|
theta_div = pi / lats
|
||||||
|
|
||||||
|
self.vertex_count = (lats + 1) * (longs + 1) * 2
|
||||||
|
buffer = self.vertex_count * 8 * [0]
|
||||||
|
index = 0
|
||||||
|
reverse = False
|
||||||
|
for i in range(longs + 1):
|
||||||
|
phi1, phi2 = i * phi_div, (i + 1) * phi_div
|
||||||
|
if reverse:
|
||||||
|
phi1, phi2 = phi2, phi1
|
||||||
|
for j in range(lats + 1):
|
||||||
|
theta = j * theta_div
|
||||||
|
if reverse:
|
||||||
|
theta = pi - theta
|
||||||
|
sine = sin(theta)
|
||||||
|
dz = cos(theta)
|
||||||
|
t = 1 - theta / pi
|
||||||
|
sphi2, cphi2 = sin(phi2), cos(phi2)
|
||||||
|
sphi1, cphi1 = sin(phi1), cos(phi1)
|
||||||
|
buffer[index:index + 14] = [
|
||||||
|
sine * cphi2, sine * sphi2, dz, sine * -sphi2, sine * cphi2, phi2 / tau, t,
|
||||||
|
sine * cphi1, sine * sphi1, dz, sine * -sphi1, sine * cphi1, phi1 / tau, t,
|
||||||
|
]
|
||||||
|
index += 14
|
||||||
|
reverse ^= True
|
||||||
|
self.vbo = list_to_gl_buffer(buffer)
|
||||||
|
|
||||||
|
|
||||||
|
class Cube(object):
|
||||||
|
type = GL_SHORT
|
||||||
|
stride = 3 * 2
|
||||||
|
direction_offset = 0
|
||||||
|
direction_size = 3
|
||||||
|
vertex_count = 36
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.vbo = list_to_gl_buffer([
|
||||||
|
-1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1,
|
||||||
|
-1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1,
|
||||||
|
-1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1
|
||||||
|
], 'h')
|
||||||
|
|
||||||
|
|
||||||
|
class OrbitVBO(object):
|
||||||
|
type = GL_FLOAT
|
||||||
|
stride = 3 * 4
|
||||||
|
position_offset = 0
|
||||||
|
position_size = 3
|
||||||
|
vertex_count = 360
|
||||||
|
|
||||||
|
def __init__(self, orbit):
|
||||||
|
buffer = 360 * 3 * [0]
|
||||||
|
for theta in range(360):
|
||||||
|
x, z, y = orbit.orbit(theta)
|
||||||
|
buffer[3*theta:3*theta+3] = [x, y, z]
|
||||||
|
|
||||||
|
self.vbo = list_to_gl_buffer(buffer)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if self.vbo is not None:
|
||||||
|
vbo = c_uint(self.vbo)
|
||||||
|
glDeleteBuffers(1, byref(vbo))
|
||||||
|
self.vbo = None
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
|
||||||
|
class FontEngine(object):
|
||||||
|
type = GL_SHORT
|
||||||
|
stride = 4 * 2
|
||||||
|
position_offset = 0
|
||||||
|
position_size = 2
|
||||||
|
tex_offset = position_size * 2
|
||||||
|
tex_size = 2
|
||||||
|
|
||||||
|
def __init__(self, shader, max_length=256):
|
||||||
|
self.storage = array('h', max_length * 24 * [0])
|
||||||
|
vbo = GLuint()
|
||||||
|
glGenBuffers(1, byref(vbo))
|
||||||
|
self.vbo = vbo.value
|
||||||
|
self.vertex_count = None
|
||||||
|
|
||||||
|
self.vao = VAO()
|
||||||
|
with self.vao:
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, self.vbo)
|
||||||
|
shader.vertex_attribute('a_rc', self.position_size, self.type, GL_FALSE,
|
||||||
|
self.stride, self.position_offset)
|
||||||
|
shader.vertex_attribute('a_tex', self.tex_size, self.type, GL_FALSE,
|
||||||
|
self.stride, self.tex_offset)
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
|
|
||||||
|
def draw(self, string):
|
||||||
|
index = 0
|
||||||
|
row = 0
|
||||||
|
col = 0
|
||||||
|
for c in string:
|
||||||
|
if c == '\n':
|
||||||
|
row += 1
|
||||||
|
col = 0
|
||||||
|
continue
|
||||||
|
o = ord(c)
|
||||||
|
if 32 <= o < 128:
|
||||||
|
self.storage[24*index:24*index+24] = array('h', [
|
||||||
|
row, col, o - 32, 1,
|
||||||
|
row + 1, col, o - 32, 0,
|
||||||
|
row + 1, col + 1, o - 31, 0,
|
||||||
|
row, col, o - 32, 1,
|
||||||
|
row + 1, col + 1, o - 31, 0,
|
||||||
|
row, col + 1, o - 31, 1,
|
||||||
|
])
|
||||||
|
index += 1
|
||||||
|
col += 1
|
||||||
|
|
||||||
|
self.vertex_count = index * 6
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, self.vbo)
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, self.storage.itemsize * len(self.storage),
|
||||||
|
array_to_ctypes(self.storage), GL_STREAM_DRAW)
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
|
|
||||||
|
|
||||||
|
class BeltVBO(object):
|
||||||
|
type = GL_FLOAT
|
||||||
|
stride = 4 * 4
|
||||||
|
location_offset = 0
|
||||||
|
location_size = 3
|
||||||
|
scale_offset = location_size * 4
|
||||||
|
scale_size = 1
|
||||||
|
|
||||||
|
def __init__(self, radius, cross, objects, count):
|
||||||
|
arrays = [array('f') for i in range(objects)]
|
||||||
|
|
||||||
|
for i in range(count):
|
||||||
|
theta = TWOPI * random()
|
||||||
|
r = gauss(radius, cross)
|
||||||
|
x, y, z = cos(theta) * r, gauss(0, cross), sin(theta) * r
|
||||||
|
scale = gauss(1, 0.5)
|
||||||
|
if scale < 0:
|
||||||
|
scale = 1
|
||||||
|
choice(arrays).extend((x, y, z, scale))
|
||||||
|
|
||||||
|
self.vbo = []
|
||||||
|
self.sizes = []
|
||||||
|
for a in arrays:
|
||||||
|
self.vbo.append(array_to_gl_buffer(a))
|
||||||
|
self.sizes.append(len(a) // 4)
|
||||||
|
|
||||||
|
|
||||||
|
class VAO(object):
|
||||||
|
def __init__(self):
|
||||||
|
buffer = GLuint()
|
||||||
|
glGenVertexArrays(1, byref(buffer))
|
||||||
|
self.vao = buffer
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
glBindVertexArray(self.vao)
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
|
glBindVertexArray(0)
|
9
punyverse/glwrapper.h
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
# include <OpenGL/gl.h>
|
||||||
|
#else
|
||||||
|
# include <GL/gl.h>
|
||||||
|
#endif
|
28
punyverse/launcher.c
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <Python.h>
|
||||||
|
|
||||||
|
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
|
||||||
|
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 0x00000001;
|
||||||
|
|
||||||
|
#ifdef GUI
|
||||||
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||||
|
#else
|
||||||
|
int main()
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#if PY_MAJOR_VERSION >= 3
|
||||||
|
int argc;
|
||||||
|
LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||||
|
#else
|
||||||
|
int argc = __argc;
|
||||||
|
char **argv = __argv;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Py_SetProgramName(argv[0]);
|
||||||
|
Py_Initialize();
|
||||||
|
PySys_SetArgvEx(argc, argv, 0);
|
||||||
|
PyRun_SimpleString("from punyverse.main import main; main()");
|
||||||
|
Py_Finalize();
|
||||||
|
return 0;
|
||||||
|
}
|
31
punyverse/launcher.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if os.name != 'nt':
|
||||||
|
print('Not on Windows. Nothing to do.')
|
||||||
|
return
|
||||||
|
|
||||||
|
source_dir = os.path.dirname(__file__)
|
||||||
|
dest_dir = os.path.join(sys.prefix, 'Scripts')
|
||||||
|
|
||||||
|
launcher_exe = os.path.join(source_dir, 'launcher.exe')
|
||||||
|
launcherw_exe = os.path.join(source_dir, 'launcherw.exe')
|
||||||
|
punyverse_exe = os.path.join(dest_dir, 'punyverse.exe')
|
||||||
|
punyversew_exe = os.path.join(dest_dir, 'punyversew.exe')
|
||||||
|
assert os.path.isfile(launcher_exe)
|
||||||
|
assert os.path.isfile(launcherw_exe)
|
||||||
|
assert os.path.isfile(punyverse_exe)
|
||||||
|
assert os.path.isfile(punyversew_exe)
|
||||||
|
|
||||||
|
def copy(src, dst):
|
||||||
|
print('Copying %s to %s...' % (src, dst))
|
||||||
|
shutil.copy(src, dst)
|
||||||
|
copy(launcher_exe, punyverse_exe)
|
||||||
|
copy(launcherw_exe, punyversew_exe)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
190
punyverse/loader.py
Normal file
|
@ -0,0 +1,190 @@
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
import pyglet
|
||||||
|
from pyglet.gl import *
|
||||||
|
from six.moves import zip_longest
|
||||||
|
|
||||||
|
from punyverse.world import World
|
||||||
|
|
||||||
|
|
||||||
|
class glContext(object):
|
||||||
|
def __init__(self, context):
|
||||||
|
self.new_context = context
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
self.old_context = get_current_context()
|
||||||
|
self.new_context.set_current()
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
|
self.old_context.set_current()
|
||||||
|
|
||||||
|
|
||||||
|
class glSection(object):
|
||||||
|
def __init__(self, type):
|
||||||
|
self.type = type
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
glBegin(self.type)
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
|
glEnd()
|
||||||
|
|
||||||
|
|
||||||
|
def progress_bar(x, y, width, height, filled):
|
||||||
|
glPushAttrib(GL_ENABLE_BIT)
|
||||||
|
glDisable(GL_TEXTURE_2D)
|
||||||
|
glDisable(GL_BLEND)
|
||||||
|
x1 = x
|
||||||
|
x2 = x + width
|
||||||
|
y1 = y
|
||||||
|
y2 = y - height
|
||||||
|
y3 = 0.65 * y1 + 0.35 * y2
|
||||||
|
y4 = 0.25 * y1 + 0.75 * y2
|
||||||
|
|
||||||
|
glColor3f(0.6, 0.6, 0.6)
|
||||||
|
with glSection(GL_LINE_LOOP):
|
||||||
|
glVertex2f(x1, y1)
|
||||||
|
glVertex2f(x1, y2)
|
||||||
|
glVertex2f(x2, y2)
|
||||||
|
glVertex2f(x2, y1)
|
||||||
|
|
||||||
|
x1 += 1
|
||||||
|
y1 -= 1
|
||||||
|
x2 = x + width * filled - 1
|
||||||
|
|
||||||
|
with glSection(GL_TRIANGLE_STRIP):
|
||||||
|
glColor3f(0.81, 1, 0.82)
|
||||||
|
glVertex2f(x1, y1)
|
||||||
|
glVertex2f(x2, y1)
|
||||||
|
glColor3f(0, 0.83, 0.16)
|
||||||
|
glVertex2f(x1, y3)
|
||||||
|
glVertex2f(x2, y3)
|
||||||
|
glVertex2f(x1, y4)
|
||||||
|
glVertex2f(x2, y4)
|
||||||
|
glColor3f(0.37, 0.92, 0.43)
|
||||||
|
glVertex2f(x1, y2)
|
||||||
|
glVertex2f(x2, y2)
|
||||||
|
glPopAttrib()
|
||||||
|
|
||||||
|
|
||||||
|
def get_context_info(context):
|
||||||
|
info = [' %-22s %s' % (key + ':', value)
|
||||||
|
for key, value in context.config.get_gl_attributes()]
|
||||||
|
info = ['%-30s %-30s' % group for group in
|
||||||
|
zip_longest(info[::2], info[1::2], fillvalue='')]
|
||||||
|
|
||||||
|
with glContext(context):
|
||||||
|
gl_info.remove_active_context()
|
||||||
|
gl_info.set_active_context()
|
||||||
|
return '\n'.join([
|
||||||
|
'Graphics Vendor: ' + gl_info.get_vendor(),
|
||||||
|
'Graphics Version: ' + gl_info.get_version(),
|
||||||
|
'Graphics Renderer: ' + gl_info.get_renderer(),
|
||||||
|
]) + '\n\n' + 'OpenGL configuration:\n' + '\n'.join(info)
|
||||||
|
|
||||||
|
|
||||||
|
class LoaderWindow(pyglet.window.Window):
|
||||||
|
MONOSPACE = ('Consolas', 'Droid Sans Mono', 'Courier', 'Courier New', 'Dejavu Sans Mono')
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(LoaderWindow, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
# work around pyglet bug: decoding font names as utf-8 instead of mbcs when using EnumFontsA.
|
||||||
|
stderr = sys.stderr
|
||||||
|
sys.stderr = open(os.devnull, 'w')
|
||||||
|
pyglet.font.have_font(self.MONOSPACE[0])
|
||||||
|
sys.stderr = stderr
|
||||||
|
|
||||||
|
self.loading_phase = pyglet.text.Label(
|
||||||
|
font_name=self.MONOSPACE, font_size=20, x=10, y=self.height - 50,
|
||||||
|
color=(255, 255, 255, 255), width=self.width - 20, align='center',
|
||||||
|
multiline=True, text='Punyverse is starting...'
|
||||||
|
)
|
||||||
|
self.loading_label = pyglet.text.Label(
|
||||||
|
font_name=self.MONOSPACE, font_size=16, x=10, y=self.height - 120,
|
||||||
|
color=(255, 255, 255, 255), width=self.width - 20, align='center',
|
||||||
|
multiline=True
|
||||||
|
)
|
||||||
|
self.info_label = pyglet.text.Label(
|
||||||
|
font_name=self.MONOSPACE, font_size=13, x=10, y=self.height - 220,
|
||||||
|
color=(255, 255, 255, 255), width=self.width - 20,
|
||||||
|
multiline=True
|
||||||
|
)
|
||||||
|
self.progress = 0
|
||||||
|
|
||||||
|
self._main_context = None
|
||||||
|
|
||||||
|
def set_main_context(self, context):
|
||||||
|
self._main_context = context
|
||||||
|
self.info_label.text = get_context_info(context)
|
||||||
|
print(self.info_label.text)
|
||||||
|
|
||||||
|
def _load_callback(self, phase, message, progress):
|
||||||
|
print(message)
|
||||||
|
with glContext(self.context):
|
||||||
|
self.loading_phase.text = phase
|
||||||
|
self.loading_label.text = message
|
||||||
|
self.progress = progress
|
||||||
|
|
||||||
|
self.on_draw()
|
||||||
|
self.flip()
|
||||||
|
self.dispatch_events()
|
||||||
|
|
||||||
|
def load(self, **kwargs):
|
||||||
|
start = time.clock()
|
||||||
|
with glContext(self._main_context):
|
||||||
|
world = World('world.json', self._load_callback, **kwargs)
|
||||||
|
print('Loaded in %s seconds.' % (time.clock() - start))
|
||||||
|
return world
|
||||||
|
|
||||||
|
def on_draw(self):
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT)
|
||||||
|
glLoadIdentity()
|
||||||
|
self.loading_phase.draw()
|
||||||
|
self.loading_label.draw()
|
||||||
|
progress_bar(10, self.height - 140, self.width - 20, 50, self.progress)
|
||||||
|
self.info_label.draw()
|
||||||
|
|
||||||
|
def main_is_initializing(self):
|
||||||
|
self._load_callback('Loading main window...', '', 0)
|
||||||
|
|
||||||
|
|
||||||
|
class LoaderConsole(object):
|
||||||
|
def __init__(self):
|
||||||
|
from ctypes import windll
|
||||||
|
self._own_console = False
|
||||||
|
if windll.kernel32.AllocConsole():
|
||||||
|
self._own_console = True
|
||||||
|
self._output = open('CONOUT$', 'w')
|
||||||
|
else:
|
||||||
|
self._output = sys.stdout
|
||||||
|
self._main_context = None
|
||||||
|
|
||||||
|
def _load_callback(self, phase, message, progress):
|
||||||
|
print(message, file=self._output)
|
||||||
|
|
||||||
|
def load(self, **kwargs):
|
||||||
|
start = time.clock()
|
||||||
|
with glContext(self._main_context):
|
||||||
|
world = World('world.json', self._load_callback, **kwargs)
|
||||||
|
print('Loaded in %s seconds.' % (time.clock() - start), file=self._output)
|
||||||
|
return world
|
||||||
|
|
||||||
|
def set_main_context(self, context):
|
||||||
|
self._main_context = context
|
||||||
|
print(get_context_info(context), file=self._output)
|
||||||
|
print('=' * 79, file=self._output)
|
||||||
|
print("You cannot see the normal loading screen because you are using Intel integrated graphics.",
|
||||||
|
file=self._output)
|
||||||
|
print('Please attempt to set python to execute with your dedicated graphics, if available.', file=self._output)
|
||||||
|
print('=' * 79, file=self._output)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if self._own_console:
|
||||||
|
self._output.close()
|
||||||
|
from ctypes import windll
|
||||||
|
windll.kernel32.FreeConsole()
|
87
punyverse/main.py
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pyglet
|
||||||
|
|
||||||
|
INITIAL_WIN_HEIGHT = 540
|
||||||
|
INITIAL_WIN_WIDTH = 700
|
||||||
|
DEBUG = False
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
macos = sys.platform == 'darwin'
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(prog='punyverse', description='''
|
||||||
|
Python simulator of a puny universe.
|
||||||
|
''')
|
||||||
|
parser.set_defaults(sky=not macos)
|
||||||
|
parser.add_argument('-D', '--debug', help='Enable pyglet OpenGL debugging', action='store_true')
|
||||||
|
parser.add_argument('-d', '--high-depth', help='Use a larger depth buffer',
|
||||||
|
const=32, default=24, dest='depth', nargs='?', type=int)
|
||||||
|
parser.add_argument('-m', '--multisample', help='Use multisampled image, optional samples',
|
||||||
|
const=2, default=0, nargs='?', type=int)
|
||||||
|
parser.add_argument('-v', '--no-vsync', help='Disables vsync',
|
||||||
|
action='store_false', dest='vsync')
|
||||||
|
parser.add_argument('-n', '--normal', help='Enables the use of normal maps',
|
||||||
|
action='store_true')
|
||||||
|
parser.add_argument('-s', '--sky', help='Enables the sky', dest='sky',
|
||||||
|
action='store_true')
|
||||||
|
parser.add_argument('-S', '--no-sky', help='Disables the sky', dest='sky',
|
||||||
|
action='store_false')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
versioning = dict(major_version=3, minor_version=3)
|
||||||
|
pyglet.options['debug_gl'] = args.debug
|
||||||
|
if macos:
|
||||||
|
pyglet.options['shadow_window'] = False
|
||||||
|
versioning = dict(major_version=4, minor_version=1, forward_compatible=True)
|
||||||
|
|
||||||
|
template = pyglet.gl.Config(depth_size=args.depth, double_buffer=True,
|
||||||
|
sample_buffers=args.multisample > 1,
|
||||||
|
samples=args.multisample, **versioning)
|
||||||
|
|
||||||
|
platform = pyglet.window.get_platform()
|
||||||
|
display = platform.get_default_display()
|
||||||
|
screen = display.get_default_screen()
|
||||||
|
try:
|
||||||
|
config = screen.get_best_config(template)
|
||||||
|
except pyglet.window.NoSuchConfigException:
|
||||||
|
raise SystemExit('Graphics configuration not supported.')
|
||||||
|
|
||||||
|
create_args = dict(width=INITIAL_WIN_WIDTH, height=INITIAL_WIN_HEIGHT,
|
||||||
|
caption='Punyverse', resizable=True, vsync=args.vsync, visible=False)
|
||||||
|
|
||||||
|
from pyglet.gl import gl_info
|
||||||
|
|
||||||
|
from punyverse.loader import LoaderWindow, LoaderConsole
|
||||||
|
from punyverse.ui import Punyverse
|
||||||
|
|
||||||
|
if pyglet.compat_platform in ('win32', 'cygwin') and gl_info.get_vendor() == 'Intel':
|
||||||
|
# pyglet has some code that tries to create without ARB on Intel.
|
||||||
|
# Of course, all that achieves is the message that you can't create OpenGL 3 contexts.
|
||||||
|
# So we force create an ARB context.
|
||||||
|
from pyglet.gl.win32 import Win32ARBContext
|
||||||
|
context = Win32ARBContext(config, None)
|
||||||
|
|
||||||
|
# We use the console loader since using the GUI loader makes all sorts of wonderful things happen on Intel:
|
||||||
|
# Access violations, mouse events going nowhere, you name it.
|
||||||
|
loader = LoaderConsole()
|
||||||
|
punyverse = Punyverse(context=context, **create_args)
|
||||||
|
else:
|
||||||
|
context = config.create_context(None)
|
||||||
|
loader = LoaderWindow(width=INITIAL_WIN_WIDTH, height=INITIAL_WIN_HEIGHT,
|
||||||
|
caption='Punyverse is loading...')
|
||||||
|
punyverse = Punyverse(context=context, **create_args)
|
||||||
|
loader.context.set_current()
|
||||||
|
|
||||||
|
loader.set_main_context(punyverse.context)
|
||||||
|
world = loader.load(sky=args.sky)
|
||||||
|
punyverse.context.set_current()
|
||||||
|
punyverse.initialize(world)
|
||||||
|
loader.close()
|
||||||
|
punyverse.set_visible(True)
|
||||||
|
pyglet.app.run()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
346
punyverse/model.py
Normal file
|
@ -0,0 +1,346 @@
|
||||||
|
import bz2
|
||||||
|
import gzip
|
||||||
|
import os
|
||||||
|
import zipfile
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
import six
|
||||||
|
from pyglet.gl import *
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
|
from six.moves import range, zip
|
||||||
|
|
||||||
|
from punyverse.glgeom import list_to_gl_buffer, VAO
|
||||||
|
from punyverse.texture import load_texture
|
||||||
|
|
||||||
|
|
||||||
|
def zip_open(file):
|
||||||
|
zip = zipfile.ZipFile(file)
|
||||||
|
return zip.open(zip.namelist()[0])
|
||||||
|
|
||||||
|
openers = {
|
||||||
|
'gz': gzip.open,
|
||||||
|
'bz2': bz2.BZ2File,
|
||||||
|
'zip': zip_open,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Face(object):
|
||||||
|
__slots__ = ('verts', 'norms', 'texs', 'size')
|
||||||
|
|
||||||
|
def __init__(self, verts, norms, texs):
|
||||||
|
self.verts = verts
|
||||||
|
self.norms = norms
|
||||||
|
self.texs = texs
|
||||||
|
self.size = len(verts)
|
||||||
|
|
||||||
|
|
||||||
|
class Material(object):
|
||||||
|
__slots__ = ('name', 'texture', 'Ka', 'Kd', 'Ks', 'shininess')
|
||||||
|
|
||||||
|
def __init__(self, name, texture=None, Ka=(0, 0, 0), Kd=(0, 0, 0), Ks=(0, 0, 0), shininess=0.0):
|
||||||
|
self.name = name
|
||||||
|
self.texture = texture
|
||||||
|
self.Ka = Ka
|
||||||
|
self.Kd = Kd
|
||||||
|
self.Ks = Ks
|
||||||
|
self.shininess = shininess
|
||||||
|
|
||||||
|
|
||||||
|
class Group(object):
|
||||||
|
__slots__ = ('material', 'faces')
|
||||||
|
|
||||||
|
def __init__(self, material=None, faces=None):
|
||||||
|
self.material = material
|
||||||
|
self.faces = faces or []
|
||||||
|
|
||||||
|
|
||||||
|
class WavefrontObject(object):
|
||||||
|
def __init__(self, path):
|
||||||
|
self.path = path
|
||||||
|
self.root = os.path.abspath(os.path.dirname(path))
|
||||||
|
self.vertices = []
|
||||||
|
self.normals = []
|
||||||
|
self.textures = []
|
||||||
|
self.groups = []
|
||||||
|
self.materials = {}
|
||||||
|
|
||||||
|
self.perform_io(self.path)
|
||||||
|
|
||||||
|
def new_material(self, words):
|
||||||
|
name = words[1].decode('utf-8')
|
||||||
|
material = Material(name)
|
||||||
|
self.materials[name] = material
|
||||||
|
self.current_material = material
|
||||||
|
|
||||||
|
def Ka(self, words):
|
||||||
|
self.current_material.Ka = (float(words[1]), float(words[2]), float(words[3]))
|
||||||
|
|
||||||
|
def Kd(self, words):
|
||||||
|
self.current_material.Kd = (float(words[1]), float(words[2]), float(words[3]))
|
||||||
|
|
||||||
|
def Ks(self, words):
|
||||||
|
self.current_material.Ks = (float(words[1]), float(words[2]), float(words[3]))
|
||||||
|
|
||||||
|
def material_shininess(self, words):
|
||||||
|
self.current_material.shininess = min(float(words[1]), 125)
|
||||||
|
|
||||||
|
def material_texture(self, words):
|
||||||
|
self.current_material.texture = words[-1].decode('utf-8')
|
||||||
|
|
||||||
|
def vertex(self, words):
|
||||||
|
self.vertices.append((float(words[1]), float(words[2]), float(words[3])))
|
||||||
|
|
||||||
|
def normal(self, words):
|
||||||
|
self.normals.append((float(words[1]), float(words[2]), float(words[3])))
|
||||||
|
|
||||||
|
def texture(self, words):
|
||||||
|
l = len(words)
|
||||||
|
u, v = 0, 0
|
||||||
|
if l >= 2:
|
||||||
|
u = float(words[1])
|
||||||
|
if l >= 3:
|
||||||
|
# OBJ origin is at upper left, OpenGL origin is at lower left
|
||||||
|
v = 1 - float(words[2])
|
||||||
|
self.textures.append((u, v))
|
||||||
|
|
||||||
|
def face(self, words):
|
||||||
|
l = len(words)
|
||||||
|
vertex_count = l - 1
|
||||||
|
|
||||||
|
vindices = []
|
||||||
|
nindices = []
|
||||||
|
tindices = []
|
||||||
|
|
||||||
|
for i in range(1, vertex_count + 1):
|
||||||
|
raw_faces = words[i].split(b'/')
|
||||||
|
l = len(raw_faces)
|
||||||
|
|
||||||
|
vindices.append(int(raw_faces[0]) - 1)
|
||||||
|
|
||||||
|
if l >= 2 and raw_faces[1]:
|
||||||
|
tindices.append(int(raw_faces[1]) - 1)
|
||||||
|
else:
|
||||||
|
tindices.append(None)
|
||||||
|
|
||||||
|
if l >= 3 and raw_faces[2]:
|
||||||
|
nindices.append(int(raw_faces[2]) - 1)
|
||||||
|
else:
|
||||||
|
nindices.append(None)
|
||||||
|
|
||||||
|
if self.current_group is None:
|
||||||
|
self.current_group = group = Group()
|
||||||
|
self.groups.append(group)
|
||||||
|
else:
|
||||||
|
group = self.current_group
|
||||||
|
|
||||||
|
group.faces.append(Face(vindices, nindices, tindices))
|
||||||
|
|
||||||
|
def material(self, words):
|
||||||
|
self.perform_io(os.path.join(self.root, words[1].decode('utf-8')))
|
||||||
|
|
||||||
|
def use_material(self, words):
|
||||||
|
mat = words[1].decode('utf-8')
|
||||||
|
try:
|
||||||
|
self.current_group.material = self.materials[mat]
|
||||||
|
except KeyError:
|
||||||
|
print("Warning: material %s undefined, only %s defined." % (mat, self.materials))
|
||||||
|
except AttributeError:
|
||||||
|
print("Warning: no group")
|
||||||
|
|
||||||
|
def group(self, words):
|
||||||
|
group = Group()
|
||||||
|
self.groups.append(group)
|
||||||
|
self.current_group = group
|
||||||
|
|
||||||
|
def perform_io(self, file):
|
||||||
|
ext = os.path.splitext(file)[1].lstrip('.')
|
||||||
|
reader = openers.get(ext, lambda x: open(x, 'rb'))(file)
|
||||||
|
|
||||||
|
dispatcher = {
|
||||||
|
b'v': self.vertex,
|
||||||
|
b'vn': self.normal,
|
||||||
|
b'vt': self.texture,
|
||||||
|
b'f': self.face,
|
||||||
|
b'mtllib': self.material,
|
||||||
|
b'usemtl': self.use_material,
|
||||||
|
b'g': self.group,
|
||||||
|
b'o': self.group,
|
||||||
|
b'newmtl': self.new_material,
|
||||||
|
b'Ka': self.Ka,
|
||||||
|
b'Kd': self.Kd,
|
||||||
|
b'Ks': self.Ks,
|
||||||
|
b'Ns': self.material_shininess,
|
||||||
|
b'map_Kd': self.material_texture,
|
||||||
|
}
|
||||||
|
default = lambda words: None
|
||||||
|
|
||||||
|
with reader:
|
||||||
|
for buf in reader:
|
||||||
|
if not buf or buf.startswith((b'\r', b'\n', b'#')):
|
||||||
|
continue # Empty or comment
|
||||||
|
words = buf.split()
|
||||||
|
type = words[0]
|
||||||
|
|
||||||
|
dispatcher.get(type, default)(words)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
model_base = os.path.join(os.path.dirname(__file__), 'assets', 'models')
|
||||||
|
|
||||||
|
|
||||||
|
def load_model(path):
|
||||||
|
if not os.path.isabs(path):
|
||||||
|
path = os.path.join(model_base, path)
|
||||||
|
if isinstance(path, six.binary_type):
|
||||||
|
path = path.decode('mbcs' if os.name == 'nt' else 'utf8')
|
||||||
|
return WavefrontObject(path)
|
||||||
|
|
||||||
|
|
||||||
|
class ModelVBO(object):
|
||||||
|
__slots__ = ('has_normal', 'has_texture', 'data_buf', 'index_buf', 'offset_type', 'vertex_count', 'vao')
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.vao = VAO()
|
||||||
|
|
||||||
|
def build_vao(self, shader):
|
||||||
|
stride = (3 + self.has_normal * 3 + self.has_texture * 2) * 4
|
||||||
|
|
||||||
|
with self.vao:
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, self.data_buf)
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self.index_buf)
|
||||||
|
|
||||||
|
shader.vertex_attribute('a_position', 3, GL_FLOAT, GL_FALSE, stride, 0)
|
||||||
|
if self.has_normal:
|
||||||
|
shader.vertex_attribute('a_normal', 3, GL_FLOAT, GL_FALSE, stride, 3 * 4)
|
||||||
|
if self.has_texture:
|
||||||
|
shader.vertex_attribute('a_uv', 2, GL_FLOAT, GL_FALSE, stride, (6 if self.has_normal else 3) * 4)
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
|
|
||||||
|
def draw(self, shader, instances=None):
|
||||||
|
with self.vao:
|
||||||
|
if not self.has_normal:
|
||||||
|
shader.vertex_attribute_vec3('a_normal', 0, 0, 0)
|
||||||
|
|
||||||
|
if not self.has_texture:
|
||||||
|
shader.vertex_attribute_vec2('a_uv', 0, 0)
|
||||||
|
if instances:
|
||||||
|
glDrawElementsInstanced(GL_TRIANGLES, self.vertex_count, self.offset_type, 0, instances)
|
||||||
|
else:
|
||||||
|
glDrawElements(GL_TRIANGLES, self.vertex_count, self.offset_type, 0)
|
||||||
|
|
||||||
|
|
||||||
|
class WavefrontVBO(object):
|
||||||
|
def __init__(self, model, shader, sx=1, sy=1, sz=1):
|
||||||
|
self._tex_cache = {}
|
||||||
|
self.vbos = []
|
||||||
|
self.scale = (sx, sy, sz)
|
||||||
|
|
||||||
|
for m, material in six.iteritems(model.materials):
|
||||||
|
if material.texture and material.texture not in self._tex_cache:
|
||||||
|
self._tex_cache[material.texture] = load_texture(os.path.join(model.root, material.texture))
|
||||||
|
|
||||||
|
vertices = model.vertices
|
||||||
|
textures = model.textures
|
||||||
|
normals = model.normals
|
||||||
|
|
||||||
|
for group in self.merge_groups(model):
|
||||||
|
processed = self.process_group(group, vertices, normals, textures)
|
||||||
|
self.vbos.append((group.material, processed))
|
||||||
|
processed.build_vao(shader)
|
||||||
|
|
||||||
|
def additional_attributes(self, callback):
|
||||||
|
for _, group in self.vbos:
|
||||||
|
with group.vao:
|
||||||
|
callback()
|
||||||
|
|
||||||
|
def draw(self, shader, instances=None):
|
||||||
|
for mat, vbo in self.vbos:
|
||||||
|
tex_id = self._tex_cache[mat.texture] if mat and mat.texture else 0
|
||||||
|
|
||||||
|
if tex_id:
|
||||||
|
glBindTexture(GL_TEXTURE_2D, tex_id)
|
||||||
|
shader.uniform_bool('u_material.hasDiffuse', True)
|
||||||
|
shader.uniform_texture('u_material.diffuseMap', 0)
|
||||||
|
else:
|
||||||
|
shader.uniform_bool('u_material.hasDiffuse', False)
|
||||||
|
|
||||||
|
if mat and mat.Ka:
|
||||||
|
shader.uniform_vec3('u_material.ambient', *mat.Ka)
|
||||||
|
else:
|
||||||
|
shader.uniform_vec3('u_material.ambient', 0.2, 0.2, 0.2)
|
||||||
|
|
||||||
|
if mat and mat.Kd:
|
||||||
|
shader.uniform_vec3('u_material.diffuse', *mat.Kd)
|
||||||
|
else:
|
||||||
|
shader.uniform_vec3('u_material.diffuse', 0.8, 0.8, 0.8)
|
||||||
|
|
||||||
|
if mat and mat.Ks:
|
||||||
|
shader.uniform_vec3('u_material.specular', *mat.Ks)
|
||||||
|
else:
|
||||||
|
shader.uniform_vec3('u_material.specular', 0, 0, 0)
|
||||||
|
|
||||||
|
if mat:
|
||||||
|
shader.uniform_float('u_material.shininess', mat.shininess)
|
||||||
|
else:
|
||||||
|
shader.uniform_float('u_material.shininess', 0)
|
||||||
|
|
||||||
|
vbo.draw(shader, instances=instances)
|
||||||
|
|
||||||
|
def merge_groups(self, model):
|
||||||
|
by_mat = defaultdict(list)
|
||||||
|
for g in model.groups:
|
||||||
|
if g.faces:
|
||||||
|
by_mat[g.material].append(g)
|
||||||
|
|
||||||
|
groups = []
|
||||||
|
for mat, gs in six.iteritems(by_mat):
|
||||||
|
faces = []
|
||||||
|
for g in gs:
|
||||||
|
faces += g.faces
|
||||||
|
groups.append(Group(mat, faces))
|
||||||
|
return groups
|
||||||
|
|
||||||
|
def process_group(self, group, vertices, normals, textures):
|
||||||
|
sx, sy, sz = self.scale
|
||||||
|
max_texture = len(textures)
|
||||||
|
has_texture = bool(textures) and any(any(n is not None for n in f.texs) for f in group.faces)
|
||||||
|
has_normal = bool(normals) and any(any(n is not None for n in f.norms) for f in group.faces)
|
||||||
|
buffer = []
|
||||||
|
indices = []
|
||||||
|
offsets = {}
|
||||||
|
|
||||||
|
for f in group.faces:
|
||||||
|
verts = []
|
||||||
|
for v, n, t in zip(f.verts, f.norms, f.texs):
|
||||||
|
# Blender defines texture coordinates on faces even without textures.
|
||||||
|
if t is not None and t >= max_texture:
|
||||||
|
t = None
|
||||||
|
if (v, n, t) in offsets:
|
||||||
|
verts.append(offsets[v, n, t])
|
||||||
|
else:
|
||||||
|
index = len(offsets)
|
||||||
|
verts.append(index)
|
||||||
|
x, y, z = vertices[v]
|
||||||
|
item = [sx * x, sy * y, sz * z]
|
||||||
|
if has_normal:
|
||||||
|
item += [0, 0, 0] if n is None else list(normals[n])
|
||||||
|
if has_texture:
|
||||||
|
item += [0, 0] if t is None else list(textures[t])
|
||||||
|
offsets[v, n, t] = index
|
||||||
|
buffer += item
|
||||||
|
|
||||||
|
for a, b in zip(verts[1:], verts[2:]):
|
||||||
|
indices += [verts[0], a, b]
|
||||||
|
|
||||||
|
result = ModelVBO()
|
||||||
|
result.has_normal = has_normal
|
||||||
|
result.has_texture = has_texture
|
||||||
|
result.offset_type = GL_UNSIGNED_SHORT if len(offsets) < 65536 else GL_UNSIGNED_INT
|
||||||
|
result.data_buf = list_to_gl_buffer(buffer, 'f')
|
||||||
|
result.index_buf = list_to_gl_buffer(indices, {
|
||||||
|
GL_UNSIGNED_SHORT: 'H',
|
||||||
|
GL_UNSIGNED_INT: 'I',
|
||||||
|
}[result.offset_type])
|
||||||
|
result.vertex_count = len(indices)
|
||||||
|
return result
|
96
punyverse/orbit.py
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
from math import sin, cos, tan, atan, sqrt, radians, degrees
|
||||||
|
|
||||||
|
|
||||||
|
class KeplerOrbit(object):
|
||||||
|
def __init__(self, sma, eccentricity, inclination=0, longitude=0, argument=0):
|
||||||
|
self.sma = sma
|
||||||
|
self.eccentricity = eccentricity
|
||||||
|
self.inclination = inclination
|
||||||
|
self.longitude = longitude
|
||||||
|
self.argument = argument
|
||||||
|
self.__true_anomaly_factor = sqrt((1 + eccentricity)/(1 - eccentricity))
|
||||||
|
self.__distance_factor = sma * (1 - eccentricity ** 2)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def inclination(self):
|
||||||
|
return degrees(self._inclination)
|
||||||
|
|
||||||
|
@inclination.setter
|
||||||
|
def inclination(self, value):
|
||||||
|
self.inclination_radian = radians(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def inclination_radian(self):
|
||||||
|
return self._inclination
|
||||||
|
|
||||||
|
@inclination_radian.setter
|
||||||
|
def inclination_radian(self, value):
|
||||||
|
self._inclination = value
|
||||||
|
self.__sin_inclination = sin(self._inclination)
|
||||||
|
self.__cos_inclination = cos(self._inclination)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def longitude(self):
|
||||||
|
return degrees(self._longitude)
|
||||||
|
|
||||||
|
@longitude.setter
|
||||||
|
def longitude(self, value):
|
||||||
|
self.longitude_radian = radians(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def longitude_radian(self):
|
||||||
|
return self._longitude
|
||||||
|
|
||||||
|
@longitude_radian.setter
|
||||||
|
def longitude_radian(self, value):
|
||||||
|
self._longitude = value
|
||||||
|
self.__sin_longitude = sin(self._longitude)
|
||||||
|
self.__cos_longitude = cos(self._longitude)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def argument(self):
|
||||||
|
return degrees(self._argument)
|
||||||
|
|
||||||
|
@argument.setter
|
||||||
|
def argument(self, value):
|
||||||
|
self.argument_radian = radians(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def argument_radian(self):
|
||||||
|
return self._argument
|
||||||
|
|
||||||
|
@argument_radian.setter
|
||||||
|
def argument_radian(self, value):
|
||||||
|
self._argument = value
|
||||||
|
self.__sin_argument = sin(self._argument)
|
||||||
|
self.__cos_argument = cos(self._argument)
|
||||||
|
|
||||||
|
def eccentric_anomaly(self, mean_anomaly):
|
||||||
|
e1 = 0
|
||||||
|
e2 = mean_anomaly
|
||||||
|
while abs(e1 - e2) > 0.000001:
|
||||||
|
e1, e2 = e2, e2 - ((e2 - mean_anomaly - self.eccentricity * sin(e2)) /
|
||||||
|
(1 - self.eccentricity * cos(e2)))
|
||||||
|
return e2
|
||||||
|
|
||||||
|
def true_anomaly(self, mean_anomaly):
|
||||||
|
eccentric_anomaly = self.eccentric_anomaly(mean_anomaly)
|
||||||
|
return 2 * atan(self.__true_anomaly_factor * tan(eccentric_anomaly / 2))
|
||||||
|
|
||||||
|
def orbit(self, mean_anomaly):
|
||||||
|
mean_anomaly = radians(mean_anomaly)
|
||||||
|
phi = self.true_anomaly(mean_anomaly)
|
||||||
|
r = self.__distance_factor / (1 + self.eccentricity * cos(phi))
|
||||||
|
x = r * cos(phi)
|
||||||
|
y = r * sin(phi)
|
||||||
|
z = 0
|
||||||
|
|
||||||
|
# phi = longitude, theta = inclination, psi = argument
|
||||||
|
x, y = (x * self.__cos_longitude + y * self.__sin_longitude,
|
||||||
|
-x * self.__sin_longitude + y * self.__cos_longitude)
|
||||||
|
x, z = (x * self.__cos_inclination + z * self.__sin_inclination,
|
||||||
|
-x * self.__sin_inclination + z * self.__cos_inclination)
|
||||||
|
x, y = (x * self.__cos_argument + y * self.__sin_argument,
|
||||||
|
-x * self.__sin_argument + y * self.__cos_argument)
|
||||||
|
|
||||||
|
return x, y, z
|
127
punyverse/shader.py
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from ctypes import pointer, byref, create_string_buffer, POINTER, cast
|
||||||
|
|
||||||
|
from pyglet.gl import *
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
|
from six.moves import range
|
||||||
|
|
||||||
|
SHADERS_DIR = os.path.join(os.path.dirname(__file__), 'shaders')
|
||||||
|
|
||||||
|
|
||||||
|
class CompileError(ValueError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class glShader(object):
|
||||||
|
def __init__(self, type):
|
||||||
|
self.type = type
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
self.shader = glCreateShader(self.type)
|
||||||
|
return self.shader
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
|
glDeleteShader(self.shader)
|
||||||
|
|
||||||
|
|
||||||
|
class Program(object):
|
||||||
|
@classmethod
|
||||||
|
def load_file(cls, file):
|
||||||
|
with open(os.path.join(SHADERS_DIR, file), 'rb') as f:
|
||||||
|
return f.read()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def compile_shader(cls, shader, source):
|
||||||
|
buffer = create_string_buffer(source)
|
||||||
|
glShaderSource(shader, 1, cast(pointer(pointer(buffer)), POINTER(POINTER(GLchar))), None)
|
||||||
|
glCompileShader(shader)
|
||||||
|
|
||||||
|
succeeded = GLint()
|
||||||
|
log_length = GLint()
|
||||||
|
glGetShaderiv(shader, GL_COMPILE_STATUS, byref(succeeded))
|
||||||
|
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, byref(log_length))
|
||||||
|
buffer = create_string_buffer(log_length.value + 1)
|
||||||
|
glGetShaderInfoLog(shader, log_length.value, None, buffer)
|
||||||
|
|
||||||
|
if not succeeded:
|
||||||
|
raise CompileError(buffer.value.decode('utf-8'))
|
||||||
|
elif log_length.value:
|
||||||
|
print('Warning:', file=sys.stderr)
|
||||||
|
print(buffer.value.decode('utf-8'), file=sys.stderr)
|
||||||
|
|
||||||
|
def __init__(self, vertex_file, fragment_file):
|
||||||
|
with glShader(GL_VERTEX_SHADER) as vertex_shader, glShader(GL_FRAGMENT_SHADER) as fragment_shader:
|
||||||
|
self.compile_shader(vertex_shader, self.load_file(vertex_file))
|
||||||
|
self.compile_shader(fragment_shader, self.load_file(fragment_file))
|
||||||
|
|
||||||
|
program = glCreateProgram()
|
||||||
|
glAttachShader(program, vertex_shader)
|
||||||
|
glAttachShader(program, fragment_shader)
|
||||||
|
glLinkProgram(program)
|
||||||
|
|
||||||
|
succeeded = GLint()
|
||||||
|
log_length = GLint()
|
||||||
|
glGetProgramiv(program, GL_LINK_STATUS, byref(succeeded))
|
||||||
|
if not succeeded:
|
||||||
|
glGetProgramiv(program, GL_INFO_LOG_LENGTH, byref(log_length))
|
||||||
|
buffer = create_string_buffer(log_length.value + 1)
|
||||||
|
glGetProgramInfoLog(program, log_length.value, None, buffer)
|
||||||
|
glDeleteProgram(program)
|
||||||
|
raise CompileError(buffer.value)
|
||||||
|
|
||||||
|
glDetachShader(program, vertex_shader)
|
||||||
|
glDetachShader(program, fragment_shader)
|
||||||
|
|
||||||
|
self.program = program
|
||||||
|
self.attributes = self._variable_locations(GL_ACTIVE_ATTRIBUTES, glGetActiveAttrib, glGetAttribLocation)
|
||||||
|
self.uniforms = self._variable_locations(GL_ACTIVE_UNIFORMS, glGetActiveUniform, glGetUniformLocation)
|
||||||
|
|
||||||
|
def vertex_attribute(self, name, size, type, normalized, stride, offset, divisor=None):
|
||||||
|
location = self.attributes[name]
|
||||||
|
glVertexAttribPointer(location, size, type, normalized, stride, offset)
|
||||||
|
glEnableVertexAttribArray(location)
|
||||||
|
if divisor:
|
||||||
|
glVertexAttribDivisor(location, divisor)
|
||||||
|
|
||||||
|
def vertex_attribute_vec2(self, name, a, b):
|
||||||
|
glVertexAttrib2f(self.attributes[name], a, b)
|
||||||
|
|
||||||
|
def vertex_attribute_vec3(self, name, a, b, c):
|
||||||
|
glVertexAttrib3f(self.attributes[name], a, b, c)
|
||||||
|
|
||||||
|
def uniform_mat4(self, name, matrix):
|
||||||
|
glUniformMatrix4fv(self.uniforms[name], 1, GL_FALSE, matrix)
|
||||||
|
|
||||||
|
def uniform_texture(self, name, index):
|
||||||
|
glUniform1i(self.uniforms[name], index)
|
||||||
|
|
||||||
|
def uniform_float(self, name, value):
|
||||||
|
glUniform1f(self.uniforms[name], value)
|
||||||
|
|
||||||
|
def uniform_bool(self, name, value):
|
||||||
|
glUniform1i(self.uniforms[name], bool(value))
|
||||||
|
|
||||||
|
def uniform_vec2(self, name, a, b):
|
||||||
|
glUniform2f(self.uniforms[name], a, b)
|
||||||
|
|
||||||
|
def uniform_vec3(self, name, a, b, c):
|
||||||
|
glUniform3f(self.uniforms[name], a, b, c)
|
||||||
|
|
||||||
|
def uniform_vec4(self, name, a, b, c, d):
|
||||||
|
glUniform4f(self.uniforms[name], a, b, c, d)
|
||||||
|
|
||||||
|
def _variable_locations(self, count_type, get_func, loc_func):
|
||||||
|
variables = {}
|
||||||
|
count = GLint()
|
||||||
|
glGetProgramiv(self.program, count_type, byref(count))
|
||||||
|
buffer = create_string_buffer(256)
|
||||||
|
size = GLint()
|
||||||
|
type = GLenum()
|
||||||
|
|
||||||
|
for index in range(count.value):
|
||||||
|
get_func(self.program, index, 256, None, byref(size), byref(type), buffer)
|
||||||
|
variables[buffer.value.decode('ascii')] = loc_func(self.program, buffer)
|
||||||
|
return variables
|
12
punyverse/shaders/atmosphere.fragment.glsl
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in float v_u;
|
||||||
|
|
||||||
|
out vec4 o_fragColor;
|
||||||
|
|
||||||
|
uniform vec3 u_color;
|
||||||
|
uniform sampler1D u_transparency;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
o_fragColor = vec4(u_color, texture(u_transparency, v_u).r);
|
||||||
|
}
|
13
punyverse/shaders/atmosphere.vertex.glsl
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec2 a_position;
|
||||||
|
in float a_u;
|
||||||
|
|
||||||
|
out float v_u;
|
||||||
|
|
||||||
|
uniform mat4 u_mvpMatrix;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = u_mvpMatrix * vec4(a_position, 0, 1);
|
||||||
|
v_u = a_u;
|
||||||
|
}
|
28
punyverse/shaders/belt.vertex.glsl
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec3 a_position;
|
||||||
|
in vec3 a_normal;
|
||||||
|
in vec2 a_uv;
|
||||||
|
in vec3 a_translate;
|
||||||
|
in float a_scale;
|
||||||
|
|
||||||
|
out vec2 v_uv;
|
||||||
|
out vec3 v_normal;
|
||||||
|
out vec3 v_position;
|
||||||
|
out vec3 v_camDirection;
|
||||||
|
|
||||||
|
uniform mat4 u_mvpMatrix;
|
||||||
|
uniform mat4 u_mvMatrix;
|
||||||
|
uniform mat4 u_modelMatrix;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
mat4 matrix = mat4(mat3(a_scale));
|
||||||
|
matrix[3].xyz = a_translate;
|
||||||
|
mat4 modelMatrix = u_modelMatrix * matrix;
|
||||||
|
|
||||||
|
gl_Position = u_mvpMatrix * matrix * vec4(a_position, 1);
|
||||||
|
v_normal = normalize(vec3(modelMatrix * vec4(a_normal, 0)));
|
||||||
|
v_uv = a_uv;
|
||||||
|
v_position = (modelMatrix * vec4(a_position, 1)).xyz;
|
||||||
|
v_camDirection = (u_mvMatrix * matrix * vec4(a_position, 1)).xyz;
|
||||||
|
}
|
19
punyverse/shaders/clouds.fragment.glsl
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec2 v_uv;
|
||||||
|
in vec3 v_normal;
|
||||||
|
in vec3 v_position;
|
||||||
|
|
||||||
|
out vec4 o_fragColor;
|
||||||
|
|
||||||
|
uniform vec3 u_ambient;
|
||||||
|
uniform vec3 u_diffuse;
|
||||||
|
uniform vec3 u_sun;
|
||||||
|
uniform sampler2D u_transparency;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec3 incident = normalize(u_sun - v_position);
|
||||||
|
vec3 diffuse = u_diffuse * clamp(dot(v_normal, incident) + 0.2, 0.0, 1.0);
|
||||||
|
|
||||||
|
o_fragColor = vec4(u_ambient + diffuse, texture(u_transparency, v_uv).r);
|
||||||
|
}
|
20
punyverse/shaders/clouds.vertex.glsl
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec3 a_normal;
|
||||||
|
in vec2 a_uv;
|
||||||
|
|
||||||
|
out vec2 v_uv;
|
||||||
|
out vec3 v_normal;
|
||||||
|
out vec3 v_position;
|
||||||
|
|
||||||
|
uniform float u_radius;
|
||||||
|
uniform mat4 u_mvpMatrix;
|
||||||
|
uniform mat4 u_modelMatrix;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec3 position = u_radius * a_normal;
|
||||||
|
v_uv = a_uv;
|
||||||
|
v_normal = (u_modelMatrix * vec4(a_normal, 0)).xyz;
|
||||||
|
v_position = (u_modelMatrix * vec4(position, 1)).xyz;
|
||||||
|
gl_Position = u_mvpMatrix * vec4(position, 1);
|
||||||
|
}
|
8
punyverse/shaders/line.fragment.glsl
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
out vec4 o_fragColor;
|
||||||
|
uniform vec4 u_color;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
o_fragColor = u_color;
|
||||||
|
}
|
8
punyverse/shaders/line.vertex.glsl
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec3 a_position;
|
||||||
|
uniform mat4 u_mvpMatrix;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = u_mvpMatrix * vec4(a_position, 1);
|
||||||
|
}
|
43
punyverse/shaders/model.fragment.glsl
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec2 v_uv;
|
||||||
|
in vec3 v_normal;
|
||||||
|
in vec3 v_position;
|
||||||
|
in vec3 v_camDirection;
|
||||||
|
|
||||||
|
out vec4 o_fragColor;
|
||||||
|
|
||||||
|
struct Material {
|
||||||
|
bool hasDiffuse;
|
||||||
|
sampler2D diffuseMap;
|
||||||
|
vec3 ambient;
|
||||||
|
vec3 diffuse;
|
||||||
|
vec3 specular;
|
||||||
|
float shininess;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Sun {
|
||||||
|
vec3 ambient;
|
||||||
|
vec3 diffuse;
|
||||||
|
vec3 specular;
|
||||||
|
vec3 position;
|
||||||
|
float intensity;
|
||||||
|
};
|
||||||
|
|
||||||
|
uniform Sun u_sun;
|
||||||
|
uniform Material u_material;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec3 incident = normalize(u_sun.position - v_position);
|
||||||
|
vec3 reflected = normalize(reflect(-incident, v_normal));
|
||||||
|
|
||||||
|
float diffuseIntensity = max(dot(v_normal, incident), 0.0);
|
||||||
|
float shininess = pow(max(dot(normalize(v_camDirection), reflected), 0), u_material.shininess);
|
||||||
|
|
||||||
|
vec3 diffuse = u_material.hasDiffuse ? texture(u_material.diffuseMap, v_uv).rgb : vec3(1);
|
||||||
|
vec3 ambient = u_material.ambient * u_sun.ambient * diffuse;
|
||||||
|
vec3 specular = u_material.specular * u_sun.specular * max(shininess, 0) * diffuseIntensity;
|
||||||
|
diffuse *= u_material.diffuse * u_sun.diffuse * diffuseIntensity;
|
||||||
|
|
||||||
|
o_fragColor = vec4((ambient + diffuse + specular) * u_sun.intensity, 1);
|
||||||
|
}
|
22
punyverse/shaders/model.vertex.glsl
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec3 a_position;
|
||||||
|
in vec3 a_normal;
|
||||||
|
in vec2 a_uv;
|
||||||
|
|
||||||
|
out vec2 v_uv;
|
||||||
|
out vec3 v_normal;
|
||||||
|
out vec3 v_position;
|
||||||
|
out vec3 v_camDirection;
|
||||||
|
|
||||||
|
uniform mat4 u_mvpMatrix;
|
||||||
|
uniform mat4 u_mvMatrix;
|
||||||
|
uniform mat4 u_modelMatrix;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = u_mvpMatrix * vec4(a_position, 1);
|
||||||
|
v_normal = normalize(vec3(u_modelMatrix * vec4(a_normal, 0)));
|
||||||
|
v_uv = a_uv;
|
||||||
|
v_position = (u_modelMatrix * vec4(a_position, 1)).xyz;
|
||||||
|
v_camDirection = (u_mvMatrix * vec4(a_position, 1)).xyz;
|
||||||
|
}
|
55
punyverse/shaders/planet.fragment.glsl
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec2 v_uv;
|
||||||
|
in vec3 v_normal;
|
||||||
|
in vec3 v_position;
|
||||||
|
in vec3 v_camDirection;
|
||||||
|
in mat3 v_TBN;
|
||||||
|
|
||||||
|
out vec4 o_fragColor;
|
||||||
|
|
||||||
|
struct Surface {
|
||||||
|
sampler2D diffuseMap;
|
||||||
|
bool hasNormal;
|
||||||
|
sampler2D normalMap;
|
||||||
|
bool hasSpecular;
|
||||||
|
sampler2D specularMap;
|
||||||
|
bool hasEmission;
|
||||||
|
sampler2D emissionMap;
|
||||||
|
vec3 ambient;
|
||||||
|
vec3 diffuse;
|
||||||
|
vec3 specular;
|
||||||
|
vec3 emission;
|
||||||
|
float shininess;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Sun {
|
||||||
|
vec3 ambient;
|
||||||
|
vec3 diffuse;
|
||||||
|
vec3 specular;
|
||||||
|
vec3 position;
|
||||||
|
float intensity;
|
||||||
|
};
|
||||||
|
|
||||||
|
uniform Sun u_sun;
|
||||||
|
uniform Surface u_planet;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec3 normal = u_planet.hasNormal ? normalize(v_TBN * texture(u_planet.normalMap, v_uv).rgb * 2 - 1) : v_normal;
|
||||||
|
vec3 diffuse = texture(u_planet.diffuseMap, v_uv).rgb;
|
||||||
|
vec3 specular = u_planet.hasSpecular ? texture(u_planet.specularMap, v_uv).rgb : vec3(1);
|
||||||
|
vec3 emission = u_planet.hasEmission ? texture(u_planet.emissionMap, v_uv).rgb : vec3(1);
|
||||||
|
|
||||||
|
vec3 incident = normalize(u_sun.position - v_position);
|
||||||
|
vec3 reflected = normalize(reflect(-incident, normal));
|
||||||
|
|
||||||
|
float diffuseIntensity = max(dot(normal, incident), 0.0);
|
||||||
|
float shininess = pow(max(dot(normalize(v_camDirection), reflected), 0), u_planet.shininess);
|
||||||
|
|
||||||
|
vec3 ambient = u_planet.ambient * u_sun.ambient * diffuse;
|
||||||
|
diffuse *= u_planet.diffuse * u_sun.diffuse * diffuseIntensity;
|
||||||
|
emission *= u_planet.emission * (1 - min(diffuseIntensity * 2, 1));
|
||||||
|
specular *= u_planet.specular * u_sun.specular * max(shininess, 0) * diffuseIntensity;
|
||||||
|
|
||||||
|
o_fragColor = vec4((ambient + diffuse + emission + specular) * u_sun.intensity, 1);
|
||||||
|
}
|
30
punyverse/shaders/planet.vertex.glsl
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec3 a_normal;
|
||||||
|
in vec2 a_tangent;
|
||||||
|
in vec2 a_uv;
|
||||||
|
|
||||||
|
out vec2 v_uv;
|
||||||
|
out vec3 v_normal;
|
||||||
|
out vec3 v_position;
|
||||||
|
out vec3 v_camDirection;
|
||||||
|
out mat3 v_TBN;
|
||||||
|
|
||||||
|
uniform float u_radius;
|
||||||
|
uniform mat4 u_mvpMatrix;
|
||||||
|
uniform mat4 u_mvMatrix;
|
||||||
|
uniform mat4 u_modelMatrix;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec3 position = u_radius * a_normal;
|
||||||
|
|
||||||
|
gl_Position = u_mvpMatrix * vec4(position, 1);
|
||||||
|
|
||||||
|
v_normal = normalize(vec3(u_modelMatrix * vec4(a_normal, 0)));
|
||||||
|
v_uv = a_uv;
|
||||||
|
v_position = (u_modelMatrix * vec4(position, 1)).xyz;
|
||||||
|
v_camDirection = (u_mvMatrix * vec4(position, 1)).xyz;
|
||||||
|
|
||||||
|
vec3 tangent = normalize((u_modelMatrix * vec4(a_tangent, a_normal.z, 0)).xyz);
|
||||||
|
v_TBN = mat3(tangent, cross(tangent, v_normal), v_normal);
|
||||||
|
}
|
22
punyverse/shaders/ring.fragment.glsl
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec3 v_position;
|
||||||
|
in float v_u;
|
||||||
|
|
||||||
|
out vec4 o_fragColor;
|
||||||
|
|
||||||
|
uniform vec3 u_sun;
|
||||||
|
uniform vec3 u_planet;
|
||||||
|
uniform float u_planetRadius;
|
||||||
|
uniform float u_ambient;
|
||||||
|
uniform sampler1D u_texture;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec3 incident = v_position - u_sun;
|
||||||
|
vec3 plane_normal = u_planet - u_sun;
|
||||||
|
vec3 plane_intersect = dot(plane_normal, plane_normal) / dot(incident, plane_normal) * incident;
|
||||||
|
o_fragColor = texture(u_texture, v_u);
|
||||||
|
if (length(plane_intersect) < length(incident) &&
|
||||||
|
distance(plane_intersect, plane_normal) <= u_planetRadius)
|
||||||
|
o_fragColor.rgb *= u_ambient;
|
||||||
|
}
|
16
punyverse/shaders/ring.vertex.glsl
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec2 a_position;
|
||||||
|
in float a_u;
|
||||||
|
|
||||||
|
out vec3 v_position;
|
||||||
|
out float v_u;
|
||||||
|
|
||||||
|
uniform mat4 u_mvpMatrix;
|
||||||
|
uniform mat4 u_modelMatrix;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = u_mvpMatrix * vec4(a_position, 0, 1);
|
||||||
|
v_position = (u_modelMatrix * vec4(a_position, 0, 1)).xyz;
|
||||||
|
v_u = a_u;
|
||||||
|
}
|