mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 23:52:35 +00:00
Added tree and biped (humanoid), can now pass x,y,z coordinance to Model
This commit is contained in:
@@ -8,8 +8,10 @@ class IMICFPS
|
|||||||
Color = Struct.new(:red, :green, :blue, :alpha)
|
Color = Struct.new(:red, :green, :blue, :alpha)
|
||||||
|
|
||||||
attr_accessor :objects, :materials, :vertexes, :texures, :normals, :faces
|
attr_accessor :objects, :materials, :vertexes, :texures, :normals, :faces
|
||||||
|
attr_accessor :x, :y, :z
|
||||||
|
|
||||||
def initialize(object = "objects/cube.obj")
|
def initialize(object = "objects/cube.obj")
|
||||||
|
@x, @y, @z = 0, 0, 0
|
||||||
@object_path = object
|
@object_path = object
|
||||||
@file = File.open(object, 'r')
|
@file = File.open(object, 'r')
|
||||||
@material_file = nil
|
@material_file = nil
|
||||||
@@ -31,15 +33,17 @@ class IMICFPS
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def draw(scale = 1)
|
def draw(x, y, z, scale = 1)
|
||||||
begin
|
begin
|
||||||
render(scale)
|
render(x,y,z, scale)
|
||||||
rescue Gl::Error => e
|
rescue Gl::Error => e
|
||||||
p e
|
p e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(scale = 1)
|
def render(x,y,z, scale = 1)
|
||||||
|
glTranslatef(x,y,z)
|
||||||
|
glScalef(scale,scale,scale)
|
||||||
@objects.each_with_index do |o, i|
|
@objects.each_with_index do |o, i|
|
||||||
glEnable(GL_CULL_FACE)
|
glEnable(GL_CULL_FACE)
|
||||||
glEnable(GL_COLOR_MATERIAL)
|
glEnable(GL_COLOR_MATERIAL)
|
||||||
@@ -59,8 +63,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_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_SPECULAR, [material.specular.red, material.specular.green, material.specular.blue, 1.0])
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, [10.0])
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, [10.0])
|
||||||
glNormal3f(normal.x*scale, normal.y*scale, normal.z*scale)
|
glNormal3f(normal.x, normal.y, normal.z)
|
||||||
glVertex3f(vertex.x*scale, vertex.y*scale, vertex.z*scale)
|
glVertex3f(vertex.x, vertex.y, vertex.z)
|
||||||
end
|
end
|
||||||
glEnd
|
glEnd
|
||||||
glDisable(GL_CULL_FACE)
|
glDisable(GL_CULL_FACE)
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ class IMICFPS
|
|||||||
super(window_width, window_height, fullscreen)
|
super(window_width, window_height, fullscreen)
|
||||||
# super(Gosu.screen_width, Gosu.screen_height, true)
|
# super(Gosu.screen_width, Gosu.screen_height, true)
|
||||||
$window = self
|
$window = self
|
||||||
@model = Wavefront::Model.new("objects/cube.obj")
|
@model = Wavefront::Model.new("objects/biped.obj")
|
||||||
|
@model2 = Wavefront::Model.new("objects/tree.obj")
|
||||||
# @model = Wavefront::Model.new("objects/sponza.obj")
|
# @model = Wavefront::Model.new("objects/sponza.obj")
|
||||||
@camera = Wavefront::Model::Vertex.new(0,-1,0)
|
@camera = Wavefront::Model::Vertex.new(0,-1,0)
|
||||||
@camera_target = Wavefront::Model::Vertex.new(0,-1,0)
|
@camera_target = Wavefront::Model::Vertex.new(0,-1,0)
|
||||||
@@ -68,7 +69,8 @@ class IMICFPS
|
|||||||
gluLookAt(@camera.x,@camera.y,@camera.z, @angle_x,@angle_y,0, 0,1,0)
|
gluLookAt(@camera.x,@camera.y,@camera.z, @angle_x,@angle_y,0, 0,1,0)
|
||||||
|
|
||||||
color = [@c1, @c2, @c3]
|
color = [@c1, @c2, @c3]
|
||||||
@model.draw(1)
|
@model.draw(0, 0, 0, 0.005)
|
||||||
|
@model2.draw(5, 0, 0, 0.005)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
52
objects/biped.mtl
Normal file
52
objects/biped.mtl
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Blender MTL File: 'biped.blend'
|
||||||
|
# Material Count: 5
|
||||||
|
|
||||||
|
newmtl eye
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.640000 0.640000 0.640000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl pants
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.068996 0.139143 0.640000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl shirt
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.006647 0.280444 0.000000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl shoe
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.134359 0.134359 0.134359
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl skin
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.110067 0.069785 0.027733
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
1274
objects/biped.obj
Normal file
1274
objects/biped.obj
Normal file
File diff suppressed because it is too large
Load Diff
22
objects/tree.mtl
Normal file
22
objects/tree.mtl
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Blender MTL File: 'tree.blend'
|
||||||
|
# Material Count: 2
|
||||||
|
|
||||||
|
newmtl Material
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.181267 0.106319 0.092156
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl leaf
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.127997 0.491692 0.000000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
1039
objects/tree.obj
Normal file
1039
objects/tree.obj
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user