Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasJC committed Nov 24, 2016
1 parent 3dc0900 commit b012402
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
16 changes: 14 additions & 2 deletions TGC.Group/Model/Camera/TgcFpsCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class TgcFpsCamera : TgcCamera
private float JumpingTime = 0f;

private Player player1;
private TgcMesh playerTool;

private float MovementSpeed;

Expand Down Expand Up @@ -91,9 +92,10 @@ public TgcFpsCamera(TgcD3dInput input)
this.PreviousUpVector = DEFAULT_UP_VECTOR;
}

public TgcFpsCamera(Player player1, TgcD3dInput input, float mapXLimit, float mapXNegLimit, float mapZLimit, float mapZNegLimit) : this(input)
public TgcFpsCamera(Player player1, TgcMesh playerTool, TgcD3dInput input, float mapXLimit, float mapXNegLimit, float mapZLimit, float mapZNegLimit) : this(input)
{
this.player1 = player1;
this.playerTool = playerTool;
this.MapXLimit = mapXLimit;
this.MapXNegLimit = mapXNegLimit;
this.MapZLimit = mapZLimit;
Expand Down Expand Up @@ -311,6 +313,16 @@ public override void UpdateCamera(float elapsedTime)
var cameraRotatedUpVector = Vector3.TransformNormal(cameraOriginalUpVector, cameraRotation);

base.SetCamera(positionEye, cameraFinalTarget, cameraRotatedUpVector);

playerTool.AutoTransformEnable = false;
//playerTool.Transform = Matrix.RotationX(-FastMath.QUARTER_PI / 2) * Matrix.RotationY(FastMath.QUARTER_PI) * Matrix.Translation(new Vector3(positionEye.X - 3, positionEye.Y - 15, positionEye.Z - 8));
//playerTool.Position = new Vector3(cameraFinalTarget.X - 3, cameraFinalTarget.Y - 15, cameraFinalTarget.Z - 8);
playerTool.Position = new Vector3(cameraFinalTarget.X, cameraFinalTarget.Y, cameraFinalTarget.Z);
playerTool.Scale = new Vector3(0.1f, 0.1f, 0.1f);
//Matrix.RotationY(FastMath.QUARTER_PI) * Matrix.RotationY(leftrightRot)
playerTool.Transform = Matrix.Scaling(playerTool.Scale) * cameraRotation * Matrix.Translation(playerTool.Position);


}
}

Expand All @@ -336,7 +348,7 @@ public override void SetCamera(Vector3 position, Vector3 directionView)

public void render()
{
//if(null != player1.EquippedTool) axe.render();
//if(null != player1.EquippedTool) playerTool.render();
}
}
}
10 changes: 9 additions & 1 deletion TGC.Group/Model/Effects/EffectsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class EffectsManager : Renderable
private float ElapsedTime;
private Dictionary<int, float> lightByHour = new Dictionary<int, float>();
private Color skyBoxColor;
//private List<TgcMesh> otherMeshes = new List<TgcMesh>();

public EffectsManager(string shadersDir, GameModel gameModel, World myWorld, float elapsedTime)
{
ShadersDir = shadersDir;
Expand Down Expand Up @@ -125,7 +127,7 @@ public void update()
{
mesh.Effect.SetValue("time", (float) time);
mesh.Effect.SetValue("luz", luz);
}
}
}

private float calculateLight()
Expand All @@ -135,6 +137,12 @@ private float calculateLight()
return result;
}

public void applyEffect(TgcMesh mesh)
{
mesh.Effect = mainEffect;
mesh.Technique = "RenderScene";
}

public void render()
{
throw new NotImplementedException();
Expand Down
15 changes: 8 additions & 7 deletions TGC.Group/Model/GameObjects/GameModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,12 @@ public override void Init()
//creo usuario
Player1 = new Player();
Player1.gameModel = this;

//inicializo mesh para hacha
Axe = loader.loadSceneFromFile(MediaDir + "Meshes\\Hacha\\Hacha-TgcScene.xml").Meshes[0];
Axe.Scale = new Vector3(0.1f, 0.1f, 0.1f);

//Inicializo cámara
MyCamera = new TgcFpsCamera(Player1, Input, (MapLength / 2), -(MapLength / 2), (MapLength / 2), -(MapLength / 2));
MyCamera = new TgcFpsCamera(Player1, Axe, Input, (MapLength / 2), -(MapLength / 2), (MapLength / 2), -(MapLength / 2));
Camara = MyCamera;

Frustum.updateVolume(D3DDevice.Instance.Device.Transform.View, D3DDevice.Instance.Device.Transform.Projection);
Expand All @@ -137,6 +138,8 @@ public override void Init()
//inicializo efectos
effectsManager = new EffectsManager(ShadersDir, this, MyWorld, ElapsedTime);

effectsManager.applyEffect(Axe);

//emisor de partículas
emitter = new ParticleEmitter(MediaDir + "Textures\\smokeParticle.png", 10);
emitter.Position = new Vector3(0, 0, 0);
Expand Down Expand Up @@ -455,7 +458,7 @@ private void updateDayTime(float elapsedTime)
private void checkTimeEvents()
{

if (this.Seconds > 0 && this.Seconds % 10 == 0)
if (this.Seconds > 0 && this.Seconds % 7 == 0)
{
MyWorld.changeWind();
}
Expand All @@ -474,6 +477,8 @@ private void checkTimeEvents()
}
}

float acuTime = 0;

/// <summary>
/// Se llama cada vez que hay que refrescar la pantalla.
/// Escribir aquí todo el código referido al renderizado.
Expand All @@ -494,10 +499,6 @@ public override void Render()

MyCamera.render();

//Axe.Position = MyCamera.Position;
Axe.Transform = Matrix.Translation(new Vector3(0, 0, 0)) * Matrix.RotationY(FastMath.Sin(ElapsedTime * 0.5f)) * Matrix.Translation(Axe.Position) * Matrix.Scaling(Axe.Scale);
Axe.render();

if (null != pickedObject)
{
//un objeto fue objetivo de una acción
Expand Down

0 comments on commit b012402

Please sign in to comment.