Fixed scaling lighting weirdness

This commit is contained in:
2018-03-18 11:53:41 -05:00
parent b35edcc7aa
commit 4d09dde058
4 changed files with 12 additions and 9 deletions

View File

@@ -2,13 +2,18 @@ GEM
remote: https://rubygems.org/
specs:
glu (8.3.0)
glu (8.3.0-x86-mingw32)
glut (8.3.0)
gosu (0.13.1)
glut (8.3.0-x86-mingw32)
gosu (0.13.2)
gosu (0.13.2-x86-mingw32)
opengl (0.10.0)
opengl (0.10.0-x86-mingw32)
wavefront (0.1.2)
PLATFORMS
ruby
x86-mingw32
DEPENDENCIES
glu

View File

@@ -3,7 +3,6 @@ require "glu"
require "glut"
require "gosu"
require "fiddle"
# require "wavefront"
require_relative "lib/wavefront/model"
require_relative "lib/wavefront/object"

View File

@@ -43,7 +43,6 @@ class IMICFPS
def render(x,y,z, scale = 1)
glTranslatef(x,y,z)
glScalef(scale,scale,scale)
@objects.each_with_index do |o, i|
glEnable(GL_CULL_FACE)
glEnable(GL_COLOR_MATERIAL)
@@ -63,8 +62,8 @@ class IMICFPS
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [material.diffuse.red, material.diffuse.green, material.diffuse.blue, 1.0])
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [material.specular.red, material.specular.green, material.specular.blue, 1.0])
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, [10.0])
glNormal3f(normal.x, normal.y, normal.z)
glVertex3f(vertex.x, vertex.y, vertex.z)
glNormal3f(normal.x, normal.y, normal.z) # Don't scale normals
glVertex3f(vertex.x*scale, vertex.y*scale, vertex.z*scale)
end
glEnd
glDisable(GL_CULL_FACE)

View File

@@ -69,8 +69,8 @@ class IMICFPS
gluLookAt(@camera.x,@camera.y,@camera.z, @angle_x,@angle_y,0, 0,1,0)
color = [@c1, @c2, @c3]
@model.draw(0, 0, 0, 0.005)
@model2.draw(5, 0, 0, 0.005)
@model.draw(0, 0, 0, 0.0009)
@model2.draw(5, 0, 0, 0.0009)
end
@@ -98,8 +98,8 @@ class IMICFPS
@angle_y = @angle_y.clamp(-360, 360)
self.mouse_x, self.mouse_y = Gosu.screen_width/2, Gosu.screen_height/2
@light_postion = [@camera.x, @camera.y, @camera.z, 1]
# @light_postion = [1.0, 0.249, 4.09, 1]
@light_postion = [@camera.x, @camera.y, @camera.z, 0]
# @light_postion = [0.0, 10, 0, 0]
@camera.x-=@speed if $window.button_down?(Gosu::KbRight)
@camera.x+=@speed if $window.button_down?(Gosu::KbLeft)