mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
Pack everything as f*? It renders!
This commit is contained in:
@@ -41,13 +41,18 @@ class IMICFPS
|
||||
end
|
||||
end
|
||||
|
||||
def draw(x, y, z, scale = MODEL_METER_SCALE, back_face_culling = true)
|
||||
def handleGlError
|
||||
e = glGetError()
|
||||
if e != GL_NO_ERROR
|
||||
$stderr.puts "OpenGL error in: #{gluErrorString(e)} (#{e})\n"
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
def draw(x, y, z, scale = MODEL_METER_SCALE, back_face_culling = true)
|
||||
handleGlError
|
||||
render(x,y,z, scale, back_face_culling)
|
||||
handleGlError
|
||||
end
|
||||
|
||||
def render(x,y,z, scale, back_face_culling)
|
||||
@@ -82,10 +87,10 @@ class IMICFPS
|
||||
# material = vert[3]
|
||||
#
|
||||
# glColor3f(material.diffuse.red, material.diffuse.green, material.diffuse.blue)
|
||||
# glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [material.ambient.red, material.ambient.green, material.ambient.blue, 1.0].pack("f*"))
|
||||
# glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [material.diffuse.red, material.diffuse.green, material.diffuse.blue, 1.0].pack("f*"))
|
||||
# glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [material.specular.red, material.specular.green, material.specular.blue, 1.0].pack("f*"))
|
||||
# glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, [10.0].pack("f*"))
|
||||
# # glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [material.ambient.red, material.ambient.green, material.ambient.blue, 1.0].pack("f*"))
|
||||
# # glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [material.diffuse.red, material.diffuse.green, material.diffuse.blue, 1.0].pack("f*"))
|
||||
# # glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [material.specular.red, material.specular.green, material.specular.blue, 1.0].pack("f*"))
|
||||
# # glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, [10.0].pack("f*"))
|
||||
# glNormal3f(normal.x, normal.y, normal.z) # Don't scale normals
|
||||
# glVertex3f(vertex.x, vertex.y, vertex.z)
|
||||
# end
|
||||
|
||||
@@ -32,7 +32,7 @@ class IMICFPS
|
||||
end
|
||||
|
||||
@vertices_list_size = list.size
|
||||
@vertices_list = list.pack("i*")
|
||||
@vertices_list = list.pack("f*")
|
||||
end
|
||||
|
||||
return @vertices_list
|
||||
@@ -42,6 +42,44 @@ class IMICFPS
|
||||
@vertices_list_size
|
||||
end
|
||||
|
||||
def flattened_textures
|
||||
unless @textures_list
|
||||
list = []
|
||||
@faces.each do |face|
|
||||
[face[1]].each do |v|
|
||||
next unless v
|
||||
list << v.x
|
||||
list << v.y
|
||||
end
|
||||
end
|
||||
|
||||
@textures_list_size = list.size
|
||||
@textures_list = list.pack("f*")
|
||||
end
|
||||
|
||||
return @textures_list
|
||||
end
|
||||
|
||||
def flattened_normals
|
||||
unless @normals_list
|
||||
list = []
|
||||
@faces.each do |face|
|
||||
[face[2]].each do |v|
|
||||
next unless v
|
||||
list << v.x
|
||||
list << v.y
|
||||
list << v.z
|
||||
# list << v.weight
|
||||
end
|
||||
end
|
||||
|
||||
@normals_list_size = list.size
|
||||
@normals_list = list.pack("f*")
|
||||
end
|
||||
|
||||
return @normals_list
|
||||
end
|
||||
|
||||
def flattened_materials
|
||||
unless @materials_list
|
||||
list = []
|
||||
@@ -59,49 +97,11 @@ class IMICFPS
|
||||
end
|
||||
|
||||
@materials_list_size = list.size
|
||||
@materials_list = list.pack("i*")
|
||||
@materials_list = list.pack("f*")
|
||||
end
|
||||
|
||||
return @materials_list
|
||||
end
|
||||
|
||||
def flattened_normals
|
||||
unless @normals_list
|
||||
list = []
|
||||
@faces.each do |face|
|
||||
[face[2]].each do |v|
|
||||
next unless v
|
||||
list << v.x
|
||||
list << v.y
|
||||
list << v.z
|
||||
# list << v.weight
|
||||
end
|
||||
end
|
||||
|
||||
@normals_list_size = list.size
|
||||
@normals_list = list.pack("i*")
|
||||
end
|
||||
|
||||
return @normals_list
|
||||
end
|
||||
|
||||
def flattened_textures
|
||||
unless @textures_list
|
||||
list = []
|
||||
@faces.each do |face|
|
||||
[face[1]].each do |v|
|
||||
next unless v
|
||||
list << v.x
|
||||
list << v.y
|
||||
end
|
||||
end
|
||||
|
||||
@textures_list_size = list.size
|
||||
@textures_list = list.pack("i*")
|
||||
end
|
||||
|
||||
return @textures_list
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user