Пример #1
0
        /// <summary>
        /// Creates a New InstanceSet in the Instances Collection using the speciefied model. The Instance Set can be
        /// retrieved by the Specified key.
        /// </summary>
        /// <param name="Key">Unique Key to use for this InstanceSet.</param>
        /// <param name="model">The Model to be used in the InstanceSet.</param>
        public virtual void CreateNewInstanceCollection(object Key, vxModel model)
        {
            InstanceSet instanceSet = new InstanceSet(vxEngine);

            instanceSet.InstancedModel = model;
            Instances.Add(Key, instanceSet);
        }
Пример #2
0
        public vxModel LoadBasicEffectModel(string PathToModel, ContentManager Content, Effect ShadowEffect, Effect UtilityEffect)
        {
            vxConsole.WriteVerboseLine("        Importing Basic Effect Model: " + PathToModel);

            // Create the Model Object to return
            vxModel newModel = new vxModel(Engine);

            // Next Load in the Main Model.
            newModel.ModelMain = Content.Load <Model>(PathToModel);

            DoModelFileCheck(PathToModel, Content);

            // Now load in the textures
            newModel.LoadTextures(Content, PathToModel);

            // Now load the shadow model.
            newModel.ModelShadow = LoadShadowModel(PathToModel, Content, ShadowEffect);


            // Now load the utility model.
            newModel.ModelUtility = LoadUtilityModel(PathToModel, Content, UtilityEffect);

            // Add a tag of the Path to the model for debuging
            newModel.ModelMain.Tag = PathToModel;

            return(newModel);
        }
Пример #3
0
        /// <summary>
        /// SnapBox for allowing tracks to snap together
        /// </summary>
        /// <param name="vxEngine"></param>
        public vxSnapBox(vxEngine vxEngine, vxModel SnapBoxModel, int Width, int Height, int Length)
            : base(vxEngine, SnapBoxModel, Vector3.Zero)
        {
            EndLocalRotation = new Vector3(MathHelper.PiOver2, -MathHelper.PiOver4, MathHelper.PiOver4);
            DoShadowMap      = false;
            HitBox           = new Box(Vector3.Zero, Width, Height, Length);

            Current3DScene.BEPUPhyicsSpace.Add(HitBox);
            //PhysicsSkin_Main.CollisionRules.Personal = Physics.CollisionRuleManagement.CollisionRule.NoSolver;
            HitBox.CollisionInformation.CollisionRules.Personal = Virtex.Lib.Vrtc.Physics.BEPU.CollisionRuleManagement.CollisionRule.NoSolver;
            ((vxSandboxGamePlay)Current3DScene).Items.Add(this);
        }
Пример #4
0
        /// <summary>
        /// Base Entity Object for the vxEngine.
        /// </summary>
        /// <param name="vxEngine">The current instance of the vxEngine.</param>
        /// <param name="EntityModel">The Entities Model to be used.</param>
        /// <param name="StartPosition">The Start Position of the Entity.</param>
        public vxEntity3D(vxEngine vxEngine, vxModel EntityModel, Vector3 StartPosition) : base(vxEngine)
        {
            World = Matrix.CreateRotationX(-MathHelper.PiOver2)
                    * Matrix.CreateTranslation(StartPosition);

            //Set Model Data
            this.vxModel = EntityModel;

            //Set Position Data
            this.Position = StartPosition;

            InitShaders();
        }
Пример #5
0
        /// <summary>
        /// Load Global Content
        /// </summary>
        /// <param name="content"></param>
        public override void LoadGlobalContent(ContentManager content)
        {
            HasContentBeenLoaded = true;

            GameVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            vxConsole.WriteLine("Loading Global Content...");

            ////////////////////////////////////////////////////////////////////////////////////////////
            //Fonts
            ////////////////////////////////////////////////////////////////////////////////////////////


            ////////////////////////////////////////////////////////////////////////////////////////////
            //Images
            ////////////////////////////////////////////////////////////////////////////////////////////



            ////////////////////////////////////////////////////////////////////////////////////////////
            //Shaders
            ////////////////////////////////////////////////////////////////////////////////////////////



            ////////////////////////////////////////////////////////////////////////////////////////////
            //MODELS
            ////////////////////////////////////////////////////////////////////////////////////////////


            Model_Items_ModelObjs = vxContentManager.LoadModel("Models/modelobjs/modelobjs");

            Model_Items_WoodenCrate = vxContentManager.LoadModel("Models/items/wooden crate/wooden crate");

            Model_Items_Concrete = vxContentManager.LoadModel("Models/concrete_cube/concrete_cube");

            Model_Items_Teapot = vxContentManager.LoadModel("Models/teapot/teapot");



            ////////////////////////////////////////////////////////////////////////////////////////////
            //Sounde Effects
            ////////////////////////////////////////////////////////////////////////////////////////////


            ////////////////////////////////////////////////////////////////////////////////////////////
            // Music
            ////////////////////////////////////////////////////////////////////////////////////////////
        }
Пример #6
0
        /// <summary>
        /// Creates a New Instance of the Working Plane Class
        /// </summary>
        /// <param name="AssetPath"></param>
        public vxWorkingPlane(vxEngine vxEngine, vxModel entityModel, Vector3 StartPosition)
            : base(vxEngine, entityModel, StartPosition)
        {
            //Render even in debug mode
            RenderEvenInDebug = true;

            WrknPlane = new Plane(Vector3.Up, -Position.Y);

            AlphaValue = 0.05f;

            basicEffect = new BasicEffect(this.vxEngine.GraphicsDevice);

            int size = 10000;

            vertices = new List <VertexPositionColor>();
            for (int i = -size; i < size + 1; i += 10)
            {
                Color color = i % 100 == 0 ? Color.White : Color.Gray * 1.5f;

                vertices.Add(new VertexPositionColor(
                                 new Vector3(i, 0, -size),
                                 color
                                 ));

                vertices.Add(new VertexPositionColor(
                                 new Vector3(i, 0, size),
                                 color
                                 ));


                vertices.Add(new VertexPositionColor(
                                 new Vector3(-size, 0, i),
                                 color
                                 ));

                vertices.Add(new VertexPositionColor(
                                 new Vector3(size, 0, i),
                                 color
                                 ));
            }
        }
Пример #7
0
 public vxAlphaEntity3D(vxEngine Engine, vxModel model, Vector3 Pos) :
     base(Engine, model, Pos)
 {
     Texture = Engine.Assets.Textures.Blank;
 }
Пример #8
0
 /// <summary>
 /// Creates a New Instance of the Base Ship Class
 /// </summary>
 /// <param name="AssetPath"></param>
 public Envrio(vxEngine vxEngine, vxModel entityModel, Vector3 StartPosition)
     : base(vxEngine, entityModel, StartPosition)
 {
     //World = Matrix.CreateRotationX(-MathHelper.PiOver2);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Virtex.Lib.Vrtc.Core.Particles.vxParticle3D"/> class.
 /// </summary>
 /// <param name="vxEngine">Vx engine.</param>
 /// <param name="model">Model.</param>
 /// <param name="StartPosition">Start position.</param>
 public vxParticle3D(vxEngine vxEngine, vxModel model, Vector3 StartPosition)
     : base(vxEngine, model, StartPosition)
 {
 }
Пример #10
0
 public vxAlphaEntity3D(vxEngine vxEngine, vxModel EntityModel, Vector3 StartPosition) :
     base(vxEngine, EntityModel, StartPosition)
 {
 }
Пример #11
0
 public vxSandboxEntity(vxEngine vxEngine, vxModel EntityModel, Vector3 StartPosition)
     : base(vxEngine, EntityModel, StartPosition)
 {
     Properties = new List <vxSandboxEntityProperty>();
 }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        public override void LoadContent()
        {
            //Load Global Content First
            if (vxEngine.HasContentBeenLoaded == false)
            {
                vxEngine.LoadGlobalContent(vxEngine.Game.Content);
            }

            InitialiseLevel();
            d = new Envrio(vxEngine, vxEngine.vxContentManager.LoadModel("Models/courtyard/td_courtyard"), new Vector3(20, 0, 0));
            //d = new Envrio(vxEngine, vxEngine.vxContentManager.LoadModel("Models/castle/mdl_castle"), new Vector3(20, 0, 0));
            //d.NormalMap = vxEngine.Game.Content.Load<Texture2D>("Models/courtyard/crtyrd_bricks_nm");
            //d.SpecularMap = vxEngine.Game.Content.Load<Texture2D>("Models/courtyard/crtyrd_bricks_sm");
            d.SpecularIntensity = 1;

            waterItems.Add(new vxWaterEntity(vxEngine, Vector3.Up, new Vector3(500, 1, 500)));

            vxModel mod = vxEngine.vxContentManager.LoadModel("Models/cbe/cbe");

            new Envrio(vxEngine, mod, new Vector3(-5, 5, 0));
            //mod.SetTexturePackLevel(vxEnumQuality.Low);
            //mod.SetTexturePackLevel(vxEnumQuality.High);
            //mod.SetTexturePackLevel(vxEnumQuality.Ultra);
            //mod.SetTexturePackLevel(vxEnumQuality.Medium);

            //vxTexture2D newtexture = new vxTexture2D(vxEngine, "Models/cbe/Cube_dds");

            int size    = 100;
            Box baseBox = new Box(new Vector3(0, -5, 0), size, 10, size);

            BEPUPhyicsSpace.Add(baseBox);

            ///////////////////////////////////////////////////////////////////////
            //Initialise Camera Code
            ///////////////////////////////////////////////////////////////////////
            #region Set Up Camera

            base.LoadContent();


            Camera.CameraType  = CameraType.Orbit;
            Camera.OrbitTarget = new Vector3(0, 1.5f, 0);
            //Camera.OrbitZoom = -375;

            //
            //Grabbers
            //
            grabber = new MotorizedGrabSpring();
            BEPUPhyicsSpace.Add(grabber);
            rayCastFilter = RayCastFilter;

            IsPausable = false;

            #endregion

            int          height = 3;
            ConcreteCube cc     = new ConcreteCube((GameEngine)vxEngine, new Vector3(0, 5, 0));
            cc.SetMesh(Matrix.CreateTranslation(new Vector3(0, height, 0)), true, true);

            cc = new ConcreteCube((GameEngine)vxEngine, new Vector3(0, 5, 4f));
            cc.SetMesh(Matrix.CreateTranslation(new Vector3(0, height, 5f)), true, true);

            cc = new ConcreteCube((GameEngine)vxEngine, new Vector3(0, 5, 4f));
            cc.SetMesh(Matrix.CreateTranslation(new Vector3(0, height, -5f)), true, true);
        }
Пример #13
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
#if !DEBUG
            try {
#endif

#if DEBUG
            BuildConfigType = vxBuildConfigType.Debug;
#else
            BuildConfigType = vxBuildConfigType.Release;
#endif


            vxConsole.WriteLine("");
            vxConsole.WriteLine("");
            vxConsole.WriteLine("");
            vxConsole.WriteLine("Starting Vertices Engine");
            vxEnviroment.Initialize(this);


            vxConsole.WriteLine("Checking Directories");

            //The Android System uses the Isolated Storage for it's GameSaves
#if VRTC_PLTFRM_DROID
            IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
                                                                        IsolatedStorageScope.Assembly, null, null);

            string settings = vxEnviroment.GetVar(vxEnumEnvVarType.PATH_SETTINGS).Value.ToString();
            string sandbox  = vxEnviroment.GetVar(vxEnumEnvVarType.PATH_SANDBOX).Value.ToString();

            //First Check, if the Profiles Directory Doesn't Exist, Create It
            if (isoStore.DirectoryExists(settings) == false)
            {
                isoStore.CreateDirectory(settings);
            }

            //First Check, if the Sandbox Directory Doesn't Exist, Create It
            if (isoStore.DirectoryExists(sandbox) == false)
            {
                isoStore.CreateDirectory(sandbox);
            }

            //First Check, if the Temp Directory Doesn't Exist, Create It
            if (isoStore.DirectoryExists("Temp/Settings") == false)
            {
                isoStore.CreateDirectory("Temp/Settings");
            }
#else
            string settings = vxEnviroment.GetVar(vxEnumEnvVarType.PATH_SETTINGS).Value.ToString();
            string sandbox  = vxEnviroment.GetVar(vxEnumEnvVarType.PATH_SANDBOX).Value.ToString();

            //First Check, if the Profiles Directory Doesn't Exist, Create It
            if (Directory.Exists(settings) == false)
            {
                Directory.CreateDirectory(settings);
            }

            //First Check, if the Sandbox Directory Doesn't Exist, Create It
            if (Directory.Exists(sandbox) == false)
            {
                Directory.CreateDirectory(sandbox);
            }

            //First Check, if the Temp Directory Doesn't Exist, Create It
            if (Directory.Exists("Temp/Settings") == false)
            {
                Directory.CreateDirectory("Temp/Settings");
            }
#endif



            vxConsole.WriteLine("Starting Content Manager");
            // Load content belonging to the screen manager.
            ContentManager content = Game.Content;
            EngineContentManager = new ContentManager(Game.Services);

            // Initialise the Engine Speciality Content Manager.
            vxContentManager = new vxContentManager(this);

            //Set Location of Content Specific too Platform
            EngineContentManager.RootDirectory = vxEnviroment.GetVar(vxEnumEnvVarType.PATH_ENGINE_CONTENT).Value.ToString();

#if VRTC_PLTFRM_DROID
            Game.Activity.Window.AddFlags(WindowManagerFlags.Fullscreen);
            Game.Activity.Window.ClearFlags(WindowManagerFlags.ForceNotFullscreen);
#endif


#if VIRTICES_2D
            LineBatch = new vxLineBatch(GraphicsDevice);

            AssetCreator = new vxAssetCreator2D(GraphicsDevice);
            AssetCreator.LoadContent(_engineContentManager);
#endif
            InputManager = new vxInputManager(this);
            InputManager.LoadContent();
            InputManager.ShowCursor = true;

            SpriteBatch = new SpriteBatch(GraphicsDevice);

            //Initialise vxEngine Assets
            Assets = new vxInternalAssetManager(this);

            vxGUITheme      = new vxGUITheme(this);
            vxGUITheme.Font = this.Assets.Fonts.MenuFont;


            #region Initialise Debug Console

            //Get the vxEngine Version through Reflection
            EngineVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();


            // initialize the debug system with the game and the name of the font
            // we want to use for the debugging
            DebugSystem = vxDebugSystem.Initialize(this, "Fonts/font_debug");
            DebugSystem.TimeRuler.ShowLog = true;

            //Initialise the Debug Renderer
            vxDebugShapeRenderer.Initialize(GraphicsDevice);
            vxConsole.Initialize(this);


            //Now Setup Settings Managers
            GraphicsSettingsManager = new vxGraphicsSettingsManager(this);

            #endregion


#if !VRTC_PLTFRM_DROID
            Model_Sandbox_WorkingPlane = this.Assets.Models.UnitPlane;
#endif


#if VRTC_INCLDLIB_NET
            InitialiseMasterServerConnection();

            ServerManager = new vxNetworkServerManager(this, 14242);
            ClientManager = new vxNetworkClientManager(this);
#endif

            #region Load Base Language

            Languages = new List <vxLanguagePackBase> ();
            LoadLanguagePacks();

            //Default is English
            this.Language = Languages [0];

            #endregion

#if VIRTICES_3D
            //Initialise Renderer
            Renderer = new vxRenderer(this);
            Renderer.LoadContent();
#endif

            //Load in Profile Data
            Profile.LoadSettings(this);

            //Once all items are Managers and Engine classes are intitalised, then apply any and all passed cmd line arguments
            vxEnviroment.ApplyCommandLineArgs();

            //Set Initial Graphics Settings
            GraphicsSettingsManager.Apply();


            // Tell each of the screens to load their content.
            foreach (vxGameBaseScreen screen in screens)
            {
                screen.LoadContent();
            }
#if !DEBUG
        }

        catch (Exception ex) {
            vxCrashHandler.Init(this, ex);
        }
#endif
        }
Пример #14
0
        /// <summary>
        /// This Loads Models at Run time performing a number of functions. See remarks for full details.
        /// </summary>
        /// <remarks>
        /// Model Loading
        /// =============================
        /// This loads a vxModel with a Specified Effect as well as applies the CascadeShadowEffect to
        /// the vxModel's internal Shadow Model as well. XNA and potentially other back ends do not allow
        /// multiple loading of the same asset, therefore if a Shadow Model.xnb is not found, then it is created
        /// from a copy of the main model as 'mainmodelname_shdw.xnb'.
        ///
        ///
        /// Texture Loading
        /// =============================
        /// Furthermore, Textures are loaded based off of the name of the model mesh name.
        ///
        /// For Example
        /// -------------
        /// ModelMesh Name = "ship"
        ///
        /// Then the content importer will look for textures under the following names:
        ///
        /// Diffuse Texture:    ship_dds
        /// Normal Map:         ship_nm
        /// Specular Map:       ship_sm
        ///
        /// The path to each of these is saved in the vxModel as well too allow for reloading of
        /// other resolution packs later on.
        /// </remarks>
        /// <returns>The model.</returns>
        /// <param name="PathToModel">Path to model.</param>
        /// <param name="Content">Content.</param>
        /// <param name="EffectToSet">Effect to set.</param>
        /// <param name="ShadowEffect">Shadow effect.</param>
        /// <param name="UtilityEffect">Utility effect.</param>
        public vxModel LoadModel(string PathToModel, ContentManager Content, Effect EffectToSet, Effect ShadowEffect, Effect UtilityEffect)
        {
            vxConsole.WriteVerboseLine("     Importing Model: " + PathToModel);

            // Create the Model Object to return
            vxModel newModel = new vxModel(Engine);


            // Next Load in the Main Model.
            newModel.ModelMain = Content.Load <Model>(PathToModel);

            DoModelFileCheck(PathToModel, Content);

            #region Main Model Loading
            /*********************************************************************************/
            //                              MAIN MODEL
            /*********************************************************************************/

            //
            // Now Apply and Initialise the New Effect on the MainModel Object using the speceified Effect.
            //


            // Table mapping the original effects to our replacement versions.
            Dictionary <Effect, Effect> effectMapping = new Dictionary <Effect, Effect>();

            foreach (ModelMesh mesh in newModel.ModelMain.Meshes)
            {
                vxConsole.WriteVerboseLine("          Mesh Name: " + mesh.Name);
                mesh.Tag = PathToModel;
                // Scan over all the effects currently on the mesh.
                foreach (Effect oldEffect in mesh.Effects)
                {
                    // If we haven't already seen this effect...
                    if (!effectMapping.ContainsKey(oldEffect))
                    {
                        // Make a clone of our replacement effect. We can't just use
                        // it directly, because the same effect might need to be
                        // applied several times to different parts of the model using
                        // a different texture each time, so we need a fresh copy each
                        // time we want to set a different texture into it.
                        Effect newEffect = EffectToSet.Clone();

                        //First Load in the Texture packs based off of the mesh name
                        newModel.LoadTextures(Content, PathToModel);

                        if (newEffect.Parameters["TextureEnabled"] != null)
                        {
                            newEffect.Parameters["TextureEnabled"].SetValue(true);
                        }

                        if (newEffect.Parameters["IsSun"] != null)
                        {
                            newEffect.Parameters["IsSun"].SetValue(false);
                        }

                        Vector4[] ShadowSplitColors = new[] {
                            new Vector4(255, 0, 0, 255),
                            new Vector4(0, 255, 0, 255),
                            new Vector4(0, 0, 255, 255),
                            new Vector4(160, 32, 240, 255)
                        };

                        if (newEffect.Parameters["SplitColors"] != null)
                        {
                            newEffect.Parameters["SplitColors"].SetValue(ShadowSplitColors);
                        }


                        if (newEffect.Parameters["AlphaValue"] != null)
                        {
                            newEffect.Parameters["AlphaValue"].SetValue(1);
                        }

                        if (newEffect.Parameters["ShadowBrightness"] != null)
                        {
                            newEffect.Parameters["ShadowBrightness"].SetValue(0.25f);
                        }

                        if (newEffect.Parameters["LightDirection"] != null)
                        {
                            newEffect.Parameters["LightDirection"].SetValue(Vector3.Normalize(new Vector3(100, 130, 0)));
                        }

                        if (newEffect.Parameters["LightColor"] != null)
                        {
                            newEffect.Parameters["LightColor"].SetValue(new Vector4(0.8f, 0.8f, 0.8f, 1.0f));
                        }

                        if (newEffect.Parameters["AmbientLightColor"] != null)
                        {
                            newEffect.Parameters["AmbientLightColor"].SetValue(new Vector4(0.2f, 0.2f, 0.2f, 1.0f));
                        }

                        effectMapping.Add(oldEffect, newEffect);
                    }
                }

                // Now that we've found all the effects in use on this mesh,
                // update it to use our new replacement versions.
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                {
                    meshPart.Effect = effectMapping[meshPart.Effect];
                }
            }
            #endregion

            // Now load the shadow model.
            newModel.ModelShadow = LoadShadowModel(PathToModel, Content, ShadowEffect);


            // Now load the utility model.
            newModel.ModelUtility = LoadUtilityModel(PathToModel, Content, UtilityEffect);

            // Add a tag of the Path to the model for debuging
            newModel.ModelMain.Tag = PathToModel;

            return(newModel);
        }