Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge de dev a Relese #51

Open
wants to merge 184 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
cb6e337
Update README.md
LucasGelabert Apr 24, 2024
c3c89a4
avances
SantiSauce Apr 28, 2024
05f9de7
avances
SantiSauce Apr 28, 2024
e7a4998
primer aproximiacion para agregar las texturas de la casa
tomasZubizarreta Apr 28, 2024
9330626
añadimos estructuras
SimonCutreraUTN Apr 29, 2024
616bb64
Agregado el basicEffect pero ahora la textura es negra
tomasZubizarreta Apr 29, 2024
2f7700c
Arreglos Varios, Eliminacion de TGCGames y remplazo por TankGame
LucasGelabert Apr 29, 2024
adeffba
Eliminacion de TGCGames y remplazo por TankGame
LucasGelabert Apr 29, 2024
86aae86
Git Merge Conflict Resuelto
LucasGelabert Apr 29, 2024
b71f1ed
Movimiento De Torreta Beta
LucasGelabert Apr 29, 2024
c4ca926
Avances, check en mapScene
SantiSauce Apr 30, 2024
b67d440
Correccion
SantiSauce Apr 30, 2024
511d2c9
var para obstaculos
SimonCutreraUTN Apr 30, 2024
a991348
añado bordes
SimonCutreraUTN Apr 30, 2024
0c5d353
avances
SantiSauce Apr 30, 2024
13a6219
Update README - Nombres.md
LucasGelabert Apr 30, 2024
02a152c
Free Camera Update
LucasGelabert May 1, 2024
7ff69aa
Avances
SantiSauce May 1, 2024
36635b0
Update 0.1.0 Tank Movement
LucasGelabert May 7, 2024
15fc6f4
Modificaciones Varias 1 .md
LucasGelabert May 7, 2024
6dbc3f5
Update README.md
LucasGelabert May 7, 2024
2603367
Fix
LucasGelabert May 14, 2024
01ee113
Agregados proyectiles
tomasZubizarreta May 14, 2024
c9d5cd8
ManageShoot (Fix V1.0)
LucasGelabert May 16, 2024
48c550e
Collisions (V1.0)
tomasZubizarreta May 16, 2024
130d3af
Avances - Sin basic effect
SantiSauce May 20, 2024
2e95736
Se agregan texturas
SantiSauce May 20, 2024
78ce58b
Avances
SantiSauce May 20, 2024
c478f8c
correccion torreta
SantiSauce May 20, 2024
58efd49
Movimiento Tanque y camara
LucasGelabert May 20, 2024
16abbae
parte de las colisiones y cambios en la bala del tanque
tomasZubizarreta May 21, 2024
5aa7add
Rocket
tomasZubizarreta May 21, 2024
7dada9a
agregados logs para verificar comportamiento
tomasZubizarreta May 21, 2024
a160d01
correcciones en bounding boxes
tomasZubizarreta May 21, 2024
567eb05
Se agrega rotacion de enemigos
SantiSauce May 21, 2024
eedc7f1
Se agregan tanques enemigos
SantiSauce May 21, 2024
721971f
casi colisiones
tomasZubizarreta May 22, 2024
fdcd69d
Merge remote-tracking branch 'origin/dev' into Relese
tomasZubizarreta May 22, 2024
f0edcdf
mios
LucasGelabert May 22, 2024
96bed1d
Mios-2
LucasGelabert May 22, 2024
bac7f79
Intento de gizmo
SantiSauce May 22, 2024
1a915f6
Merge
LucasGelabert May 22, 2024
c7bd5d6
Merge branch 'dev' into Relese
LucasGelabert May 22, 2024
99cdf04
git
LucasGelabert May 22, 2024
0a34668
Correxion Errores
LucasGelabert May 22, 2024
4c624de
Gizmos
SantiSauce May 22, 2024
f16a067
Merge branch 'dev' into Relese
LucasGelabert May 22, 2024
d81b4d3
Correccion Shader
SantiSauce May 22, 2024
bed360b
Arreglos Varios De Codigo
LucasGelabert May 22, 2024
0b0febd
Correxiones Varias
LucasGelabert May 22, 2024
c0ed4b0
Arreglos Varios
LucasGelabert May 23, 2024
a6d77f3
agrego mipmapping
SimonCutreraUTN Jun 2, 2024
3149f61
Fix Errores Varios y Mira
LucasGelabert Jun 2, 2024
5b71636
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
LucasGelabert Jun 2, 2024
6d79281
Colisiones v1.1
tomasZubizarreta Jun 2, 2024
3b53a2e
Fix Colitions
LucasGelabert Jun 3, 2024
8592e0d
Fix Mira y Bullet
LucasGelabert Jun 3, 2024
89bc4c4
Modificacion de proyectil y fix mira
LucasGelabert Jun 3, 2024
4025eba
Se agrega menu
SantiSauce Jun 3, 2024
73f86ff
Se agrega logica de colision
SantiSauce Jun 3, 2024
6d54635
Avances
SantiSauce Jun 4, 2024
458e56a
cambios en proyectiles y en casa
tomasZubizarreta Jun 4, 2024
c94181b
Gizmos
SimonCutreraUTN Jun 4, 2024
454c3d8
Colisiones
tomasZubizarreta Jun 4, 2024
f2dde71
Se agregan texturas
SantiSauce Jun 4, 2024
89af88e
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
SantiSauce Jun 4, 2024
8d54287
Avances Menu
SantiSauce Jun 4, 2024
0d1755c
mipmapping arboles
SimonCutreraUTN Jun 4, 2024
a8ab42c
Avances
SantiSauce Jun 4, 2024
931aac6
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
SantiSauce Jun 4, 2024
570dae0
Avances
SantiSauce Jun 4, 2024
84b1fe5
base de hud
SimonCutreraUTN Jun 4, 2024
c54eece
merge y principio de hud
SimonCutreraUTN Jun 4, 2024
5743214
add: hud
SimonCutreraUTN Jun 4, 2024
9003f09
Agrego Props
LucasGelabert Jun 4, 2024
1364cf7
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
LucasGelabert Jun 4, 2024
490f77f
fix
SimonCutreraUTN Jun 4, 2024
584e0dd
Fix Varios
LucasGelabert Jun 4, 2024
082b4d6
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
LucasGelabert Jun 4, 2024
0ac2aa2
Disparan tanques enemigos
tomasZubizarreta Jun 4, 2024
9b1afc1
tanques enemigos hacen daño
tomasZubizarreta Jun 5, 2024
436dfa6
Se agregan texturas
SantiSauce Jun 5, 2024
a856d40
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
SantiSauce Jun 5, 2024
74aea8d
Intento de agregar modelo en menu
SantiSauce Jun 5, 2024
293c2df
Merge
LucasGelabert Jun 5, 2024
02217a7
Fix Movimiento Bounding Boxes
LucasGelabert Jun 5, 2024
34413e8
Fix Errors
LucasGelabert Jun 5, 2024
4564b2c
Ordenamiento de codigo
LucasGelabert Jun 5, 2024
1ffc8cc
Fix autodisparo (Coliciones)
LucasGelabert Jun 7, 2024
58c6ddb
Fix: BoundingBox de TanquesEnemigos. Optimizacion Projectiles
LucasGelabert Jun 10, 2024
9c25924
Fix: Crosshair, Tanque 3D del menu, Ordenamiento de codigo y dependen…
LucasGelabert Jun 11, 2024
69513de
Add: Textos Menu, Audio Engine, Nuevo Spawn, Varios
LucasGelabert Jun 11, 2024
5506b28
Fix: Se arreglo el error de posicion erronea de tanque
LucasGelabert Jun 11, 2024
982b328
Se agrega logica de lifeBar
SantiSauce Jun 12, 2024
e8dcfef
Trate de agregar transformacion de vertices en tanque
SantiSauce Jun 12, 2024
e4a6387
shader deformacion al impacto
SimonCutreraUTN Jun 13, 2024
a09971f
My Changes
LucasGelabert Jun 13, 2024
825b2cf
My Changes 2
LucasGelabert Jun 13, 2024
22428ab
My Changes
LucasGelabert Jun 13, 2024
4e38efd
Add: Contador de FPS; Fix: Organizacion Varia
LucasGelabert Jun 13, 2024
8d033d2
los tres tanques enemigos disparan en distintos intervalos
tomasZubizarreta Jun 14, 2024
a13fcc5
Fix: FPS ahora se muestran correctamente
LucasGelabert Jun 14, 2024
b6197be
Add: Nuevo modelo de tanque enemigo
LucasGelabert Jun 15, 2024
7a136fe
agregado moviemento de oruga
tomasZubizarreta Jun 16, 2024
0385576
Add: Hierva, Character en el menu
LucasGelabert Jun 17, 2024
42ddb1e
Fix: TextureCoordenates, Add: Grass, Character Model
LucasGelabert Jun 17, 2024
7eb0969
Se agrega iluminacion
SantiSauce Jun 19, 2024
1f1df8f
Add: Nuevos modelos de Arboles, Rotacion de Piedras
LucasGelabert Jun 21, 2024
fd35bcb
Fix: Random pasa a ser variable global
LucasGelabert Jun 21, 2024
4e41bdf
Fix: BoundingBox de Casa Add: New Model MiniShack
LucasGelabert Jun 22, 2024
a0fc01e
Intento de heightmap
SantiSauce Jun 23, 2024
c88af35
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
SantiSauce Jun 23, 2024
9d74aa6
Cambios en el comportamiento del Tanque enemigo.
tomasZubizarreta Jun 23, 2024
f879a42
Se agrega lightBox
SantiSauce Jun 24, 2024
67b2acd
Avances
SantiSauce Jun 24, 2024
0889f80
Corrección
SantiSauce Jun 24, 2024
513531c
shader de impacto casi terminado
SimonCutreraUTN Jun 24, 2024
d303887
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
SimonCutreraUTN Jun 24, 2024
0dea471
impact shader full sin balas ni acumulativo
SimonCutreraUTN Jun 24, 2024
7c80be3
Avance heightMap
SantiSauce Jun 24, 2024
4afbf99
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
SantiSauce Jun 24, 2024
e68cd85
Heightmap funcional
SantiSauce Jun 24, 2024
4397e36
shader de impactos 2.0 (beta)
SimonCutreraUTN Jun 24, 2024
e800255
shader impact experimental
SimonCutreraUTN Jun 24, 2024
00a7e1e
Add: Los Shaders ahora estan unidos y son dos pasadas diferentes
LucasGelabert Jun 25, 2024
fc6f090
Tests
LucasGelabert Jun 25, 2024
6fd9264
fixes
SimonCutreraUTN Jun 25, 2024
cff72c4
ADD: base para posprocessing
SimonCutreraUTN Jun 26, 2024
b91f5b9
agregado el Frustum
tomasZubizarreta Jun 27, 2024
42d92a4
cambios cuando la oruga rota
tomasZubizarreta Jun 27, 2024
d1e6114
Merge branch 'Relese' into dev
LucasGelabert Jun 27, 2024
ee9c362
Merge: Relese into dev
LucasGelabert Jun 27, 2024
ed71e2c
Reordenamiento de codigo y buenas practicas
LucasGelabert Jun 27, 2024
e46e4d7
Fix: Arreglos Varios
LucasGelabert Jun 27, 2024
34e1eb6
sombras (pero no funciona bruh)
SimonCutreraUTN Jun 27, 2024
420002e
merge con shadowing
SimonCutreraUTN Jun 27, 2024
926874a
Mios
LucasGelabert Jun 27, 2024
4b671b4
Fix Merge
LucasGelabert Jun 27, 2024
5e9eb49
Se agrega movimiento tanque - pitch
SantiSauce Jun 29, 2024
b907ab7
Avances - OBB + Gizmo
SantiSauce Jun 30, 2024
666001c
Fix: Varios
LucasGelabert Jun 30, 2024
7f9673c
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
LucasGelabert Jun 30, 2024
8b2151a
colisiones con oriented BB
tomasZubizarreta Jul 1, 2024
12c0242
colisiones con rotacion
tomasZubizarreta Jul 1, 2024
bef4a2d
My Commit
LucasGelabert Jul 1, 2024
b824c0d
fix de impact
SimonCutreraUTN Jul 1, 2024
8158942
Logica de distintas oleadas
tomasZubizarreta Jul 1, 2024
e07fc6a
Merge
LucasGelabert Jul 1, 2024
5fb6c00
Merge Manual
LucasGelabert Jul 1, 2024
7093fe4
shadow ?
SimonCutreraUTN Jul 1, 2024
b7fda37
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
SimonCutreraUTN Jul 1, 2024
12b72c0
System Particle - 1st step
SantiSauce Jul 1, 2024
9b20e9e
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
SantiSauce Jul 1, 2024
746e104
Avances
SantiSauce Jul 2, 2024
12917be
cambios en la logica de los tanques enemigos
tomasZubizarreta Jul 2, 2024
3059180
shadows experim
SimonCutreraUTN Jul 2, 2024
5576157
cambios en la logica de la oleada y los limites del mapa
tomasZubizarreta Jul 2, 2024
d686d83
Add: Intento de Animacion comentado
LucasGelabert Jul 2, 2024
9b6730a
Fix Merge
LucasGelabert Jul 2, 2024
7973fef
light view
SimonCutreraUTN Jul 2, 2024
931a150
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
SimonCutreraUTN Jul 2, 2024
b326ae0
modifico camara light
SimonCutreraUTN Jul 2, 2024
d396dc2
modificacion menor de la lightCamara
SimonCutreraUTN Jul 2, 2024
45add53
Elemetos varios y mira
LucasGelabert Jul 2, 2024
14403c1
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
LucasGelabert Jul 2, 2024
e08cf14
comento shadowmap
SimonCutreraUTN Jul 2, 2024
c76faaa
merge
SimonCutreraUTN Jul 2, 2024
cb5a0c4
Se agrega free camera
SantiSauce Jul 2, 2024
4fd31d6
Avances
SantiSauce Jul 2, 2024
f52f0f8
cambios en enemy Tank
tomasZubizarreta Jul 2, 2024
ce213a9
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
tomasZubizarreta Jul 2, 2024
1e7c1cc
fix de impacto de balas
SimonCutreraUTN Jul 2, 2024
393745e
Merge branch 'dev' of https://github.com/LucasGelabert/2024-1C-3015-T…
SimonCutreraUTN Jul 2, 2024
435cea3
Fotos TGCitos
LucasGelabert Jul 2, 2024
731dc56
FullScreen
LucasGelabert Jul 2, 2024
1ebb43e
Foto Gameplay
LucasGelabert Jul 2, 2024
2e360f2
Update ReadMe
LucasGelabert Jul 3, 2024
8bdd5de
Correccion de paths
LucasGelabert Jul 3, 2024
234913e
Fix ReadMe
LucasGelabert Jul 3, 2024
274a670
Gameplay Screen
LucasGelabert Jul 3, 2024
b6ccd74
Fix: Cambios en codigo y orden de las cosas
LucasGelabert Jul 3, 2024
5d382b9
Arreglos de codigo varios
LucasGelabert Jul 4, 2024
83c68a0
Fix: Pointing Laser, Crosshair
LucasGelabert Jul 4, 2024
3f1ef57
Ordenamiento de codigo y eliminado de archivos innecesarios
LucasGelabert Jul 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions FotosGameplay/Gameplay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions FotosGameplay/Menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions FotosTGCitos/Lucas Gelabert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions FotosTGCitos/Santiago Saucedo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions FotosTGCitos/Simon Cutrera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions FotosTGCitos/Tomas Zubizarreta.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
# TGC - MonoGame - TP
# TGC - MonoGame - Thundering Tanks

[![.NET](https://github.com/tgc-utn/tgc-monogame-tp/actions/workflows/dotnet.yml/badge.svg)](https://github.com/tgc-utn/tgc-monogame-tp/actions/workflows/dotnet.yml)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/63382c4441444632b06d83dcc6dab106)](https://app.codacy.com/gh/tgc-utn/tgc-monogame-tp/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![GitHub license](https://img.shields.io/github/license/tgc-utn/tgc-monogame-tp.svg)](https://github.com/tgc-utn/tgc-monogame-tp/blob/master/LICENSE)

[#BuiltWithMonoGame](http://www.monogame.net) and [.NET Core](https://dotnet.microsoft.com)

## Descripción
## Descripcion
Juego de batalla de tanques creado por estudiantes de la carrera de ingenieria en sistemas de la UTN de buenos aires para la materia Tecnicas De Graficos Por Computadora utilizando el FrameWork Monogame.

Proyecto plantilla para los trabajos prácticos de la asignatura electiva [Técnicas de Gráficos por Computadora](http://tgc-utn.github.io/) (TGC) en la carrera de Ingeniería en Sistemas de Información. Universidad Tecnológica Nacional, Facultad Regional Buenos Aires (UTN-FRBA).

## Configuración del entorno de desarrollo

Los pasos a seguir según su sistema operativo se pueden leer en el siguiente documento [install.md](https://github.com/tgc-utn/tgc-monogame-samples/blob/master/docs/install/install.md).

Afuera del mundo Windows, vas a necesitar la ayudar de [Wine](https://www.winehq.org) para los shaders, por lo menos por [ahora](https://github.com/MonoGame/MonoGame/issues/2167).

Los recursos usados se almacenan utilizando [Git LFS](https://git-lfs.github.com), con lo cual antes de clonar el repositorio les conviene tenerlo instalado así es automático el pull o si ya lo tienen pueden hacer `git lfs pull`.
## Controles
Tecla | Accion
----- | -----
W | Movimiento hacia adelante
A | Rotacion izquierda
S | Movimiento hacia atras
D | Rotacion derecha
C | Debug mode
G | God mode
Click Izquierdo | Disparo de cañon

## Integrantes

TGC, Tgcito | Apellido, Nombre
------------ | -------------
| <img src="https://github.com/tgc-utn/tgc-utn.github.io/blob/master/images/robotgc.png" height="500"> | <img src="https://github.com/tgc-utn/tgc-utn.github.io/blob/master/images/trofeotp.png" height="500"> |
| ![Lucas Gelabert](/FotosTGCitos/Lucas%20Gelabert.png) | Lucas Gelabert |
| ![Santiago Saucedo](/FotosTGCitos/Santiago%20Saucedo.png) | Santiago Saucedo |
| ![Simon Cutrera](/FotosTGCitos/Simon%20Cutrera.png) | Simon Cutrera |
| ![Tomas Zubizarreta](/FotosTGCitos/Tomas%20Zubizarreta.png) | Tomas Zubizarreta |

## Capturas

![screenshot1](https://github.com/tgc-utn/tgc-monogame-tp/blob/master/TGC.MonoGame.TP/Icon.bmp)
![screenshot2](https://github.com/tgc-utn/tgc-monogame-tp/blob/master/TGC.MonoGame.TP/Icon.bmp)
![screenshot3](https://github.com/tgc-utn/tgc-monogame-tp/blob/master/TGC.MonoGame.TP/Icon.bmp)
![screenshot4](https://github.com/tgc-utn/tgc-monogame-tp/blob/master/TGC.MonoGame.TP/Icon.bmp)
![screenshot5](https://github.com/tgc-utn/tgc-monogame-tp/blob/master/TGC.MonoGame.TP/Icon.bmp)
![Menu](/FotosGameplay/Menu.png)

## Game Play
![Gameplay](/FotosGameplay/Gameplay.png)

[![Watch the video](https://img.youtube.com/vi/pgEwUC0jvH4/0.jpg)](https://www.youtube.com/playlist?list=PLRM4L32DjvnazuMl8wZlbpEYL5Qh63ulG)
## Game Play
21 changes: 21 additions & 0 deletions TGC.MonoGame.TP/Animations/DataTypes/AnimationBone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections.Generic;
using ThunderingTanks.Animation;

namespace ThunderingTanks.Animation.DataTypes;

/// <summary>
/// Keyframes are grouped per bone for an animation clip.
/// </summary>
public class AnimationBone
{
/// <summary>
/// The keyframes for this bone.
/// </summary>
public List<Keyframe> Keyframes { get; set; } = new();

/// <summary>
/// The bone name for these keyframes.
/// Each bone has a name so we can associate it with a runtime model.
/// </summary>
public string Name { get; set; } = string.Empty;
}
25 changes: 25 additions & 0 deletions TGC.MonoGame.TP/Animations/DataTypes/AnimationClip.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Collections.Generic;
using ThunderingTanks.Animation;

namespace ThunderingTanks.Animation.DataTypes;

/// <summary>
/// An animation clip is a set of keyframes with associated bones.
/// </summary>
public class AnimationClip
{
/// <summary>
/// The bones for this animation clip with their keyframes.
/// </summary>
public List<AnimationBone> Bones { get; set; } = new();

/// <summary>
/// Duration of the animation clip.
/// </summary>
public double Duration { get; set; }

/// <summary>
/// Name of the animation clip.
/// </summary>
public string Name { get; set; }
}
40 changes: 40 additions & 0 deletions TGC.MonoGame.TP/Animations/DataTypes/Keyframe.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Microsoft.Xna.Framework;
using ThunderingTanks.Animation;

namespace ThunderingTanks.Animation.DataTypes;

/// <summary>
/// An Keyframe is a rotation and Translation for a moment in time.
/// It would be easy to extend this to include scaling as well.
/// </summary>
public class Keyframe
{
/// <summary>
/// The rotation for the bone.
/// </summary>
public Quaternion Rotation { get; set; }

/// <summary>
/// The keyframe time.
/// </summary>
public double Time { get; set; }

/// <summary>
/// The Translation for the bone.
/// </summary>
public Vector3 Translation { get; set; }

public Matrix Transform
{
get => Matrix.CreateFromQuaternion(Rotation) * Matrix.CreateTranslation(Translation);
set
{
var transform = value;
transform.Right = Vector3.Normalize(transform.Right);
transform.Up = Vector3.Normalize(transform.Up);
transform.Backward = Vector3.Normalize(transform.Backward);
Rotation = Quaternion.CreateFromRotationMatrix(transform);
Translation = transform.Translation;
}
}
}
19 changes: 19 additions & 0 deletions TGC.MonoGame.TP/Animations/DataTypes/ModelExtra.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections.Generic;

namespace ThunderingTanks.Animation.DataTypes;

/// <summary>
/// Class that contains additional information attached to the model and shared with the runtime.
/// </summary>
public class ModelExtra
{
/// <summary>
/// Animation clips associated with this model.
/// </summary>
public List<AnimationClip> Clips { get; set; } = new();

/// <summary>
/// The bone indices for the skeleton associated with any skinned model.
/// </summary>
public List<int> Skeleton { get; set; } = new();
}
162 changes: 162 additions & 0 deletions TGC.MonoGame.TP/Animations/Models/AnimatedModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using ThunderingTanks.Animation.DataTypes;

namespace ThunderingTanks.Animation.Models;

/// <summary>
/// An enclosure for an XNA Model that we will use that includes support for Bones, animation, and some manipulations.
/// </summary>
public class AnimatedModel
{
/// <summary>
/// The Model asset name.
/// </summary>
private readonly string _assetName;

/// <summary>
/// The underlying Bones for the Model.
/// </summary>
private readonly List<Bone> _bones = new();

/// <summary>
/// The actual underlying XNA Model.
/// </summary>
private Model _model;

/// <summary>
/// Extra data associated with the XNA Model.
/// </summary>
private ModelExtra _modelExtra;

/// <summary>
/// An associated animation clip Player.
/// </summary>
private AnimationPlayer _player;

/// <summary>
/// The Model animation clips.
/// </summary>
public List<AnimationClip> Clips => _modelExtra.Clips;

/// <summary>
/// Creates the Model from an XNA Model.
/// </summary>
/// <param name="assetName">The name of the asset for this Model.</param>
public AnimatedModel(string assetName)
{
_assetName = assetName;
}

/// <summary>
/// Play an animation clip.
/// </summary>
/// <param name="clip">The clip to play.</param>
/// <returns>The Player that will play this clip.</returns>
public AnimationPlayer PlayClip(AnimationClip clip)
{
// Create a clip Player and assign it to this Model.
_player = new AnimationPlayer(clip, this);
return _player;
}

/// <summary>
/// Update animation for the Model.
/// </summary>
public void Update(GameTime gameTime)
{
_player.Update(gameTime);
}

/// <summary>
/// Draw the Model.
/// </summary>
/// <param name="world">A world matrix to place the Model.</param>
/// <param name="view">The view matrix, normally from the camera.</param>
/// <param name="projection">The projection matrix, normally from the application.</param>
public void Draw(Matrix world, Matrix view, Matrix projection)
{
// Compute all of the bone absolute transforms.
var boneTransforms = new Matrix[_bones.Count];

for (var i = 0; i < _bones.Count; i++)
{
var bone = _bones[i];
bone.ComputeAbsoluteTransform();

boneTransforms[i] = bone.AbsoluteTransform;
}

// Determine the skin transforms from the skeleton.
var skeleton = new Matrix[_modelExtra.Skeleton.Count];
for (var s = 0; s < _modelExtra.Skeleton.Count; s++)
{
var bone = _bones[_modelExtra.Skeleton[s]];
skeleton[s] = bone.SkinTransform * bone.AbsoluteTransform;
}

// Draw the Model.
foreach (var modelMesh in _model.Meshes)
{
foreach (var effect in modelMesh.Effects)
{
var skinnedEffect = effect as SkinnedEffect;
skinnedEffect.World = boneTransforms[modelMesh.ParentBone.Index] * world;
skinnedEffect.View = view;
skinnedEffect.Projection = projection;
skinnedEffect.EnableDefaultLighting();
skinnedEffect.PreferPerPixelLighting = true;
skinnedEffect.SetBoneTransforms(skeleton);
}

modelMesh.Draw();
}
}

/// <summary>
/// Load the Model asset from content.
/// </summary>
public void LoadContent(ContentManager content)
{
_model = content.Load<Model>(_assetName);
_modelExtra = _model.Tag as ModelExtra;

ObtainBones();
}

/// <summary>
/// Get the Bones from the Model and create a bone class object for each bone. We use our bone class to do the real
/// animated bone work.
/// </summary>
private void ObtainBones()
{
_bones.Clear();
foreach (var bone in _model.Bones)
{
// Create the bone object and add to the hierarchy.
var newBone = new Bone(bone.Name, bone.Transform, bone.Parent != null ? _bones[bone.Parent.Index] : null);

// Add to the Bones for this Model.
_bones.Add(newBone);
}
}

/// <summary>
/// Find a bone in this Model by name.
/// </summary>
public Bone FindBone(string name)
{
foreach (var bone in _bones)
{
if (bone.Name == name)
{
return bone;
}
}

return null;
}
}
Loading