Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed Shuttering

  • Loading branch information...
commit ff4c1133544ce155625be9f00e06bde9d6ed8eb9 1 parent 8c2a57a
Fabian Heredia Montiel authored April 25, 2012
8  Engine/__main__.py
@@ -18,7 +18,6 @@
18 18
 
19 19
 ##########
20 20
 # Engine
21  
-print path
22 21
 print "=== Cargando Engine ==="
23 22
 if path[0].split("/")[-1] == "Engine": chdir("../")
24 23
 path.append("./")
@@ -35,6 +34,8 @@
35 34
 
36 35
 ##########
37 36
 # Funciones Globales
  37
+
  38
+# Initialization of GLUT, GL and Engine
38 39
 def init():
39 40
 	# Init de GLUT
40 41
 	glutInit(argv)
@@ -70,7 +71,6 @@ def init():
70 71
 	object.create("resources/models/Pejuang_Final.obj", {"id": "player", "pos": [0, 0, 0, 100]})
71 72
 	object.create("resources/models/Pejuang_Final.obj", {"pos": [randint(0,360), randint(0,360), randint(0,360), 100]})
72 73
 	object.create("resources/models/Pejuang_Final.obj", {"pos": [randint(0,360), randint(0,360), randint(0,360), 100]})
73  
-	object.create("resources/models/Pejuang_Final.obj", {"pos": [randint(0,360), randint(0,360), randint(0,360), 100]})
74 74
 	
75 75
 	# Control de flujo
76 76
 	global nRun, nTime, tick
@@ -83,7 +83,8 @@ def init():
83 83
 	
84 84
 	# Main Loop
85 85
 	glutMainLoop()
86  
-	
  86
+
  87
+# OpenGL Drawing
87 88
 def display():
88 89
 	# Clear
89 90
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
@@ -111,6 +112,7 @@ def display():
111 112
 	# Pasar a pantalla
112 113
 	glutSwapBuffers()
113 114
 
  115
+# Looping and Scheduling
114 116
 def idle():
115 117
 	global nRun, nTime, tick
116 118
 	# Scheduling
12  Engine/object.py
... ...
@@ -1,3 +1,4 @@
  1
+# coding=utf-8
1 2
 from math import *
2 3
 from random import *
3 4
 from OpenGL.GL import *
@@ -29,8 +30,9 @@ def __init__(self, resource):
29 30
 		self._prop = {}
30 31
 		self._prop["pos"] = [0.0,0.0,0.0,0.0]
31 32
 		self._prop["vec"] = [0.0,0.0,0.0,0.0]
32  
-		self._prop["mass"] = 1.0
  33
+		self._prop["rot"] = [0.0,0.0,0.0]
33 34
 		self._prop["scale"] = 1.0
  35
+		self._prop["mass"] = 1.0
34 36
 		self._prop["health"] = float("inf")
35 37
 		self._prop["forces"] = []
36 38
 		self._prop["res"] = resource
@@ -88,11 +90,19 @@ def getCart(self):
88 90
 	def draw(self):
89 91
 		glPushMatrix()
90 92
 		
  93
+		# Posición
91 94
 		glRotatef(self._prop["pos"][0], 1, 0, 0) # phi
92 95
 		glRotatef(self._prop["pos"][1], 0, 1, 0) # theta
93 96
 		glRotatef(self._prop["pos"][2], 0, 0, 1) # gao
94 97
 		glTranslatef(0, 0, self._prop["pos"][3]) # rho
95 98
 		
  99
+		# Rotación
  100
+		glRotatef(self._prop["rot"][0], 1, 0, 0)
  101
+		glRotatef(self._prop["rot"][1], 0, 1, 0)
  102
+		glRotatef(self._prop["rot"][2], 0, 0, 1)
  103
+		
  104
+		# Escala
  105
+		
96 106
 		resourcemanager.get(self._prop["res"]).draw()
97 107
 		
98 108
 		glPopMatrix()
BIN  Engine/object.pyc
Binary file not shown
3  shaders/frag.glsl
... ...
@@ -1,4 +1,7 @@
1 1
 void main()
2 2
 {
3 3
 	gl_FragColor = gl_Color;
  4
+	
  5
+	// Tone Mapping
  6
+	gl_FragColor *= vec4(1.0, 0.9, 1.0, 1.0);
4 7
 }
4  shaders/vertex.glsl
@@ -5,11 +5,11 @@ void main()
5 5
 	
6 6
 	// Componente Diffuso = Md * Ld * cos(theta)
7 7
 	vec3 nC	= normalize(gl_NormalMatrix * gl_Normal);
8  
-	vec3 pL	= vec3(gl_LightSource[0].position);
  8
+	vec3 pL	= gl_ModelViewProjectionMatrix * gl_LightSource[0].position;
9 9
 	vec4 eCL= dot(nC, normalize(pL));
10 10
 	vec4 cD	= gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse * eCL;
11 11
 	
12 12
 	
13 13
 	gl_FrontColor	= cA + cD;
14  
-	gl_Position		= ftransform();
  14
+	gl_Position		= gl_ModelViewProjectionMatrix * gl_Vertex;
15 15
 }

0 notes on commit ff4c113

Please sign in to comment.
Something went wrong with that request. Please try again.