sumit381

Members
  • Content count

    11
  • Joined

  • Last visited

Community Reputation

122 Neutral

About sumit381

  • Rank
    Member
  1. Line list rendering problem.

    Hey, EvilSteve I tried turning off alpha blending but it didn't work. Also, how can I apply a material to my grid. I thought a material can only be applied to a mesh but my grid is a primitive type of LineList. Please inform me more in this matter. Thanks. This is the new code that I used: Material m = new Material(); m.Ambient = Color.White; m.AmbientColor = ColorValue.FromColor(Color.White); m.Diffuse = Color.White; m.Diffuse = Color.White; d3dDevice.RenderState.AlphaBlendEnable = false; d3dDevice.Material = m; // Draws line grid d3dDevice.VertexFormat = CustomVertex.PositionColored.Format; d3dDevice.SetStreamSource(0, lineList, 0); d3dDevice.DrawPrimitives(PrimitiveType.LineList, 0, numOfVerts / 2); d3dDevice.RenderState.AlphaBlendEnable = true;
  2. Line list rendering problem.

    Thank you for your input NightMarez but that unfortunately did not fix the problem. My lighting is by default set to false in my device creation method. When I set the lighting to true, the sprites also disappear.
  3. I am making a data visualization program which basically display data on a 3D grid. I am making the grid using a line list. Also, the data points are created in two ways. 1st: using actual 3D mesh spheres. 2nd: using point sprites. When I use the 3D sphere my grid displays correctly. Here is a link to what it looks like: http://img115.imageshack.us/my.php?image=gridlinesappearnv2.gif But when I tried using the point sprites, the grid lines do not seem to appear. Except when I move in closer on the grid I can see that the grid are rendering but they are blending into the background color. Here are links to pictures of what that looks like: http://img48.imageshack.us/my.php?image=gridlinesdontappearju8.gif http://img240.imageshack.us/my.php?image=gridlinecloseupxh3.gif The following is the method that creates the data points: private void DrawDataPoints() { //d3dDevice.SetTexture(0, null); d3dDevice.SetTexture(0, sphereSpriteTexture); myownvertexformat[] spritecoordsarray = new myownvertexformat[dataList.Length]; for (int i = 0; i <= dataList.Length - 1; i++) { #region 3D Spheres - lower framerate // //If a data point is selected then the color sphere covering the // //selected sphere should also move with it. //if (hitColored && hitPos.X == dataList[i].X && hitPos.Y == dataList[i].Y && hitPos.Z == dataList[i].Z) //{ // d3dDevice.Transform.World = Matrix.Translation(currentXHit, currentYHit, currentZHit); // coverMesh.DrawSubset(0); //} //d3dDevice.Transform.World = Matrix.Translation((float)dataList[i].X, (float)dataList[i].Y, (float)dataList[i].Z); //dataSphereMesh.DrawSubset(0); #endregion #region 2D Sprites - higher framerate spritecoordsarray[i] = new myownvertexformat((float)dataList[i].X, (float)dataList[i].Y, (float)dataList[i].Z, 1f, Color.Red.ToArgb()); #endregion } d3dDevice.VertexFormat = CustomVertex.PositionColored.Format | VertexFormats.PointSize | VertexFormats.Diffuse; d3dDevice.DrawUserPrimitives(PrimitiveType.PointList, dataList.Length - 1, spritecoordsarray); } Here is the myownvertexformat struct: struct myownvertexformat { public float xval; public float yval; public float zval; public float PointSize; public int icolor; public myownvertexformat(float fxval, float fyval, float fzval, float psize, int color) { xval = fxval; yval = fyval; zval = fzval; PointSize = psize; icolor = color; } } The following method draws the line grid: private void DrawLineGrid() { lineList = new VertexBuffer(typeof(CustomVertex.PositionColored), numOfVerts, d3dDevice, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default); CustomVertex.PositionColored[] verts = new CustomVertex.PositionColored[numOfVerts]; // x-axis verts[0].Position = new Vector3((float)minX - 1, 0.0f, 0.0f); verts[1].Position = new Vector3((float)maxX + 1, 0.0f, 0.0f); // y-axis verts[2].Position = new Vector3((float)maxX, (float)maxY + 1, 0.0f); verts[3].Position = new Vector3((float)maxX, (float)minY - 1, 0.0f); // z-axis verts[4].Position = new Vector3((float)maxX, 0.0f, (float)minZ - 1); verts[5].Position = new Vector3((float)maxX, 0.0f, (float)maxZ + 1); // X-Z Grid int counter = 1; for (int v = 6; v <= (numOfZLines * 2) + 6; v += 2) { verts[v].Position = new Vector3((float)minX, 0, (float)minZ + counter); verts[v + 1].Position = new Vector3((float)maxX, 0, (float)minZ + counter); counter++; } // Y-Z Grid counter = 1; for (int v = (numOfZLines * 2) + 6; v <= (numOfZLines * 4) + 6; v += 2) { verts[v].Position = new Vector3((float)maxX, (float)minY, (float)minZ + counter); verts[v + 1].Position = new Vector3((float)maxX, (float)maxY, (float)minZ + counter); counter++; } // X-Y Grid counter = 0; for (int v = (numOfXLines * 4) + 6; v <= (numOfXLines * 6) + 6; v += 2) { verts[v].Position = new Vector3((float)minX + counter, (float)minY, 0); verts[v + 1].Position = new Vector3((float)minX + counter, (float)maxY, 0); counter++; } counter = 0; for (int v = (numOfZLines * 6) + 6; v <= (numOfZLines * 8) + 6; v += 2) { verts[v].Position = new Vector3((float)minX + counter, 0, (float)minZ); verts[v + 1].Position = new Vector3((float)minX + counter, 0, (float)maxZ); counter++; } counter = 1; for (int v = (numOfZLines * 8) + 6; v <= (numOfZLines * 10) + 6; v += 2) { verts[v].Position = new Vector3((float)maxX, (float)minY + counter, (float)minZ); verts[v + 1].Position = new Vector3((float)maxX, (float)minY + counter, (float)maxZ); counter++; } counter = 1; for (int v = (numOfXLines * 10) + 6; v <= (numOfXLines * 12) + 4; v += 2) { verts[v].Position = new Vector3((float)minX, (float)minY + counter, 0); verts[v + 1].Position = new Vector3((float)maxX, (float)minY + counter, 0); counter++; } for (int i = 0; i <= 5; i++) verts[i].Color = Color.Red.ToArgb(); for (int i = 6; i <= numOfVerts - 1; i++) verts[i].Color = Color.Green.ToArgb(); lineList.SetData(verts, 0, LockFlags.None); lineList.Unlock(); } The following code is in my render method: // Draws line grid d3dDevice.VertexFormat = CustomVertex.PositionColored.Format; d3dDevice.SetStreamSource(0, lineList, 0); d3dDevice.DrawPrimitives(PrimitiveType.LineList, 0, numOfVerts / 2); Please help in any way you can. Thanks!!!
  4. Circular camera movement

    Thank you for the help everyone provided me. To answer your question Evil Steve, it doesn't really matter to me if the camera moves around the grid or the grid rotates in front of the camera. I just need the effect of the camera rotating around the grid. I chose to move the camera around the grid because I tried doing a world transform rotation but I got undesired results when I did that. Thanks again for your help everyone.
  5. I am trying to create a camera where it moves in a circle about a fixed 3D point. I have been using the following code and it results in a square like movement. if (rotateCamera) { if (vEye.Z &gt;= midZ && vEye.X &lt;= midX) { //z movement vEye.Z -= moveSpeed * elapsedTime; //vLook.Z -= elapsedTime; //x movement vEye.X -= moveSpeed * elapsedTime; //vLook.X += elapsedTime; } else if (vEye.Z &lt;= midZ && vEye.X &lt;= midX) { vEye.Z -= moveSpeed * elapsedTime; //vLook.Z += elapsedTime; vEye.X += moveSpeed * elapsedTime; //vLook.X -= elapsedTime; } else if (vEye.Z &lt;= midZ && vEye.X &gt;= midX) { vEye.Z += moveSpeed * elapsedTime; //vLook.Z -= elapsedTime; vEye.X += moveSpeed * elapsedTime; //vLook.X -= elapsedTime; } else { vEye.Z += moveSpeed * elapsedTime; //vLook.Z -= elapsedTime; vEye.X -= moveSpeed * elapsedTime; //vLook.X += elapsedTime; } } The midX, midY, midZ variables are midpoints on a grid I have set up. I basically want the camera to rotate around the grid while always facing in the middle of the grid. How can I make the camera move in a circle around a fixed point and also always have the camera facing that fixed point? Thank you for your help. EDIT: Please remember 'source' tags in future... [Edited by - jollyjeffers on March 28, 2007 9:33:31 AM]
  6. Drawing a grid

    Hi, I was wonder what would be the best way to draw a grid in directX? The size of the grid will be determined by data that is passed into the program by an xml file. This data will contain data points that have x, y, z values. Below is the code I am current using. I don't know if it seems to be too efficient. lineList = new VertexBuffer(typeof(CustomVertex.PositionColored), numOfVerts, d3dDevice, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default); CustomVertex.PositionColored[] verts = new CustomVertex.PositionColored[numOfVerts]; // x-axis verts[0].Position = new Vector3(-2.0f, 0.0f, 0.0f); verts[1].Position = new Vector3(7.0f, 0.0f, 0.0f); // y-axis verts[2].Position = new Vector3(7.0f, 9.0f, 0.0f); verts[3].Position = new Vector3(7.0f, 0.0f, 0.0f); // z-axis verts[4].Position = new Vector3(7.0f, 0.0f, 0.0f); verts[5].Position = new Vector3(7.0f, 0.0f, 9.0f); // loop creates the grid lines on the x-z plane int counter = 0; for (int v = 0; v < numOfGridVerts; v += 2) { if (v == 0) { verts[v + 6].Position = new Vector3(-2.0f, 0.0f, v + 1f); verts[v + 7].Position = new Vector3(7.0f, 0.0f, v + 1f); } else { verts[v + 6].Position = new Vector3(-2.0f, 0.0f, (float)v - counter); verts[v + 7].Position = new Vector3(7.0f, 0.0f, (float)v - counter); } counter++; } for (int i = 0; i <= numOfVerts - 1; i++) { verts[i].Color = Color.Red.ToArgb(); } lineList.SetData(verts, 0, LockFlags.None); Anyway, please help if you can, thank you.
  7. Directx resource usage question.

    Thanks for your help. I have tried using sprites before but for some reason the rendering for sprites was so much slower than spheres. Here is the code I used for the sprites: //d3dDevice.SetTexture(0, null); myownvertexformat[] spritecoordsarray = new myownvertexformat[dataList.Length]; for (int i = 0; i <= dataList.Length - 1; i++) { #region makes data points using 3D spheres //d3dDevice.Transform.World = Matrix.Translation((float)dataList[i].X, (float)dataList[i].Y, (float)dataList[i].Z); //dataSphereMesh.DrawSubset(0); #endregion #region makes data points using sprites spritecoordsarray[i] = new myownvertexformat((float)dataList[i].X, (float)dataList[i].Y, (float)dataList[i].Z, 0.5f); d3dDevice.SetTexture(0, sphereSpriteTexture); d3dDevice.VertexFormat = VertexFormats.Position | VertexFormats.PointSize | VertexFormats.Diffuse; d3dDevice.DrawUserPrimitives(PrimitiveType.PointList, dataList.Length, spritecoordsarray); #endregion } The image I am using for the sprite is JPG format approximately 1.7Kb in file size and 40x40 in pixel size. Is there something I am not doing correctly in this? Please help if possible. Thanks.
  8. I am developing a data visualization app using directx. The app basically with get input data from a file and make a 3-D grid with data points. I am currently using sphere objects for the data points; however, soon I will need to handle maybe millions of data points. What is the best way to represent those points, using actual spheres or using sprites? I learned a little about billboarding. Would that render faster as opposed to spheres? Thank you for your help.
  9. I am developing an app using VS05, C#, and the Feb 07 directx sdk. I am looking at the CustomUI sample included with the sdk and I would like to use a button on my app. I don't need the whole GUI, just one button on top of my app. I am using this code but I don't see any results. private void CreateUI() { hud.SetLocation(0, 0); hud.SetSize(100, 100); sampleUtility.Button playBtn = hud.AddButton(0, "Click Me", 1, 1, 20, 20); playBtn.Click += new EventHandler(clickBtnOnClick); hud.SetControlEnable(0, true); } private void clickBtnOnClick(object sender, EventArgs e) { this.Text = "You clicked the button."; } The CreateUI() method is called in my Render function after my device.BeginScene() statement. Can anyone please help me to display the button. I tried working through the CustomUI sample code but I couldn't really figure it out. Thanks for you help.
  10. Mesh.Intersect issue

    Thanks remigius. I inserted a break statement in the loop and it works great!
  11. Hello, I am writing a DX app using C#, VS05, and DX 9.0c SDK. My app takes an xml files filed with x,y,z coords and makes an array of Vector3 called dataList. This data is then used to create a bunch of spheres as data points on a grid. The problem I am having is being able to select the data point when I click on them. The data points are rendered as sphere meshes stored in a mesh called dataSphereMesh. When I render the data points, I loop through my dataList array and create a subset of the dataSphereMesh for each item in the array. This is the picking code that I am currently using: private void DrawDataPoints() { d3dDevice.SetTexture(0, null); for (int i = 0; i &lt;= dataList.Length - 1; i++) { d3dDevice.Transform.World = Matrix.Translation((float)dataList[i].X, (float)dataList[i].Y, (float)dataList[i].Z); dataSphereMesh.DrawSubset(0); } } protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) { mousing = true; string test = ""; for (int i = 0; i &lt;= dataList.Length - 1; i++) { dataPosition = new Vector3(dataList[i].X, dataList[i].Y, dataList[i].Z); if (testHit(e.X, e.Y, dataPosition)) test = "it's a hit!"; else test = "false"; } this.Text = test; } private bool testHit(Single x, Single y, Vector3 position) { Vector3 near = new Vector3(x, y, 0); Vector3 far = new Vector3(x, y, 1); near.Unproject(d3dDevice.Viewport, d3dDevice.Transform.Projection, d3dDevice.Transform.View, Matrix.Translation(position)); far.Unproject(d3dDevice.Viewport, d3dDevice.Transform.Projection, d3dDevice.Transform.View, Matrix.Translation(position)); far.Subtract(near); IntersectInformation closest = new IntersectInformation(); if (dataSphereMesh.Intersect(near, far, out closest)) return true; else return false; } When I run the code, I am only able to click on the very last item in the array. Please help in this matter if possible, thanks. [Edited by - Washu on February 13, 2007 12:06:20 PM]