}//end draw #if XBOX == FALSE /// <summary> /// Draws the model attached into the pick buffer /// </summary> public override void DrawPick(XPickBuffer pick_buf, XICamera camera) { // don't draw if we don't have a model //null checks are for editor! //remove these eventually maybe using a compiler directive for an editorer version of the DLL? if (!tree.loaded) { return; } //if (!mPickEnabled) // return; pick_buf.PushMatrix(MatrixMode.World, this.PhysicsObject.GetWorldMatrix(null, Vector3.Zero)); pick_buf.PushPickID(this.ComponentID); //trunk pick_buf.PushVertexBuffer(tree.Trunk.vertexBuffer); pick_buf.PushIndexBuffer(tree.Trunk.indexBuffer); pick_buf.PushVertexDeclaration(tree.Trunk.vertexDeclaration); pick_buf.QueueIndexedPrimitives(Microsoft.Xna.Framework.Graphics.PrimitiveType.TriangleList, 0, 0, 0, tree.Trunk.vertices.Length, 0, tree.Trunk.indices.Length / 3); pick_buf.PopVertexDeclaration(); pick_buf.PopVertexBuffer(); pick_buf.PopIndexBuffer(); pick_buf.PopPickID(); pick_buf.PopMatrix(MatrixMode.World); }
/// <summary> /// Creates a new instance of Manipulator /// </summary> /// <param name="graphics">The IGraphicsDeviceService with which drawing will be performed</param> /// <param name="camera">A provider for camera view and projection data</param> /// <param name="input">A provider for input data</param> public Manipulator(IGraphicsDeviceService graphics, XICamera camera, XIInputProvider input) { mGraphics = graphics; mCamera = camera; mInput = input; mSelectedAxes = AxisFlags.None; mActiveMode = TransformationMode.None; mEnabledModes = TransformationMode.None; mVectorSpace = VectorSpace.World; mPickBuffer = new XPickBuffer(graphics); mSettings = new ManipulatorSettings(); mSettings.RestoreDefaults(); mGraphics.DeviceCreated += new EventHandler(OnDeviceCreated); mGraphics.DeviceReset += new EventHandler(CreateDepthBuffer); mGraphics.DeviceResetting += new EventHandler(DisposeDepthBuffer); mGraphics.DeviceDisposing += new EventHandler(OnDeviceDisposing); if ((mGraphics.GraphicsDevice != null) && !mGraphics.GraphicsDevice.IsDisposed) { OnDeviceCreated(this, null); CreateDepthBuffer(this, null); } mUndoStack = new Stack <TransformState>(); mRedoStack = new Stack <TransformState>(); mDrawFunctions = new DrawFunctions(); mManipFunctions = new ManipFunctions(); mDrawFunctions[TransformationMode.None][AxisFlags.X] = mDrawFunctions[TransformationMode.None][AxisFlags.Y] = mDrawFunctions[TransformationMode.None][AxisFlags.Z] = delegate(AxisFlags axis) { Vector3 unit = GetUnitAxis(axis); XPrimitives.DrawLine(mGraphics.GraphicsDevice, Vector3.Zero, unit); }; InitTranslation(); InitRotation(); InitScale(); }
public void Initialize(GraphicsDevice graphics_device, GraphicsDeviceManager graphics_device_manager, ContentManager content_manager) { mGraphicsDeviceManager = graphics_device_manager; mGraphicsDevice = graphics_device; mContentManager = content_manager; var current_display_mode = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode; mScreenDim = new xCoord(current_display_mode.Width, current_display_mode.Height); mGraphicsDeviceManager.IsFullScreen = false; // true; mGraphicsDeviceManager.PreferredBackBufferWidth = mScreenDim.x; mGraphicsDeviceManager.PreferredBackBufferHeight = mScreenDim.y; mGraphicsDeviceManager.ApplyChanges(); XSimpleDraw.Initialize(); XSimpleDraw.CreateInstance(xeSimpleDrawType.WorldSpace_Transient).Init(graphics_device, persistent: false, max_lines: 2000, max_triangles: 50); XSimpleDraw.CreateInstance(xeSimpleDrawType.WorldSpace_Persistent).Init(graphics_device, persistent: true, max_lines: 50, max_triangles: 50); XSimpleDraw.CreateInstance(xeSimpleDrawType.ScreenSpace_Transient).Init(graphics_device, persistent: false, max_lines: 200, max_triangles: 50); XSimpleDraw.CreateInstance(xeSimpleDrawType.ScreenSpace_Persistent).Init(graphics_device, persistent: true, max_lines: 50, max_triangles: 50); XSimpleDraw.CreateInstance(xeSimpleDrawType.WorldSpace_Persistent_Map).Init(graphics_device, persistent: true, max_lines: 50, max_triangles: 1600000); mMainWorldCam = new XWorldCam(mScreenDim); mScreenCam = new XScreenCam(mScreenDim); }
/// <summary> /// Draws the model attached into the pick buffer /// </summary> public override void DrawPick(XPickBuffer pick_buf, XICamera camera) { if (!this.loaded) { return; } //if (!mPickEnabled) // return; pick_buf.PushMatrix(MatrixMode.World, Matrix.Identity); pick_buf.PushPickID(this.ComponentID); pick_buf.PushVertexDeclaration(new VertexDeclaration(X.GraphicsDevice, VertexPositionTexture.VertexElements)); pick_buf.QueueUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 2); pick_buf.PopVertexDeclaration(); pick_buf.PopPickID(); pick_buf.PopMatrix(MatrixMode.World); }
/// <summary> /// Draws the model attached into the pick buffer /// </summary> public override void DrawPick(XPickBuffer pick_buf, XICamera camera) { // don't draw if we don't have a model //null checks are for editor! //remove these eventually maybe using a compiler directive for an editorer version of the DLL? if (model == null || !model.loaded) { return; } //if (!mPickEnabled) // return; pick_buf.PushMatrix(MatrixMode.World, this.GetWorldMatrix()); pick_buf.PushPickID(this.ComponentID); foreach (ModelMesh mesh in model.Model.Meshes) { pick_buf.PushVertexBuffer(mesh.VertexBuffer); pick_buf.PushIndexBuffer(mesh.IndexBuffer); foreach (ModelMeshPart part in mesh.MeshParts) { pick_buf.PushVertexDeclaration(part.VertexDeclaration); pick_buf.QueueIndexedPrimitives(Microsoft.Xna.Framework.Graphics.PrimitiveType.TriangleList, part.StreamOffset, part.BaseVertex, 0, part.NumVertices, part.StartIndex, part.PrimitiveCount); pick_buf.PopVertexDeclaration(); } pick_buf.PopVertexBuffer(); pick_buf.PopIndexBuffer(); } pick_buf.PopPickID(); pick_buf.PopMatrix(MatrixMode.World); }
/// <summary> /// Draws the model attached to the model into the pick buffer /// </summary> public virtual void DrawPick(XPickBuffer pick_buf, XICamera camera) { }
/// <summary> /// Creates a new instance of Manipulator /// </summary> /// <param name="graphics">The IGraphicsDeviceService with which drawing will be performed</param> /// <param name="camera">A provider for camera view and projection data</param> public Manipulator(IGraphicsDeviceService graphics, XICamera camera) : this(graphics, camera, new Input(graphics)) { }