Added some model loading and removed an useless file.
This commit is contained in:
@@ -39,7 +39,7 @@ import com.badlogic.gdx.graphics.g3d.loader.G3dModelLoader;
|
|||||||
import com.badlogic.gdx.math.Matrix3;
|
import com.badlogic.gdx.math.Matrix3;
|
||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
import com.badlogic.gdx.utils.GdxRuntimeException;
|
import com.badlogic.gdx.utils.GdxRuntimeException;
|
||||||
import com.badlogic.gdx.utils.JsonReader;
|
import com.badlogic.gdx.utils.UBJsonReader;
|
||||||
|
|
||||||
public class BombGameEntityCreator extends EntityCreatorBase{
|
public class BombGameEntityCreator extends EntityCreatorBase{
|
||||||
private static final String TAG = "BOMB_ENTITY_CREATOR";
|
private static final String TAG = "BOMB_ENTITY_CREATOR";
|
||||||
@@ -75,12 +75,12 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
private int currentBombId;
|
private int currentBombId;
|
||||||
|
|
||||||
public BombGameEntityCreator(){
|
public BombGameEntityCreator(){
|
||||||
G3dModelLoader loader = new G3dModelLoader(new JsonReader());
|
G3dModelLoader loader = new G3dModelLoader(new UBJsonReader());
|
||||||
currentBombId = 0;
|
currentBombId = 0;
|
||||||
|
|
||||||
parameters = new EntityParameters();
|
parameters = new EntityParameters();
|
||||||
parameters.environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.3f, 0.3f, 0.3f, 1.0f));
|
parameters.environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.3f, 0.3f, 0.3f, 1.0f));
|
||||||
parameters.environment.add(new DirectionalLight().set(new Color(1, 1, 1, 1), new Vector3(1, 0, -0.5f)));
|
parameters.environment.add(new DirectionalLight().set(new Color(1, 1, 1, 1), new Vector3(0, 0, -1)));
|
||||||
|
|
||||||
// Load the shader.
|
// Load the shader.
|
||||||
shader = new DirectionalLightPerPixelShader();
|
shader = new DirectionalLightPerPixelShader();
|
||||||
@@ -95,15 +95,15 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
// Create the models.
|
// Create the models.
|
||||||
// TODO: Set the correct model paths.
|
// TODO: Set the correct model paths.
|
||||||
// TODO: Load collision models.
|
// TODO: Load collision models.
|
||||||
doorModel = loader.loadModel(Gdx.files.internal("assets/models/render_models/"));
|
doorModel = loader.loadModel(Gdx.files.internal("models/render_models/bomb_game/door.g3db"));
|
||||||
doorFrameModel = loader.loadModel(Gdx.files.internal("assets/models/render_models/"));
|
doorFrameModel = loader.loadModel(Gdx.files.internal("models/render_models/bomb_game/door_frame1.g3db"));
|
||||||
bombModelCombination = loader.loadModel(Gdx.files.internal("assets/models/render_models/"));
|
// bombModelCombination = loader.loadModel(Gdx.files.internal("models/render_models/bomb_game/"));
|
||||||
bombModelInclination = loader.loadModel(Gdx.files.internal("assets/models/render_models/"));
|
// bombModelInclination = loader.loadModel(Gdx.files.internal("models/render_models/bomb_game/"));
|
||||||
bombModelWires = loader.loadModel(Gdx.files.internal("assets/models/render_models/"));
|
bombModelWires = loader.loadModel(Gdx.files.internal("models/render_models/bomb_game/bomb_1_body.g3db"));
|
||||||
easterEggModel = loader.loadModel(Gdx.files.internal("assets/models/render_models/"));
|
// easterEggModel = loader.loadModel(Gdx.files.internal("models/render_models/bomb_game/"));
|
||||||
bombModelWiresWire1 = loader.loadModel(Gdx.files.internal("assets/models/render_models/"));
|
bombModelWiresWire1 = loader.loadModel(Gdx.files.internal("models/render_models/bomb_game/cable_1.g3db"));
|
||||||
bombModelWiresWire2 = loader.loadModel(Gdx.files.internal("assets/models/render_models/"));
|
bombModelWiresWire2 = loader.loadModel(Gdx.files.internal("models/render_models/bomb_game/cable_2.g3db"));
|
||||||
bombModelWiresWire3 = loader.loadModel(Gdx.files.internal("assets/models/render_models/"));
|
bombModelWiresWire3 = loader.loadModel(Gdx.files.internal("models/render_models/bomb_game/cable_3.g3db"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -111,23 +111,23 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
// TODO: Add the robot arms.
|
// TODO: Add the robot arms.
|
||||||
|
|
||||||
// Add bombs.
|
// Add bombs.
|
||||||
parameters.markerCode = 89;
|
// parameters.markerCode = 89;
|
||||||
addBomb(parameters, bomb_type_t.COMBINATION);
|
// addBomb(parameters, bomb_type_t.COMBINATION);
|
||||||
|
//
|
||||||
parameters.markerCode = 90;
|
// parameters.markerCode = 90;
|
||||||
addBomb(parameters, bomb_type_t.INCLINATION);
|
// addBomb(parameters, bomb_type_t.INCLINATION);
|
||||||
|
|
||||||
parameters.markerCode = 91;
|
parameters.markerCode = 91;
|
||||||
addBomb(parameters, bomb_type_t.WIRES);
|
addBomb(parameters, bomb_type_t.WIRES);
|
||||||
|
|
||||||
// Add doors.
|
// Add doors.
|
||||||
parameters.nextAnimation = 0;
|
parameters.nextAnimation = 1;
|
||||||
parameters.loopAnimation = false;
|
parameters.loopAnimation = false;
|
||||||
|
|
||||||
parameters.markerCode = 89;
|
// parameters.markerCode = 89;
|
||||||
addDoor(parameters);
|
// addDoor(parameters);
|
||||||
parameters.markerCode = 90;
|
// parameters.markerCode = 90;
|
||||||
addDoor(parameters);
|
// addDoor(parameters);
|
||||||
parameters.markerCode = 91;
|
parameters.markerCode = 91;
|
||||||
addDoor(parameters);
|
addDoor(parameters);
|
||||||
}
|
}
|
||||||
@@ -170,6 +170,7 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
bomb.addComponent(bombComponent);
|
bomb.addComponent(bombComponent);
|
||||||
bomb.addComponent(new VisibilityComponent());
|
bomb.addComponent(new VisibilityComponent());
|
||||||
|
|
||||||
|
// Add the collision and render models depending on the bomb type.
|
||||||
if(type == bomb_type_t.COMBINATION){
|
if(type == bomb_type_t.COMBINATION){
|
||||||
bomb.addComponent(new RenderModelComponent(bombModelCombination));
|
bomb.addComponent(new RenderModelComponent(bombModelCombination));
|
||||||
}else if(type == bomb_type_t.INCLINATION){
|
}else if(type == bomb_type_t.INCLINATION){
|
||||||
@@ -195,6 +196,7 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
wire1.addComponent(new RenderModelComponent(bombModelWiresWire1));
|
wire1.addComponent(new RenderModelComponent(bombModelWiresWire1));
|
||||||
wire1.addComponent(new BombComponent(bomb));
|
wire1.addComponent(new BombComponent(bomb));
|
||||||
wire1.addComponent(new VisibilityComponent());
|
wire1.addComponent(new VisibilityComponent());
|
||||||
|
wire1.addComponent(new MarkerCodeComponent(parameters.markerCode));
|
||||||
wire1.addToWorld();
|
wire1.addToWorld();
|
||||||
|
|
||||||
wire2 = world.createEntity();
|
wire2 = world.createEntity();
|
||||||
@@ -204,6 +206,7 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
wire2.addComponent(new RenderModelComponent(bombModelWiresWire2));
|
wire2.addComponent(new RenderModelComponent(bombModelWiresWire2));
|
||||||
wire2.addComponent(new BombComponent(bomb));
|
wire2.addComponent(new BombComponent(bomb));
|
||||||
wire2.addComponent(new VisibilityComponent());
|
wire2.addComponent(new VisibilityComponent());
|
||||||
|
wire2.addComponent(new MarkerCodeComponent(parameters.markerCode));
|
||||||
wire2.addToWorld();
|
wire2.addToWorld();
|
||||||
|
|
||||||
wire3 = world.createEntity();
|
wire3 = world.createEntity();
|
||||||
@@ -213,6 +216,7 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
wire3.addComponent(new RenderModelComponent(bombModelWiresWire3));
|
wire3.addComponent(new RenderModelComponent(bombModelWiresWire3));
|
||||||
wire3.addComponent(new BombComponent(bomb));
|
wire3.addComponent(new BombComponent(bomb));
|
||||||
wire3.addComponent(new VisibilityComponent());
|
wire3.addComponent(new VisibilityComponent());
|
||||||
|
wire3.addComponent(new MarkerCodeComponent(parameters.markerCode));
|
||||||
wire3.addToWorld();
|
wire3.addToWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2014 Miguel Angel Astor Romero
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package ve.ucv.ciens.ccg.nxtar.exceptions;
|
|
||||||
|
|
||||||
public class ShaderFailedToLoadException extends Exception {
|
|
||||||
private static final long serialVersionUID = 9989L;
|
|
||||||
|
|
||||||
public ShaderFailedToLoadException(String msg){
|
|
||||||
super(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,6 +36,8 @@ public class DirectionalLightPerPixelShader implements Shader{
|
|||||||
private static final String VERTEX_SHADER_PATH = "shaders/directionalPerPixelSingleLight/directionalPerPixel_vert.glsl";
|
private static final String VERTEX_SHADER_PATH = "shaders/directionalPerPixelSingleLight/directionalPerPixel_vert.glsl";
|
||||||
private static final String FRAGMENT_SHADER_PATH = "shaders/directionalPerPixelSingleLight/directionalPerPixel_frag.glsl";
|
private static final String FRAGMENT_SHADER_PATH = "shaders/directionalPerPixelSingleLight/directionalPerPixel_frag.glsl";
|
||||||
private static final String INCLUDE_SKINNING = "#define SKINNING\n";
|
private static final String INCLUDE_SKINNING = "#define SKINNING\n";
|
||||||
|
private static final float DEFAULT_SHININESS = 50.0f;
|
||||||
|
private static final Vector3 DEFAULT_LIGHT = new Vector3(1, 1, 1);
|
||||||
|
|
||||||
private ShaderProgram skinningProgram;
|
private ShaderProgram skinningProgram;
|
||||||
private ShaderProgram baseProgram;
|
private ShaderProgram baseProgram;
|
||||||
@@ -134,22 +136,8 @@ public class DirectionalLightPerPixelShader implements Shader{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRender(Renderable renderable){
|
public boolean canRender(Renderable renderable){
|
||||||
// Check for all needed lighting and material attributes.
|
// Easier to always return true. Missing material properties are replaced by
|
||||||
if(renderable.environment.directionalLights.size < 1)
|
// default values during render.
|
||||||
return false;
|
|
||||||
|
|
||||||
if(!renderable.environment.has(ColorAttribute.AmbientLight))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(!renderable.material.has(ColorAttribute.Diffuse))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(!renderable.material.has(ColorAttribute.Specular))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(!renderable.material.has(FloatAttribute.Shininess))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,14 +159,41 @@ public class DirectionalLightPerPixelShader implements Shader{
|
|||||||
ShaderProgram program;
|
ShaderProgram program;
|
||||||
int index;
|
int index;
|
||||||
boolean bonesEnabled;
|
boolean bonesEnabled;
|
||||||
|
Vector3 lightPosition;
|
||||||
|
Color diffuseLightColor;
|
||||||
|
Color diffuseColor;
|
||||||
|
Color specularColor;
|
||||||
|
Color ambientColor;
|
||||||
|
float shininess;
|
||||||
|
|
||||||
// Get material colors.
|
// Get material colors.
|
||||||
Vector3 lightPosition = renderable.environment.directionalLights.get(0).direction;
|
if(renderable.environment.directionalLights.size >= 1){
|
||||||
Color diffuseLightColor = renderable.environment.directionalLights.get(0).color;
|
lightPosition = renderable.environment.directionalLights.get(0).direction;
|
||||||
Color diffuseColor = ((ColorAttribute)renderable.material.get(ColorAttribute.Diffuse)).color;
|
diffuseLightColor = renderable.environment.directionalLights.get(0).color;
|
||||||
Color specularColor = ((ColorAttribute)renderable.material.get(ColorAttribute.Specular)).color;
|
}else{
|
||||||
Color ambientColor = ((ColorAttribute)renderable.environment.get(ColorAttribute.AmbientLight)).color;
|
lightPosition = DEFAULT_LIGHT;
|
||||||
float shininess = ((FloatAttribute)renderable.material.get(FloatAttribute.Shininess)).value;
|
diffuseLightColor = Color.WHITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(renderable.material.has(ColorAttribute.Diffuse))
|
||||||
|
diffuseColor = ((ColorAttribute)renderable.material.get(ColorAttribute.Diffuse)).color;
|
||||||
|
else
|
||||||
|
diffuseColor = Color.WHITE;
|
||||||
|
|
||||||
|
if(renderable.material.has(ColorAttribute.Specular))
|
||||||
|
specularColor = ((ColorAttribute)renderable.material.get(ColorAttribute.Specular)).color;
|
||||||
|
else
|
||||||
|
specularColor = Color.BLACK;
|
||||||
|
|
||||||
|
if(renderable.environment.has(ColorAttribute.AmbientLight))
|
||||||
|
ambientColor = ((ColorAttribute)renderable.environment.get(ColorAttribute.AmbientLight)).color;
|
||||||
|
else
|
||||||
|
ambientColor = Color.BLACK;
|
||||||
|
|
||||||
|
if(renderable.material.has(FloatAttribute.Shininess))
|
||||||
|
shininess = ((FloatAttribute)renderable.material.get(FloatAttribute.Shininess)).value;
|
||||||
|
else
|
||||||
|
shininess = DEFAULT_SHININESS;
|
||||||
|
|
||||||
if(renderable.mesh.getVertexAttribute(VertexAttributes.Usage.BoneWeight) != null){
|
if(renderable.mesh.getVertexAttribute(VertexAttributes.Usage.BoneWeight) != null){
|
||||||
program = skinningProgram;
|
program = skinningProgram;
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ public class InGameState extends BaseState{
|
|||||||
perspectiveCamera.lookAt(0.0f, 0.0f, -1.0f);
|
perspectiveCamera.lookAt(0.0f, 0.0f, -1.0f);
|
||||||
perspectiveCamera.update();
|
perspectiveCamera.update();
|
||||||
|
|
||||||
gameWorld.getSystem(VisibilitySystem.class).setCamera(perspectiveCamera);
|
// gameWorld.getSystem(VisibilitySystem.class).setCamera(perspectiveCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to find the markers in the current video frame.
|
// Attempt to find the markers in the current video frame.
|
||||||
|
|||||||
@@ -38,12 +38,14 @@ public class AnimationSystem extends EntityProcessingSystem {
|
|||||||
protected void process(Entity e) {
|
protected void process(Entity e) {
|
||||||
AnimationComponent animation = animationMapper.get(e);
|
AnimationComponent animation = animationMapper.get(e);
|
||||||
VisibilityComponent visibility = visibilityMapper.get(e);
|
VisibilityComponent visibility = visibilityMapper.get(e);
|
||||||
|
int loopCount = animation.loop ? -1 : 1;
|
||||||
|
|
||||||
if(animation.current != animation.next && animation.next >= 0 && animation.next < animation.animationsIds.size()){
|
if(animation.current != animation.next && animation.next >= 0 && animation.next < animation.animationsIds.size()){
|
||||||
if(animation.loop)
|
if(animation.controller.current == null){
|
||||||
animation.controller.animate(animation.animationsIds.get(animation.next), -1, 1, null,0.1f);
|
animation.controller.setAnimation(animation.animationsIds.get(animation.next), loopCount, 1, null);
|
||||||
else
|
}else{
|
||||||
animation.controller.animate(animation.animationsIds.get(animation.next), 1, 1, null,0.1f);
|
animation.controller.animate(animation.animationsIds.get(animation.next), loopCount, 1, null, 0.1f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(visibility.visible)
|
if(visibility.visible)
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.utils;
|
package ve.ucv.ciens.ccg.nxtar.utils;
|
||||||
|
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.entities.BombGameEntityCreator;
|
||||||
import ve.ucv.ciens.ccg.nxtar.entities.EntityCreatorBase;
|
import ve.ucv.ciens.ccg.nxtar.entities.EntityCreatorBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.entities.MarkerTestEntityCreator;
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.GameLogicSystemBase;
|
import ve.ucv.ciens.ccg.nxtar.systems.GameLogicSystemBase;
|
||||||
|
|
||||||
public abstract class GameSettings{
|
public abstract class GameSettings{
|
||||||
@@ -24,7 +24,7 @@ public abstract class GameSettings{
|
|||||||
public static GameLogicSystemBase gameLogicSystem = null;
|
public static GameLogicSystemBase gameLogicSystem = null;
|
||||||
|
|
||||||
public static void initGameSettings(){
|
public static void initGameSettings(){
|
||||||
entityCreator = new MarkerTestEntityCreator();
|
entityCreator = new BombGameEntityCreator();
|
||||||
gameLogicSystem = null;
|
gameLogicSystem = null;
|
||||||
//gameLogicSystem = new BombGameLogicSystem();
|
//gameLogicSystem = new BombGameLogicSystem();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user