Initial commit
This commit is contained in:
commit
3ca078c7e7
17 changed files with 1540 additions and 0 deletions
Objects/Cuboid
22
Objects/Cuboid/Cuboid.py
Normal file
22
Objects/Cuboid/Cuboid.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from OpenGL.GLUT import *
|
||||
from OpenGL.GLU import *
|
||||
from OpenGL.GL import *
|
||||
from Objects.Objects import *
|
||||
|
||||
class Cuboid(Object):
|
||||
GeometryShaderId = -1
|
||||
|
||||
def __init__(self):
|
||||
Object.__init__(self)
|
||||
if(Cuboid.GeometryShaderId == -1):
|
||||
self.initializeShader()
|
||||
def initializeShader(self)->bool:
|
||||
with open('./Objects/Cuboid/cuboid_geometry.glsl', 'r') as f:
|
||||
geometry_shader_string = f.read()
|
||||
Cuboid.GeometryShaderId = glCreateShader(GL_GEOMETRY_SHADER)
|
||||
glShaderSource(Cuboid.GeometryShaderId, geometry_shader_string)
|
||||
glCompileShader(Cuboid.GeometryShaderId)
|
||||
if glGetShaderiv(Cuboid.GeometryShaderId, GL_COMPILE_STATUS) != GL_TRUE:
|
||||
raise RuntimeError(glGetShaderInfoLog(Cuboid.GeometryShaderId))
|
||||
return False
|
||||
return True
|
204
Objects/Cuboid/cuboid_geometry.glsl
Normal file
204
Objects/Cuboid/cuboid_geometry.glsl
Normal file
|
@ -0,0 +1,204 @@
|
|||
#version 410
|
||||
|
||||
layout(points) in;
|
||||
layout(triangle_strip,max_vertices=24) out;
|
||||
|
||||
uniform mat4 projModelViewMatrix;
|
||||
uniform mat3 normalMatrix;
|
||||
uniform mat3 rotMatrix;
|
||||
|
||||
layout(location = 0) in vec3 colorgeo[1];
|
||||
layout(location = 1) in vec3 size[1];
|
||||
layout(location = 0) out vec3 colorout;
|
||||
layout(location = 1) out vec3 normal;
|
||||
layout(location = 2) out vec3 pos;
|
||||
|
||||
void main(){
|
||||
//hinten
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,-size[0].y,-size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,0,-1));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,-size[0].y,-size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,0,-1));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,size[0].y,-size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,0,-1));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,size[0].y,-size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,0,-1));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
//vorne
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,size[0].y,size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,0,1));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,-size[0].y,size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,0,1));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,size[0].y,size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,0,1));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,-size[0].y,size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,0,1));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
//oben
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,size[0].y,-size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,1,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,size[0].y,-size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,1,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,size[0].y,size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,1,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,size[0].y,size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,1,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
//unten
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,-size[0].y,size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,-1,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,-size[0].y,-size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,-1,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,-size[0].y,size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,-1,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,-size[0].y,-size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(0,-1,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
//links
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,size[0].y,-size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(-1,0,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,-size[0].y,-size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(-1,0,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,size[0].y,size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(-1,0,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,-size[0].y,size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(-1,0,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
//rechts
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,-size[0].y,size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(1,0,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,-size[0].y,-size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(1,0,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,size[0].y,size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(1,0,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,size[0].y,-size[0].z),0));
|
||||
colorout = colorgeo[0];
|
||||
normal = normalize(rotMatrix * vec3(1,0,0));
|
||||
|
||||
pos = gl_Position.xyz;
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue