/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { X = new XMain(graphics.GraphicsDevice, Services, "", freeCamera); //We are going to use a right hand corrdinate system switch default cull mode to refelect this //NOTE: Using the default model processor will not work with this since its winding order is backwards X.GraphicsDevice.RenderState.CullMode = CullMode.CullClockwiseFace; #if DEBUG XDebugVolumeRenderer.InitializeBuffers(X.GraphicsDevice, 50); #endif X.FrameRate.DisplayFrameRate = true; X.Console.AutoDraw = false; X.Debug.StartPosition.Y = 200; resources = new XResourceGroup(ref X); input = new InputProcessor(ref X, this); menus = new MenuManager(ref X); //menu to the debugnodraw list X.Renderer.DebugNoDraw.Add(menus); //Make some Cameras freeCamera = new XFreeLookCamera(ref X, .1f, 1000f); freeCamera.Position = new Vector3(0, 10, 50); driverCamera = new XFreeLookCamera(ref X, .1f, 1000f); chase = new XChaseCamera(ref X, .1f, 1000f); currentCamera = chase; X.DefaultCamera = freeCamera; base.Initialize(); }
public MenuManager(ref XMain X) : base(ref X) { DrawOrder = 500; Buttons.Add("Button 1"); Buttons.Add("Button 2"); Buttons.Add("Exit"); }
public ComponentPluginManager(XMain X) { this.X = X; Plugins.Add(new XDynamicSky_Plugin(X)); Plugins.Add(new XEnvironmentParameters_Plugin(X)); Plugins.Add(new XHeightMap_Plugin(X)); Plugins.Add(new XWater_Plugin(X)); Plugins.Add(new XModel_Plugin(X)); Plugins.Add(new XActor_Plugin(X)); Plugins.Add(new XProp_Plugin(X)); Plugins.Add(new XCamera_Plugin(X)); Plugins.Add(new XTree_Plugin(X)); Plugins.Add(new XTreeSystem_Plugin(X)); Plugins.Add(new XSkyBox_Plugin(X)); Plugins.Add(new XWaterFast_Plugin(X)); Plugins.Add(new XTreeModel_Plugin(X)); Plugins.Add(new XCubeTriggerVolume_Plugin(X)); Plugins.Add(new XAnimatedActor_Plugin(X)); // Add any custom plugins for custom components here }
protected override void Initialize() { time = new XEditorGameTime(); X = new XMain(this.GraphicsDevice, this.Services, ContentRootDir, camera); //setup some basic usefull settings X.Gravity = new Vector3(0, -40, 0); X.UpdatePhysics = false; X.FrameRate.DisplayFrameRate = true; X.Console.AutoDraw = false; X.Debug.StartPosition.Y = 200; camera = new XFreeLookCamera(ref X, 0.1f, 1000f); //set the initial position of the camera such that we are looking at the center of the game world (0,0,0) camera.Position = new Vector3(30f, 15f, 40f); //so we look at center add in a rotation (trial and error) camera.Rotate(new Vector3(MathHelper.ToRadians(-10f), MathHelper.ToRadians(40f), 0)); X.LoadContent(); X.Physics.EnableFreezing = true; time.TotalGameTime.Reset(); time.TotalGameTime.Start(); time.ElapsedGameTime.Reset(); time.ElapsedGameTime.Start(); hasFocus = false; dragdroprelease = false; SetupBaseComponents(); //Begin draw timer! //redraw = new Timer(); //redraw.Interval = 1; //redraw.Start(); //redraw.Tick += new EventHandler(redraw_Tick); // Hook the idle event to constantly redraw our animation. Application.Idle += delegate { Invalidate(); }; }
public XEnvironmentParameters_Plugin(XMain X) : base(X) { type = typeof(XEnvironmentParameters); group = "Environment"; }
public XWater_Plugin(XMain X) : base(X) { type = typeof(XWater); group = "Environment"; }
public XModel_Plugin(XMain X) : base(X) { this.type = typeof(XModel); group = "Models"; }
public XTree_Plugin(XMain X) : base(X) { type = typeof(XTree); group = "Actors"; }
public ComponentPlugin(XMain X) { this.X = X; }
public XHeightMap_Plugin(XMain X) : base(X) { type = typeof(XHeightMap); group = "Environment"; }
public ModelDraw(ref XMain X, Model m, string name) { this.X = X; name_ = name; model_ = m; world_ = Matrix.Identity; // I'll need the world-space pose of each bone matrices_ = new Matrix[m.Bones.Count]; // inverse bind pose for skinning pose only object ibp; Dictionary <string, object> tagDict = m.Tag as Dictionary <string, object>; if (tagDict == null) { throw new System.ArgumentException("Model {0} wasn't processed with the AnimationProcessor.", name); } if (tagDict.TryGetValue("InverseBindPose", out ibp)) { inverseBindPose_ = ibp as SkinnedBone[]; CalculateIndices(); } // information about bounds, in case the bind pose contains scaling object bi; if (((Dictionary <string, object>)m.Tag).TryGetValue("BoundsInfo", out bi)) { boundsInfo_ = bi as BoundsInfo; } if (boundsInfo_ == null) { boundsInfo_ = new BoundsInfo(1, 0); } // pick apart the model, so I know how to draw the different pieces List <Chunk> chl = new List <Chunk>(); foreach (ModelMesh mm in m.Meshes) { int mmpIx = 0; foreach (ModelMeshPart mmp in mm.MeshParts) { ++mmpIx; // chunk is used to draw an individual subset Chunk ch = new Chunk(); // set up all the well-known parameters through the EffectConfig helper. //TODO: remove this line, ch.Fx gets replaced later on 2 lines down //ch.Fx = new EffectConfig(ref X, mmp.Effect, mm.Name + "_" + mmpIx.ToString()); ch.SAS = new SASContainer(ref X); ch.Fx = mmp.Effect; // if this effect is skinned, set up additional data if (mmp.Effect.Parameters["Pose"] != null) { // If I haven't built the pose, then build it now if (pose_ == null) { if (inverseBindPose_ == null) { throw new System.ArgumentNullException(String.Format( "The model {0} should have an inverse bone transform because it has a pose, but it doesn't.", name)); } // Send bones as sets of three 4-vectors (column major) to the shader pose_ = new Vector4[inverseBindPose_.Length * 3]; for (int i = 0; i != inverseBindPose_.Length; ++i) { // start out with the identity pose (which is terrible) pose_[i * 3 + 0] = new Vector4(1, 0, 0, 0); pose_[i * 3 + 1] = new Vector4(0, 1, 0, 0); pose_[i * 3 + 2] = new Vector4(0, 0, 1, 0); } } ch.SAS.Pose = pose_; } ch.Mesh = mm; ch.Part = mmp; // check out whether the technique contains transparency EffectAnnotation ea = mmp.Effect.CurrentTechnique.Annotations["transparent"]; if (ea != null && ea.GetValueBoolean() == true) { ch.Deferred = true; } chl.Add(ch); } } // use a native array instead of a List<> for permanent storage chunks_ = chl.ToArray(); // calculate bounds information (won't take animation into account) CalcBoundingSphere(); }
public XDynamicSky_Plugin(XMain X) : base(X) { type = typeof(XDynamicSky); group = "Environment"; }
public InputProcessor(ref XMain X, Game parent) { this.X = X; this.parent = parent; }
public XCubeTriggerVolume_Plugin(XMain X) : base(X) { type = typeof(XCubeTriggerVolume); group = "Game Logic"; }
public XProp_Plugin(XMain X) : base(X) { type = typeof(XProp); group = "Actors"; }
public XAnimatedActor_Plugin(XMain X) : base(X) { type = typeof(XAnimatedActor); group = "Actors"; }
public XTreeSystem_Plugin(XMain X) : base(X) { type = typeof(XTreeSystem); group = "Environment"; }
public XCamera_Plugin(XMain X) : base(X) { type = typeof(XCamera); group = "Cameras"; }
public XSkyBox_Plugin(XMain X) : base(X) { type = typeof(XSkyBox); group = "Environment"; }