Exemple #1
0
        /// <summary>
        /// Initialize the class
        /// </summary>
        /// <param name="device">GraphicsDevice class</param>
        /// <param name="cameraPos">Default position of the camera</param>
        /// <param name="target">Default target of the camera</param>
        /// <param name="nearClip">Closest elements to be rendered</param>
        /// <param name="farClip">Farthest elements to be rentered</param>
        /// <param name="camVelocity">Camera movement speed</param>
        /// <param name="isCamFrozen">Camera Frozen or not</param>
        /// <param name="freeCam">Is the camera free of physics or not</param>
        /// /// <param name="camVelocity">Give an map (heightmap) instance</param>
        public CCamera(GraphicsDevice device, Vector3 cameraPos, Vector3 target, float nearClip, float farClip, bool isCamFrozen, bool freeCam = false, CTerrain map = null, bool[] componentUsages = null)
        {
            this._graphics = device;
            _Viewport      = device.Viewport;
            _aspectRatio   = _graphics.Viewport.AspectRatio; // 16::9 - 4::3 etc

            this._nearClip = nearClip;
            this._farClip  = farClip;

            this._cameraPos    = cameraPos;
            this._cameraTarget = target;

            this._pitch = 0f;
            this._yaw   = 0f;
            this._roll  = 0f;

            this._elapsedStepTime         = 0;
            this._isPitchShiftedStepSound = false;

            this.isCamFrozen = isCamFrozen;
            this.isFreeCam   = freeCam;

            //this._physicsMap = new Game.CPhysics2(9.81f / 500, _map, _playerHeight);
            this._physicsMap = new Game.CPhysics();

            if (map != null)
            {
                _physicsMap.LoadContent(_playerHeight, componentUsages);
                _physicsMap._terrain = map;
            }

            this._up          = Vector3.Up;
            this._right       = Vector3.Cross(Vector3.Forward, _up);
            this._translation = Vector3.Zero;

            this._middleScreen = new Point(_graphics.Viewport.Width / 2, _graphics.Viewport.Height / 2);

            _isMoving = false;

            _view = Matrix.CreateLookAt(cameraPos, target, Vector3.Up);

            fieldOfView     = MathHelper.ToRadians(40);
            _projection     = Matrix.CreatePerspectiveFieldOfView(fieldOfView, _aspectRatio, _nearClip, _farClip);
            _nearProjection = Matrix.CreatePerspectiveFieldOfView(fieldOfView, _aspectRatio, 0.02f, 1f);

            generateFrustum();
        }
Exemple #2
0
        public void LoadContent(ContentManager content, Display3D.CCamera cam)
        {
            // We load the ennemy content
            _model.LoadContent(content);

            // We Create the forces application on the Ennemy
            _physicEngine = new CPhysics();
            _physicEngine.LoadContent(0.2f, new bool[] { true, true });
            _physicEngine._triangleList        = cam._physicsMap._triangleList;
            _physicEngine._triangleNormalsList = cam._physicsMap._triangleNormalsList;
            _physicEngine._terrain             = cam._physicsMap._terrain;
            _physicEngine._waterHeight         = cam._physicsMap._waterHeight;
            _physicEngine.heightCorrection     = 0.85f;

            GenerateHitBoxesTriangles();

            if (!_isMultiPlayer)
            {
                _loaded = true;
            }
        }