Skip to content

Commit

Permalink
Fixed quick model loader bug causing a crash; tweaked some settings a…
Browse files Browse the repository at this point in the history
…nd improved the material loader;
  • Loading branch information
Andrei Bârsan committed May 22, 2013
1 parent f3e5383 commit 6fa2308
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion res/models/LS.mtl
Expand Up @@ -22,6 +22,6 @@ newmtl LS_Shader_Base
Kd 0.588000 0.588000 0.588000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
#map_Kd LS_Diffuse_A.png
map_Kd LS_Diffuse_A.png
#map_Ks LS_Rim_A.png
#map_bump LS_NormalMap.png
2 changes: 1 addition & 1 deletion src/barsan/opengl/input/FreeflyCamera.java
Expand Up @@ -14,7 +14,7 @@ public class FreeflyCamera extends PerspectiveCamera {
float speed = 0.0f;
float rotSpeed = 0.0f;

final float MAXSPEED = 60.0f;
final float MAXSPEED = 30.0f;
final float FRICTION = 20.0f;
final float ACCELERATION = 15.0f;
final float ACCMUL = 8f;
Expand Down
3 changes: 2 additions & 1 deletion src/barsan/opengl/rendering/Nessie.java
Expand Up @@ -491,6 +491,7 @@ private void renderPLVol(PointLight l, boolean computeLight) {
lightPassTechnique.drawPointLight(plVolume, l, state);
}
else {
plVolume.getMaterial().setDiffuse(l.getDiffuse());
flatTechnique.renderDude(plVolume, state, nullStack);
}
}
Expand Down Expand Up @@ -534,6 +535,7 @@ private void renderSLVol(SpotLight l, boolean computeLight) {
prepareLightPass(state);
lightPassTechnique.drawSpotLight(slVolume, l, state);
} else {
slVolume.getMaterial().setDiffuse(l.getDiffuse());
flatTechnique.renderDude(slVolume, state, nullStack);
}
}
Expand All @@ -556,7 +558,6 @@ public void finalizePass(Scene scene) {
break;

case DrawGBuffer:
//gbuffer.bindForInspection();
gbuffer.bindForFinalPass();

int w = Yeti.get().settings.width;
Expand Down
6 changes: 5 additions & 1 deletion src/barsan/opengl/resources/MTLLoader.java
Expand Up @@ -36,7 +36,7 @@ public static List<Material> load(String fileName) {
}
}
String cmd = tokens[0];
String[] params = Arrays.copyOfRange(tokens, 1, tokens.length - 1);
String[] params = Arrays.copyOfRange(tokens, 1, tokens.length);

if(cmd.equals("newmtl")) {
current = new Material();
Expand All @@ -56,13 +56,17 @@ else if(cmd.equals("Ns")) {
}
else if(tokens[0].equals("map_Kd")) {
String textureName = tokens[1];
Yeti.debug(String.format("Loading texture dependency of material %s: %s",
current.getName(), textureName));
ResourceLoader.loadTexture(textureName);
current.setDiffuseMap(ResourceLoader.texture(
textureName.substring(0, textureName.lastIndexOf('.'))
));
}
else if(tokens[0].equals("map_Bump") || tokens[0].equals("map_bump")) {
String textureName = tokens[1];
Yeti.debug(String.format("Loading texture dependency of material %s: %s",
current.getName(), textureName));
ResourceLoader.loadTexture(textureName);
current.setNormalMap(ResourceLoader.texture(
textureName.substring(0, textureName.lastIndexOf('.'))
Expand Down
6 changes: 5 additions & 1 deletion src/barsan/opengl/scenes/NessieTestScene.java
Expand Up @@ -73,7 +73,7 @@ public void init(GLAutoDrawable drawable) {
ResourceLoader.loadObj("DR_sphere", "dr_icosphere.obj");
ResourceLoader.loadObj("sphere", "sphere.obj");
ResourceLoader.loadObj("DR_cone", "cone.obj");
// ResourceLoader.loadObj("LS", "LS.obj", 3);
ResourceLoader.loadObj("LS", "LS.obj", 3);

ResourceLoader.loadObj("hm", "The_Handyman.obj");

Expand All @@ -92,6 +92,10 @@ public void init(GLAutoDrawable drawable) {
// h.getTransform().updateScale(0.1f);

addModelInstance(h);

StaticModelInstance littleSister = new StaticModelInstance(ResourceLoader.model("LS"));
littleSister.getTransform().updateScale(0.06f);
addModelInstance(littleSister);

floor = new StaticModelInstance(ModelLoader.buildPlane(
100.0f, 100.0f, 10, 10));
Expand Down

0 comments on commit 6fa2308

Please sign in to comment.