Code: Select all
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
using SynapseGaming.LightingSystem.Core;
using SynapseGaming.LightingSystem.Rendering;
using SgMotion;
using SgMotion.Controllers;
using SgMotion.Effects;
namespace Aggro.Clutter
{
public class Weapon
{
public Model model;
public SceneObject weaponObject;
public SceneObject dropObject;
public bool held = true;
private Matrix lastBonePos = Matrix.Identity;
public Vector3 Position
{
get { return weaponObject.World.Translation; }
set { weaponObject.World = Matrix.CreateTranslation(value); }
}
public Weapon(ContentManager gameContent, string modelFile, Matrix bonePos)
{
LoadContent(gameContent, modelFile);
}
public void LoadContent(ContentManager gameContent, string modelFile)
{
model = gameContent.Load<Model>(modelFile);
weaponObject = new SceneObject(model);
weaponObject.UpdateType = UpdateType.Automatic;
weaponObject.Visibility = ObjectVisibility.RenderedAndCastShadows;
weaponObject.StaticLightingType = StaticLightingType.Composite;
weaponObject.CollisionType = SynapseGaming.LightingSystem.Collision.CollisionType.Collide;
weaponObject.HullType = HullType.Mesh;
weaponObject.Mass = 10;
weaponObject.AffectedByGravity = true;
SceneInterface.ActiveSceneInterface.ObjectManager.Submit(weaponObject);
weaponObject.CalculateBounds();
}
public void Update(GameTime gametime, Matrix bonePos, Matrix offset)
{
weaponObject.World = bonePos;
}
}
}
I use a bepu character controller, but it's a bit too complicated for a physics noob like me to convert for this purpose.