Mesh namespace not found

Started by
0 comments, last by jcochran 20 years, 1 month ago
For some reason Visual Studio is not recognizing the Mesh namespace. I am trying to initialize a mesh variable; private Mesh mesh = null; The error is C:\Documents and Settings\Jason\My Documents\Visual Studio Projects\MDX9Ch5\Form1.cs(51): The type or namespace name ''Mesh'' could not be found (are you missing a using directive or an assembly reference?) I have both DirectX and DirectX.Direct3d referenced and I have both of my "using" statements. This is managed directx using c#. The sample I am using is coming from Tom Miller''s book of chapter 5 on using a mesh. I have the summer update for directx so that is not it. The code insight is not even recognizing Mesh. It''s really weird. My entire code is below: ======== Begin Code ========== using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace MDX9Ch5 { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private Device device = null; private Mesh mesh = null; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; private float angle = 0.0f; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); } /// /// We will initialize our graphics device here /// public void InitializeGraphics() { // Set our presentation parameters PresentParameters presentParams = new PresentParameters(); presentParams.Windowed = true; presentParams.SwapEffect = SwapEffect.Discard; presentParams.AutoDepthStencilFormat = DepthFormat.D16; presentParams.EnableAutoDepthStencil = true; // Create our device device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams); Mesh mesh = Mesh.Box(device, 2.0f, 2.0f, 2.0f); } private void SetupCamera() { device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, this.Width / this.Height, 1.0f, 100.0f); device.Transform.View = Matrix.LookAtLH(new Vector3(0,0, 18.0f), new Vector3(), new Vector3(0,1,0)); device.RenderState.Ambient = Color.DarkBlue; device.Lights[0].Type = LightType.Directional; device.Lights[0].Diffuse = Color.DarkBlue; device.Lights[0].Direction = new Vector3(0, -1, -1); device.Lights[0].Commit(); device.Lights[0].Enabled = true; } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.CornflowerBlue, 1.0f, 0); SetupCamera(); device.BeginScene(); // Draw our boxes DrawBox(angle / (float)Math.PI, angle / (float)Math.PI * 2.0f, angle / (float)Math.PI / 4.0f, 0.0f, 0.0f, 0.0f); DrawBox(angle / (float)Math.PI, angle / (float)Math.PI / 2.0f, angle / (float)Math.PI * 4.0f, 5.0f, 0.0f, 0.0f); DrawBox(angle / (float)Math.PI, angle / (float)Math.PI * 4.0f, angle / (float)Math.PI / 2.0f, -5.0f, 0.0f, 0.0f); DrawBox(angle / (float)Math.PI, angle / (float)Math.PI * 2.0f, angle / (float)Math.PI / 4.0f, 0.0f, -5.0f, 0.0f); DrawBox(angle / (float)Math.PI, angle / (float)Math.PI / 2.0f, angle / (float)Math.PI * 4.0f, 5.0f, -5.0f, 0.0f); DrawBox(angle / (float)Math.PI, angle / (float)Math.PI * 4.0f, angle / (float)Math.PI / 2.0f, -5.0f, -5.0f, 0.0f); DrawBox(angle / (float)Math.PI, angle / (float)Math.PI * 2.0f, angle / (float)Math.PI / 4.0f, 0.0f, 5.0f, 0.0f); DrawBox(angle / (float)Math.PI, angle / (float)Math.PI / 2.0f, angle / (float)Math.PI * 4.0f, 5.0f, 5.0f, 0.0f); DrawBox(angle / (float)Math.PI, angle / (float)Math.PI * 4.0f, angle / (float)Math.PI / 2.0f, -5.0f, 5.0f, 0.0f); device.EndScene(); device.Present(); this.Invalidate(); } private void DrawBox(float yaw, float pitch, float roll, float x, float y, float z) { angle += 0.01f; device.Transform.World = Matrix.RotationYawPitchRoll(yaw, pitch, roll) * Matrix.Translation(x, y, z); Material boxMaterial = new Material(); boxMaterial.Ambient = Color.White; boxMaterial.Diffuse = Color.White; device.Material = boxMaterial; mesh.DrawSubset(0); } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.Size = new Size(800,600); this.Text = "Form1"; } #endregion /// /// The main entry point for the application. /// static void Main() { using (Form1 frm = new Form1()) { // Show our form and initialize our graphics engine frm.Show(); frm.InitializeGraphics(); Application.Run(frm); } } } } ======== EndCode ==========
Advertisement
I found out why. I forgot to reference the Microsoft.DirectX.Direct3DX namespace, which includes the Mesh container.

I guess just simply posting a question to yourself is a healthy way of finding solutions.

This topic is closed to new replies.

Advertisement