示例#1
0
 public static int addModel(ContentManager content, CModel model)
 {
     modelsList.Add(model);
     renderer.Models.Add(model);
     model.LoadContent(content);
     return(modelsList.IndexOf(model));
 }
示例#2
0
        public CWater(ContentManager content, GraphicsDevice graphics, Vector3 position, Vector3 deepestPoint, Vector2 size, float alpha)
        {
            this.content  = content;
            this.graphics = graphics;

            this._waterPosition     = position;
            this._waterSize         = size;
            this._waterDeepestPoint = deepestPoint;

            waterMesh = new CModel(content.Load <Model>("3D/plane"), position, Vector3.Zero, new Vector3(size.X, 1, size.Y), graphics);

            waterEffect = content.Load <Effect>("Effects/WaterEffect");
            waterMesh.SetModelEffect(waterEffect, false);

            waterEffect.Parameters["viewportWidth"].SetValue(graphics.Viewport.Width);
            waterEffect.Parameters["viewportHeight"].SetValue(graphics.Viewport.Height);
            waterEffect.Parameters["WaterNormalMap"].SetValue(content.Load <Texture2D>("Textures/water_normal"));

            this.WaterAlpha = alpha;

            reflectionTarg = new RenderTarget2D(graphics, graphics.Viewport.Width, graphics.Viewport.Height, false, SurfaceFormat.Color, DepthFormat.Depth24);

            reflectionCamera = new CCamera(graphics, Vector3.Zero, Vector3.Zero, 0.1f, 10000.0f, true);

            pickWorld = Matrix.CreateTranslation(Vector3.Zero);

            GenerateBoundingBoxes();
        }
示例#3
0
        public CPickUp(GraphicsDevice graphics, Model model, Texture2D texture, Vector3 position, Vector3 rotation, Vector3 scale, string weaponName, int weaponBullets)
        {
            Dictionary <string, Texture2D> textureList = new Dictionary <string, Texture2D>();

            textureList.Add("ApplyAllMesh", texture);
            _Model = new CModel(model, position, rotation, scale, graphics, textureList, 0, 1, null);
            _Model.shouldNotUpdateTriangles = true;

            _weaponName    = weaponName;
            _weaponBullets = weaponBullets;
        }
示例#4
0
        public CSkybox(ContentManager Content, GraphicsDevice GraphicsDevice, TextureCube Texture)
        {
            model = new CModel(Content.Load <Model>("3D/Skysphere"), Vector3.Zero, Vector3.Zero, new Vector3(2000), GraphicsDevice);
            model.shouldNotUpdateTriangles = true;

            effect = Content.Load <Effect>("Effects/Skysphere");
            effect.Parameters["CubeMap"].SetValue(Texture);

            model.SetModelEffect(effect, false);

            this.graphics = GraphicsDevice;

            ColorIntensity = 1.0f;
        }
示例#5
0
        public static void UpdateGameLevel(ref Game.LevelInfo.LevelData lvl)
        {
            for (int i = 0; i < modelsList.Count; i++)
            {
                CModel mdl = modelsList[i];

                lvl.MapModels.Models[i].Position   = new Game.LevelInfo.Coordinates(mdl._modelPosition);
                lvl.MapModels.Models[i].Rotation   = new Game.LevelInfo.Coordinates(mdl._modelRotation);
                lvl.MapModels.Models[i].Scale      = new Game.LevelInfo.Coordinates(mdl._modelScale);
                lvl.MapModels.Models[i].Alpha      = mdl.Alpha;
                lvl.MapModels.Models[i].Explodable = mdl._Explodable;
            }
            while (lvl.MapModels.Models.Count != modelsList.Count)
            {
                lvl.MapModels.Models.RemoveAt(lvl.MapModels.Models.Count - 1);
            }
        }
示例#6
0
        public CProjectile(CModel Model, Vector3 Pos, Vector3 Rot, Vector3 Direction, float damage = 20, bool destroy = false)
        {
            this._model     = Model;
            this._pos       = Pos;
            this._rot       = Rot;
            this._direction = Direction;

            this._damage  = damage;
            this._destroy = destroy;

            _fallElapsedTime = 0f;

            _model._modelPosition    = _pos;
            _model._modelRotation    = _rot;
            _model._UseForwardVector = true;

            this._isCollisioned = false;
        }
示例#7
0
        public void SetDamageToModel(float damage)
        {
            if (_ModelLife > 0)
            {
                _ModelLife -= damage;
                if (_ModelLife <= 0)
                {
                    //_ModelLife = 25f;
                    Display3D.Particles.ParticlesManager.AddParticle("explosion", _modelPosition, 20);
                    //Game.CSoundManager.soundList["Explosion"]._sound.
                    Game.CSoundManager.soundList["Explosion"]._audioEmitter.Position = _modelPosition;
                    Game.CSoundManager.PlaySound("Explosion", 1);

                    // Check for nearby explodable models
                    CModel closestModel = null;
                    float  closestDist  = -1;
                    foreach (CModel mdl in Display3D.CModelManager.modelsList)
                    {
                        if (mdl != this && mdl._Explodable && mdl._ModelLife > 0)
                        {
                            float dist = Vector3.Distance(mdl._modelPosition, _modelPosition);
                            if (closestDist == -1 || closestDist > dist)
                            {
                                closestDist  = dist;
                                closestModel = mdl;
                            }
                        }
                    }
                    if (closestDist <= 5 && closestModel != null)
                    {
                        System.Timers.Timer timer = new System.Timers.Timer();
                        timer.Interval = 200;
                        timer.Elapsed += (s, e) => { closestModel.SetDamageToModel(150); ((System.Timers.Timer)s).Stop(); };
                        timer.Enabled  = true;
                        timer.Start();
                    }
                }
            }
        }
示例#8
0
        private float rotateIntensity = 50; // The more the value is, the more sensitive it is



        public CGizmos(ContentManager Content, GraphicsDevice GraphicsDevice, CCamera cam)
        {
            Dictionary <string, Texture2D> guizmoTexture = new Dictionary <string, Texture2D>();

            guizmoTexture.Add("R", Content.Load <Texture2D>("Textures/Guizmo"));
            posGizmo = new Display3D.CModel(Content.Load <Model>("Models/Guizmo"), Vector3.Zero, new Vector3(-MathHelper.PiOver2, MathHelper.PiOver2, 0), Vector3.One, GraphicsDevice, guizmoTexture, 0, 1);
            posGizmo.AddTrianglesToPhysics(cam, false);

            Dictionary <string, Texture2D> guizmoTexture2 = new Dictionary <string, Texture2D>();

            guizmoTexture2.Add("R", Content.Load <Texture2D>("Textures/RotationGuizmo"));
            rotGizmo = new Display3D.CModel(Content.Load <Model>("Models/RotationGuizmo"), Vector3.Zero, Vector3.Zero, Vector3.One, GraphicsDevice, guizmoTexture2, 0, 1);
            rotGizmo.AddTrianglesToPhysics(cam, false);

            Dictionary <string, Texture2D> guizmoTexture3 = new Dictionary <string, Texture2D>();

            guizmoTexture3.Add("R", Content.Load <Texture2D>("Textures/ScalingGuizmo"));
            scaleGizmo = new Display3D.CModel(Content.Load <Model>("Models/ScalingGuizmo"), Vector3.Zero, new Vector3(-MathHelper.PiOver2, MathHelper.PiOver2, 0), Vector3.One, GraphicsDevice, guizmoTexture3, 0, 1);
            scaleGizmo.AddTrianglesToPhysics(cam, false);

            GenerateBoundingBoxes();

            gizmoSize = new Vector3(0.12f);
        }