mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
More testing
This commit is contained in:
@@ -2,7 +2,7 @@ class IMICFPS
|
|||||||
class Terrain
|
class Terrain
|
||||||
include OpenGL
|
include OpenGL
|
||||||
def initialize(size:, height: nil, width: nil, length: nil, heightmap: nil)
|
def initialize(size:, height: nil, width: nil, length: nil, heightmap: nil)
|
||||||
@size = size
|
@size = 3#size
|
||||||
@heightmap = heightmap
|
@heightmap = heightmap
|
||||||
@map = []
|
@map = []
|
||||||
|
|
||||||
@@ -18,20 +18,23 @@ class IMICFPS
|
|||||||
|
|
||||||
def generate
|
def generate
|
||||||
# x
|
# x
|
||||||
row = []
|
row = []
|
||||||
@width.times do |x|
|
@width.times do |x|
|
||||||
@length.times do |z|
|
@length.times do |z|
|
||||||
@map << Vertex.new(x-@width.to_f/2, @height, z-@length.to_f/2)
|
@map << Vertex.new(x-@width.to_f/2, @height, z-@length.to_f/2)
|
||||||
@map << Vertex.new(x+1-@width.to_f/2, @height, z-@length.to_f/2)
|
@map << Vertex.new(x+1-@width.to_f/2, @height, z-@length.to_f/2)
|
||||||
# @map << Vertex.new(x+1, height, z)
|
@map << Vertex.new(x-@width.to_f/2, @height, z+1-@length.to_f/2)
|
||||||
# @map << Vertex.new(x+1, height, z-1)
|
|
||||||
#
|
# @map << Vertex.new(x+1, height, z)
|
||||||
# @map << Vertex.new(x, height, z)
|
# @map << Vertex.new(x+1, height, z-1)
|
||||||
# @map << Vertex.new(x+1, height, z)
|
#
|
||||||
# @map << Vertex.new(x+1, height, z-1)
|
# @map << Vertex.new(x, height, z)
|
||||||
# height +=0.5
|
# @map << Vertex.new(x+1, height, z)
|
||||||
|
# @map << Vertex.new(x+1, height, z-1)
|
||||||
|
# height +=0.5
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# @map << row
|
# @map << row
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -55,22 +58,22 @@ class IMICFPS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def draw
|
def draw
|
||||||
new_draw
|
# new_draw
|
||||||
old_draw
|
old_draw
|
||||||
end
|
end
|
||||||
|
|
||||||
def old_draw
|
def old_draw
|
||||||
glEnable(GL_COLOR_MATERIAL)
|
glEnable(GL_COLOR_MATERIAL)
|
||||||
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
|
# glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
|
||||||
glPointSize(5)
|
glPointSize(5)
|
||||||
# glBegin(GL_LINES)
|
# glBegin(GL_LINES)
|
||||||
# glBegin(GL_POINTS)
|
# glBegin(GL_POINTS)
|
||||||
glBegin(GL_TRIANGLE_STRIP)
|
glBegin(GL_TRIANGLES)
|
||||||
@map.each_with_index do |vertex, index|
|
@map.each_with_index do |vertex, index|
|
||||||
glNormal3f(0,1,0)
|
glNormal3f(0,1,0)
|
||||||
glColor3f(0.0, 0.5, 0) if index.even?
|
glColor3f(0.0, 0.5, 0) if index.even?
|
||||||
glColor3f(0.5, 0, 0) if index.odd?
|
glColor3f(0, 1.0, 0) if index.odd?
|
||||||
glVertex3f(vertex.x, vertex.y, vertex.z)
|
glVertex3f(vertex.x, vertex.y, vertex.z)
|
||||||
end
|
end
|
||||||
glEnd
|
glEnd
|
||||||
|
|||||||
@@ -21,13 +21,15 @@ class IMICFPS
|
|||||||
@draw_skydome = true
|
@draw_skydome = true
|
||||||
@skydome = Skydome.new(scale: 0.02, backface_culling: false, auto_manage: false)
|
@skydome = Skydome.new(scale: 0.02, backface_culling: false, auto_manage: false)
|
||||||
Tree.new(x: 1, y: 0, z: -5)
|
Tree.new(x: 1, y: 0, z: -5)
|
||||||
|
Tree.new(x: 5, y: 0, z: 5)
|
||||||
|
Tree.new(x: -5, y: 0, z: 1)
|
||||||
p ObjectManager.objects.map {|o| o.name}
|
p ObjectManager.objects.map {|o| o.name}
|
||||||
# Model.new(type: :obj, file_path: "objects/tree.obj", z: -5)
|
# Model.new(type: :obj, file_path: "objects/tree.obj", z: -5)
|
||||||
# Model.new(type: :obj, file_path: "objects/tree.obj", x: -2, z: -6)
|
# Model.new(type: :obj, file_path: "objects/tree.obj", x: -2, z: -6)
|
||||||
# Model.new(type: :obj, file_path: "objects/sponza.obj", scale: 1, y: -0.2)
|
# Model.new(type: :obj, file_path: "objects/sponza.obj", scale: 1, y: -0.2)
|
||||||
@terrain = Terrain.new(size: 20, height: 0)
|
@terrain = Terrain.new(size: 20, height: 0)
|
||||||
|
|
||||||
@player = Player.new(x: 1, y: 0, z: -10)
|
@player = Player.new(x: 1, y: 0, z: -1)
|
||||||
@camera = Camera.new(x: 0, y: -2, z: 1)
|
@camera = Camera.new(x: 0, y: -2, z: 1)
|
||||||
@camera.attach_to(@player)
|
@camera.attach_to(@player)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user