Commit 6577d457 authored by Shmuel Blitz's avatar Shmuel Blitz

Trying to rended a decent cube

parent 1d412409
# cube.obj
#
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 0.500000
v -0.500000 0.500000 0.500000
v 0.500000 0.500000 0.500000
v -0.500000 0.500000 -0.500000
v 0.500000 0.500000 -0.500000
v -0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 -0.500000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 0.000000 1.000000
vt 1.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn 1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
f 1/1/1 2/2/1 3/3/1
f 3/3/1 2/2/1 4/4/1
f 3/1/2 4/2/2 5/3/2
f 5/3/2 4/2/2 6/4/2
f 5/4/3 6/3/3 7/2/3
f 7/2/3 6/3/3 8/1/3
f 7/1/4 8/2/4 1/3/4
f 1/3/4 8/2/4 2/4/4
f 2/1/5 8/2/5 4/3/5
f 4/3/5 8/2/5 6/4/5
f 7/1/6 1/2/6 5/3/6
f 5/3/6 1/2/6 3/4/6
# Blender v2.79 (sub 0) OBJ File: 'cube.blend'
# www.blender.org
o Cube
v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -0.999999
v 0.999999 1.000000 1.000001
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
v -0.000000 1.000000 0.000000
v 1.000000 0.897903 -0.901142
v 1.000000 -0.000853 -0.000852
v -0.000000 0.000000 1.000000
v -1.000000 0.000000 -0.000000
v 0.000000 -1.000000 -0.000000
v 0.000000 -0.000000 -1.000000
vt 0.838954 0.838954
vt 0.161046 0.838954
vt 0.161046 0.161046
vt 0.838954 0.838954
vt 0.161046 0.838954
vt 0.161046 0.161046
vt 0.161046 0.161046
vt 0.838954 0.161046
vt 0.838954 0.838954
vt 0.161046 0.838954
vt 0.161046 0.161046
vt 0.838954 0.838954
vt 0.161046 0.838954
vt 0.161046 0.161046
vt 0.161046 0.838954
vt 0.161046 0.161046
vt 0.838954 0.838954
vt 0.161046 0.838954
vt 0.161046 0.161046
vt 0.838954 0.838954
vt 0.838954 0.838954
vt 0.161046 0.161046
vt 0.161046 0.838954
vt 0.161046 0.161046
vt 0.838954 0.161046
vt 0.838954 0.838954
vt 0.161046 0.838954
vt 0.161046 0.161046
vt 0.161046 0.838954
vt 0.838954 0.838954
vt 0.161046 0.838954
vt 0.161046 0.161046
vt 0.838954 0.838954
vt 0.161046 0.838954
vt 0.838954 0.838954
vt 0.161046 0.161046
vt 0.838954 0.838954
vt 0.838954 0.838954
vt 0.161046 0.838954
vt 0.838954 0.838954
vt 0.161046 0.838954
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 1.0000 -0.0000 0.0000
vn 0.0000 -0.0000 1.0000
vn -1.0000 -0.0000 -0.0000
vn 0.0000 0.0000 -1.0000
s off
f 1/1/1 14/2/1 4/3/1
f 5/4/2 8/5/2 9/6/2
f 1/1/3 10/7/3 11/8/3
f 2/9/4 6/10/4 12/11/4
f 3/12/5 7/13/5 13/14/5
f 5/4/6 15/15/6 8/16/6
f 6/17/2 9/18/2 7/19/2
f 7/20/2 9/18/2 8/16/2
f 9/21/2 6/10/2 5/22/2
f 2/9/3 11/23/3 6/24/3
f 6/17/3 10/7/3 5/25/3
f 11/26/3 2/27/3 1/28/3
f 3/12/4 12/29/4 7/19/4
f 7/20/4 12/29/4 6/24/4
f 12/30/4 3/31/4 2/32/4
f 8/33/5 4/34/5 13/14/5
f 13/35/5 4/34/5 3/36/5
f 13/35/5 7/13/5 8/16/5
f 4/37/1 14/2/1 3/36/1
f 14/38/1 1/39/1 2/32/1
f 3/12/1 14/2/1 2/32/1
f 8/33/6 15/15/6 4/3/6
f 4/37/6 15/15/6 1/28/6
f 15/40/6 5/41/6 1/28/6
f 1/1/3 5/41/3 10/7/3
f 6/17/3 11/23/3 10/7/3
......@@ -31,13 +31,13 @@ object MainGameLoop {
// val texture = ModelTexture(loader.loadTexture("stallTexture"), 10, 1)
val texturedModel = TexturedModel(model, texture)
val boxModel = new TexturedModel(OBJLoader2.loadOBJModel("cube", loader), ModelTexture(loader.loadTexture("dark-brown")))
val boxModel = new TexturedModel(OBJLoader2.loadOBJModel("cube", loader), ModelTexture(loader.loadTexture("white"), 10,1))
val entity = Entity(texturedModel, new Vector3f(0, 0, 25), 0, 0, 0, 1)
val boxEntity = Entity(boxModel, new Vector3f(0,-1,-10), 0, 90, 0, 1)
val boxEntity = Entity(boxModel, new Vector3f(0,0,0), 0, 90, 0, 1)
// val boxEntity2 = Entity(boxModel, new Vector3f(1.5f, 0.5f, 0.5f), 0, 0, 0, 1)
val light = new Light(new Vector3f(20, 30, -25), new Vector3f(1, 1, 1))
val light = new Light(new Vector3f(0, 20, 0), new Vector3f(1, 1, 1))
// val terrain: Terrain = new Terrain(0, 0, loader, new ModelTexture(loader.loadTexture("grass")))
// val terrain2: Terrain = new Terrain(1, 0, loader, new ModelTexture(loader.loadTexture("image")))
......@@ -47,6 +47,7 @@ object MainGameLoop {
val renderer = new MasterRenderer()
while (!GLFW.glfwWindowShouldClose(DisplayManager.window)) {
entity.increaseRotation(0, 1, 0)
boxEntity.increaseRotation(0, 1, 0)
camera.move()
// renderer.processTerrain(terrain)
......
......@@ -31,4 +31,5 @@ void main(void) {
vec3 finalSpecular = dampedFactor * reflectivity * lightColour;
out_Colour = vec4(diffuse, 1.0) * texture(textureSampler, pass_textureCoords) + vec4(finalSpecular,1.0);
//out_Colour = vec4(diffuse, 1.0) * texture(textureSampler, pass_textureCoords) ;
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ void main(void) {
gl_Position = projectionMatrix * viewMatrix * worldPosition;
pass_textureCoords = textureCoords;
surfaceNormal = (transformationMatrix * vec4(normal, 0.0)).xyz;
surfaceNormal = (transformationMatrix * vec4(normal, 1.0)).xyz;
toLightVector = lightPosition - worldPosition.xyz;
toCameraVector = (inverse(viewMatrix) * vec4(0.0, 0.0, 0.0, 1.0)).xyz - worldPosition.xyz;
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment