Exemplo n.º 1
0
        public XMaterial(ref XMain X, Texture2D Texture, bool EnableTextureMapping, Texture2D NormalMap, bool EnableNormalMapping, Vector4?DiffuseColor, bool AlphaBlendable, float Specularity)
        {
            if (Texture != null)
            {
                texture = Texture;
            }

            if (NormalMap != null)
            {
                normalmap = NormalMap;
            }

            if (DiffuseColor != null)
            {
                diffuse = DiffuseColor;
            }
            else
            {
                diffuse = new Vector4(1f, 1f, 1f, 1);
            }

            VertexWinding       = CullMode.CullCounterClockwiseFace;
            this.AlphaBlendable = AlphaBlendable;

            this.EnableTexureMapping = EnableTextureMapping;
            this.EnableNormalMapping = EnableNormalMapping;

            this.Specularity = Specularity;
        }
Exemplo n.º 2
0
        public XGamePad(ref XMain X, int GamepadNumber) : base(ref X)
        {
            DrawOrder          = 0;
            this.GamepadNumber = GamepadNumber;

            if (GamepadNumber == 1)
            {
                index = PlayerIndex.One;
            }
            else if (GamepadNumber == 2)
            {
                index = PlayerIndex.Two;
            }
            else if (GamepadNumber == 3)
            {
                index = PlayerIndex.Three;
            }
            else if (GamepadNumber == 4)
            {
                index = PlayerIndex.Four;
            }

            GetState();

            idleTime       = new XTimer(ref X);
            vibrationTimer = new XTimer(ref X);
        }
Exemplo n.º 3
0
        public XMaterial(ref XMain X, string Texture, bool EnableTextureMapping, string NormalMap, bool EnableNormalMapping, Vector4?DiffuseColor, bool AlphaBlendable, float Specularity)
        {
            if (!string.IsNullOrEmpty(Texture))
            {
                texture = X.Content.Load <Texture2D>(Texture);
            }

            if (!string.IsNullOrEmpty(NormalMap))
            {
                normalmap = X.Content.Load <Texture2D>(NormalMap);
            }

            if (DiffuseColor != null)
            {
                diffuse = DiffuseColor;
            }
            else
            {
                diffuse = new Vector4(1f, 1f, 1f, 1);
            }

            VertexWinding       = CullMode.CullCounterClockwiseFace;
            this.AlphaBlendable = AlphaBlendable;

            this.EnableTexureMapping = EnableTextureMapping;
            this.EnableNormalMapping = EnableNormalMapping;

            this.Specularity = Specularity;
        }
Exemplo n.º 4
0
 public XHingeJoint(ref XMain X, XActor actor1, XActor actor2, Vector3 HingeAxis, Vector3 Offset, float Width, float ForwardMax, float BackWardMax, float Sideways, float Damping)
     : base(ref X)
 {
     hinge = new HingeJoint();
     hinge.Initialise(actor1.PhysicsObject.PhysicsBody, actor2.PhysicsObject.PhysicsBody, HingeAxis, Offset, Width / 2, ForwardMax, BackWardMax, Sideways, Damping);
     hinge.EnableController();
     hinge.EnableHinge();
 }
Exemplo n.º 5
0
 public XTreeSystem(ref XMain X, string TreeMapFile, XHeightMap heightMap)
     : base(ref X)
 {
     treeMapFile    = TreeMapFile;
     this.heightMap = heightMap;
     treeMap        = new List <Vector3>();
     trees          = new List <XTree>();
 }
Exemplo n.º 6
0
 public XModel(ref XMain X, string Filename) : base(ref X)
 {
     this.X        = X;
     SASData       = new SASContainer(ref X);
     this.Filename = Filename;
     Giftextures   = new Dictionary <int, XGifTexture>();
     Count++;
     Number = Count;
 }
Exemplo n.º 7
0
 public XComponent(ref XMain X)
 {
     this.componentID = X.Tools.GeneratorNewID();
     this.X           = X;
     X.Components.Add(this);
     this.Name = this.ToString().Replace("XEngine.", "") + this.componentID.ToString();
     //sort X.Components list according to Draworder
     X.Components.Sort();
 }
Exemplo n.º 8
0
 public XTriggerVolume(ref XMain X, XPhysicsObject obj, bool Continuous, Vector3 translation, Quaternion rotation, Vector3 scale) : base(ref X)
 {
     this.obj         = obj;
     continuous       = Continuous;
     triggered        = false;
     this.translation = translation;
     this.rotation    = rotation;
     this.scale       = scale;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Constructs a new particle emitter object.
        /// </summary>
        public XParticleEmitter(ref XMain X, XParticleSystem particleSystem,
                                float particlesPerSecond, Vector3 initialPosition) : base(ref X)
        {
            this.particleSystem = particleSystem;

            timeBetweenParticles = 1.0f / particlesPerSecond;

            previousPosition = initialPosition;
        }
Exemplo n.º 10
0
 public XAnimatedActor(ref XMain X, XModel model, Vector3 Position,
                       Vector3 Velocity, float Mass) :
     base(ref X, model, Position, Velocity, Mass)
 {
     if (model != null)
     {
         model.Parent = this;
     }
 }
Exemplo n.º 11
0
 public XSkyBox(ref XMain X, string SkyCubeMap)
     : base(ref X)
 {
     DrawOrder = 19;
     Filenames = new List <string>();
     if (!string.IsNullOrEmpty(SkyCubeMap))
     {
         Filenames.Add(SkyCubeMap);
     }
 }
Exemplo n.º 12
0
 public XAnimatedActor(ref XMain X, XPhysicsObject Object, XModel model, Vector3 ModelScale,
                       Vector3 Velocity, float Mass)
     :
     base(ref X, Object, model, ModelScale, Velocity, Mass)
 {
     if (model != null)
     {
         model.Parent = this;
     }
 }
Exemplo n.º 13
0
        public XWater(ref XMain X, Vector2 pointOne, Vector2 size, float height) : base(ref X)
        {
            DrawOrder = 22;
            PointOne  = pointOne;
            PointTwo  = Vector2.Add(pointOne, size);
            this.Size = size;

            this.height = height;

            reflectionCamera = new XCamera(ref X, 1, 100);
        }
Exemplo n.º 14
0
        public XDynamicSky(ref XMain X, XEnvironmentParameters Parameters) : base(ref X)
        {
            if (Parameters != null)
            {
                this.Params = Parameters;
            }

            RealTime = false;
            Theta    = 4.0f;
            Phi      = 0.0f;
        }
Exemplo n.º 15
0
        public XWater(ref XMain X)
            : base(ref X)
        {
            DrawOrder = 22;
            height    = 4;
            Size      = new Vector2(128 * 2, 128 * 2);
            PointOne  = new Vector2(-128, -128);
            PointTwo  = Vector2.Add(PointOne, Size);

            reflectionCamera = new XCamera(ref X, 1, 100);
        }
Exemplo n.º 16
0
        public XWaterFast(ref XMain X, string EnvironmentMap)
            : base(ref X)
        {
            myWidth  = 256;
            myHeight = 256;

            myPosition = new Vector3(0, 0, 0);
            myScale    = new Vector3(10, 1, 10); //Vector3.One;
            myRotation = new Quaternion(0, 0, 0, 1);

            EnvAsset = EnvironmentMap;
        }
Exemplo n.º 17
0
        public Matrix GenerateProjection(ref XMain X, float FoV, float AspectRatio, ProjectionTypes type, float nearplane, float farplane)
        {
            if (type == ProjectionTypes.Perspective)
            {
                return(Matrix.CreatePerspectiveFieldOfView(FoV, AspectRatio, nearplane, farplane));
            }
            else if (type == ProjectionTypes.Orthographic)
            {
                return(Matrix.CreateOrthographic(100, 100, nearplane, farplane));
            }

            return(Matrix.Identity);
        }
Exemplo n.º 18
0
        public XCamera(ref XMain X, float nearplane, float farplane)
            : base(ref X)
        {
            ProjectionType = ProjectionTypes.Perspective;
            RenderType     = RenderTypes.Normal;
            NearPlane      = nearplane;
            FarPlane       = farplane;
            FOV            = MathHelper.PiOver4;
            GenerateProjection(ref X, this.FOV, this.ProjectionType, NearPlane, FarPlane);

            Base      = this;
            DrawOrder = 50000;
        }
Exemplo n.º 19
0
        public XHeightMap(ref XMain X, string HeightMap, XEnvironmentParameters Params, string RTexture, string GTexture, string BTexture, string TextureMap) : base(ref X)
        {
            if (Params != null)
            {
                this.Params = Params;
            }

            HeightMapFile  = HeightMap;
            TextureMapFile = TextureMap;
            RTextureFile   = RTexture;
            GTextureFile   = GTexture;
            BTextureFile   = BTexture;
            DrawOrder      = 21;
        }
Exemplo n.º 20
0
        public XRenderer(XMain X) : base(ref X)
        {
            DebugNoDraw = new List <XComponent>();
            DebugNoDraw.Add(X.Debug);
            DebugNoDraw.Add(X.DebugDrawer);
            DebugNoDraw.Add(X.Console);
            DebugNoDraw.Add(X.FrameRate);
            //The menumanager is also added to this list elsewhere in the code, no access from here

            //Add particle systems to the DebugNoDrawTypes list
            DebugNoDrawTypes = new List <Type>();
            DebugNoDrawTypes.Add(typeof(XParticleSystem));
            DebugNoDrawTypes.Add(typeof(XDynamicSky));
        }
Exemplo n.º 21
0
        public XTreeModel(ref XMain X, string XMLProfileFile, string BarkTextureFile, string LeafTextureFile) : base(ref X)
        {
            //generate some random values as default for a new TreeModel
            Random rand = new Random();

            Seed           = rand.Next();
            RadialSegments = rand.Next(8, 12);
            AddLeaves      = true;
            CuttoffLevel   = rand.Next(0, 2);

            this.Profile     = XMLProfileFile;
            this.LeafTexture = LeafTextureFile;
            this.BarkTexture = BarkTextureFile;
        }
Exemplo n.º 22
0
 public XTree(ref XMain X, XTreeModel model, Vector3 translation, Vector3 ModelScale)
     : base(ref X, new BoxObject(new Vector3(ModelScale.X, 10, ModelScale.Z), Matrix.Identity, translation), null, ModelScale, Vector3.Zero, 10000)
 {
     this.tree         = model;
     this.Immovable    = true;
     this.renderLeaves = true;
     // Enable/disable leaf sorting
     if (tree != null)
     {
         if (tree.Leaves != null)
         {
             tree.Leaves.SortingEnabled = false;
         }
     }
 }
Exemplo n.º 23
0
        /// <summary>
        /// Creates a new instance of QuaternionCamera with a position at the origin
        /// using a perspective projection with the specified projection parameters
        /// </summary>
        /// <param name="position">The position of the camera's eye point</param>
        /// <param name="orientation">The orientation of the camera</param>
        /// <param name="fov">The camera's perspective projection field of view</param>
        /// <param name="aspect">The camera's perspective projection aspect ratio</param>
        /// <param name="near">The near frustum plane distance of the camera's projection</param>
        /// <param name="far">The far frustum plane distance of the camera's projection</param>
        public XQuaternionCamera(ref XMain X, Vector3 position, Quaternion orientation, float fov,
                                 float aspect, float near, float far) : base(ref X, near, far)
        {
            Position           = position;
            mOrientation       = orientation;
            View               = Matrix.Identity;
            mInverseViewMatrix = Matrix.Identity;
            Projection         = Matrix.Identity;

            FOV         = fov;
            AspectRatio = aspect;
            NearPlane   = near;
            FarPlane    = far;

            mBuildView       = true;
            mBuildProjection = true;
        }
Exemplo n.º 24
0
        public XActor(ref XMain X, XPhysicsObject Object, XModel model, Vector3 ModelScale, Vector3 Velocity, float Mass)
            : base(ref X)
        {
            DrawOrder = 100;

            if (model != null)
            {
                this.model       = model;
                model.Parent     = this;
                this.modelNumber = model.Number;
            }
            this.PhysicsObject = Object;
            this.PhysicsObject.SetMass(Mass);
            this.PhysicsObject.scale = ModelScale;
            this.PhysicsObject.PhysicsBody.Velocity = Velocity;
            this.PhysicsObject.PhysicsBody.SetDeactivationTime(0.1f);
            this.PhysicsObject.PhysicsBody.SetActivityThreshold(5f, 5f);
        }
Exemplo n.º 25
0
        public XProp(ref XMain X, XModel model, Vector3 position, Vector3 modeloffset, Matrix orient, Vector3 scale)
            : base(ref X)
        {
            DrawOrder = 100;

            if (model != null)
            {
                this.model   = model;
                model.Parent = this;
                modelNumber  = model.Number;
                //if its not loaded try and load!
                //if (!model.loaded) model.Load(X.Content);
            }
            this.position    = position;
            this.modeloffset = modeloffset;
            this.orientation = orient;
            this.scale       = scale;
        }
Exemplo n.º 26
0
        /// <summary>
        /// Constructs a new projectile.
        /// </summary>
        public XProjectile(ref XMain X, XParticleSystem explosionParticles,
                           XParticleSystem explosionSmokeParticles,
                           XParticleSystem projectileTrailParticles) : base(ref X)
        {
            this.explosionParticles      = explosionParticles;
            this.explosionSmokeParticles = explosionSmokeParticles;

            // Start at the origin, firing in a random (but roughly upward) direction.
            position = Vector3.Zero;

            velocity.X = (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange;
            velocity.Y = (float)(random.NextDouble() + 0.5) * verticalVelocityRange;
            velocity.Z = (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange;

            // Use the particle emitter helper to output our trail particles.
            trailEmitter = new XParticleEmitter(ref X, projectileTrailParticles,
                                                trailParticlesPerSecond, position);
        }
Exemplo n.º 27
0
        public XMouse(ref XMain X) : base(ref X)
        {
            DrawOrder      = 0;
            Delta          = Vector2.Zero;
            ScrollPosition = 0;
            ScrollDelta    = 0;

            if (Reset)
            {
                Mouse.SetPosition(X.GraphicsDevice.Viewport.Width / 2, X.GraphicsDevice.Viewport.Height / 2);
            }

            CurrentState = Mouse.GetState();
            LastState    = CurrentState;

            InitialPosition = new Vector2(CurrentState.X, CurrentState.Y);
            CurrentPosition = InitialPosition;

            idleTime = new XTimer(ref X);
        }
Exemplo n.º 28
0
        public static HeightMapInfo GenerateFromHeightmap(ref XMain X, Texture2D Heighmap, float TerrainScale)
        {
            int Width  = Heighmap.Width;
            int Height = Heighmap.Height;

            float[,] heights = new float[Width, Height];
            Color[] colors = new Color[Width * Height];

            Heighmap.GetData(colors);

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    heights[x, y] = colors[x + y * Width].R * 0.5f;//*.16f;
                }
            }

            return(new HeightMapInfo(heights, TerrainScale));
        }
Exemplo n.º 29
0
        public XEnvironmentParameters(XMain X) : base(ref X)
        {
            LightDirection            = new Vector4(100.0f, -100.0f, 100.0f, 1.0f);
            LightColor                = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            LightColorAmbient         = new Vector4(0.1f, 0.1f, 0.1f, 1.0f);
            FogColor                  = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            FogDensity                = .0045f;
            SunLightness              = 0.2f;
            SunRadiusAttenuation      = 256.0f;
            LargeSunLightness         = 0.2f;
            LargeSunRadiusAttenuation = 1.0f;
            DayToSunsetSharpness      = 1.15f;
            HazeTopAltitude           = 100.0f;

            SunsetFile = @"Content\XEngine\Textures\SkySunset";
            DayFile    = @"Content\XEngine\Textures\SkyDay";
            NightFile  = @"Content\XEngine\Textures\SkyNight";

            count++;
            number  = count;
            Shadows = true;
        }
Exemplo n.º 30
0
        public XActor(ref XMain X, XModel model, Vector3 Position, Vector3 Velocity, float Mass)
            : base(ref X)
        {
            DrawOrder  = 100;
            this.Scale = Vector3.One;

            if (model != null)
            {
                this.model       = model;
                model.Parent     = this;
                this.modelNumber = model.Number;
                if (model.Model != null)
                {
                    RebuildCollisionSkin();
                    this.PhysicsObject.SetMass(Mass);
                    this.PhysicsObject.PhysicsBody.Velocity = Velocity;
                }
            }
            this.Translation = Position;
            this.Velocity    = Velocity;
            this.Mass        = Mass;
        }