Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

105 Neutral

About OppiXP

  • Rank
  1. Hi, try to round the x- and y-coordinates to the nearest integer when translating.
  2. Hi, I am using the March 2009 SP1 Release of SlimDX. DirectX SDK is installed and debugging of unmanaged code is enabled and I am using the debug runtime of DirectX. There is no error at all. I can render Text with a transparent background and it looks correct. I just cannot figure out how I can tell the SlimDX.Direct3D9.Font to use an opaque backround. As you can see, I am using SpriteFlags.ObjectSpace | SpriteFlags.DoNotModifyRenderState | SpriteFlags.DoNotSaveState because I thought that I can achieve solid text by changing some render states. But I don't know what to change. Thanks in advance.
  3. Hello everybody, I am wondering if it is possible to render solid 2D text using a SlimDX.Direct3D9.Sprite and a SlimDX.Direct3D9.Font. Basically this is what i am doing: textSprite.Begin(SpriteFlags.ObjectSpace | SpriteFlags.DoNotModifyRenderState | SpriteFlags.DoNotSaveState); Device.SetRenderState(RenderState.AlphaBlendEnable, false); text2D.DrawString(textSprite, text, rect, format | DrawTextFormat.NoClip, color); textSprite.End(); text, rect, format and color are parameters of my method. Unfortunately I only get a solid black rectangle. Is it possible to draw black text with a white background? Any help is appreciated! Best regards
  4. Everything works fine now. Many thanks for your help!
  5. Quote:Are you trying to allow the camera to be translated and rotated? Basically I'd like the eye vector to be located on the hull of a sphere whilst looking to the center of the sphere. By using the mouse wheel the user can change the distance to the center and by moving the mouse up/down and left/right the horizontal and vertical position on the hull. The calculation of the view matrix did that fine but obviously screwed up a few things. Could you please give me a hint how I can move the eye vector the way I explained? Thank you very much!
  6. That's it!!! Man! If I use Matrix.LookAtLH the whole thing works perfectly. The next question is how can I rotate the eye vector around (0,0,0) in x and y directions with varying distance?
  7. Yes, the view and projection matrices are always stored in my DX singleton as you can see references to it in my code. The world matrix is set explicitely before unprojecting and has the same scale and translation factors used during rendering the axes. Funny thing though if I assign the identity matrix to the view and projection matrices the coordinates are correct, ranging from -1 to 1 in either x and y direction. Maybe there is something wrong in the unproject method in SlimDX? I have no clue what is going wrong. As far as I understand the whole unproject thing should return coordinates from -1 to 1 as long as I stay inside the "cube" of my coordinate system. This drives me nuts as I have tried at least 5 different tutorials I found and none of them worked. Could it be a problem that the distance of the camera to the coordinate system is always negative? The range is from -19 to -1. Maybe the calculation of the view matrix is not correct. Could you please have a look at it? Many thanks in advance!!!
  8. Hey guys, thanks for your help! I really appreciate it! I tried Buckeyes hint but again no luck. This is what I have so far: // The size of the coordinate system was doubled before so I set the world matrix accordingly. The coordinate sytem is now centered. DX.Instance.SetWorldMatrix(Matrix.Scaling(2f, 2f, 2f), Matrix.Translation(-1, -1, -1)); // Unproject near plane Vector3 nearPlane = Vector3.Unproject(new Vector3(e.X, e.Y, 0), DX.Instance.ViewPort, DX.Instance.CurrentProjectionMatrix, DX.Instance.CurrentViewMatrix, DX.Instance.CurrentWorldMatrix); // Unproject far plane Vector3 farPlane = Vector3.Unproject(new Vector3(e.X, e.Y, 1), DX.Instance.ViewPort, DX.Instance.CurrentProjectionMatrix, DX.Instance.CurrentViewMatrix, DX.Instance.CurrentWorldMatrix); Vector3 direction = farPlane - nearPlane; direction.Normalize(); position = new Vector3( nearPlane.X + direction.X * (-nearPlane.Z / direction.Z), nearPlane.Y + direction.Y * (-nearPlane.Z / direction.Z), nearPlane.Z + direction.Z * (-nearPlane.Z / direction.Z)); Console.WriteLine(position); It seems that the distance and angle of the camera is not taken into account. If I understand this correctly the position vector should return values at z = 0 which is the center of the coordinate system. So if I move the mouse pointer left and right at this z position with camera angles all zero, position.X should return -1 if I hit the left boundary and 1 if I hit the right boundary but I get values ranging from 0.64 to 0.3. I think we are getting close but there is still something I did wrong... The other approach using the plane does not work either. Regards OppiXP [Edited by - OppiXP on February 11, 2010 8:21:49 AM]
  9. Hi, maybe I tell you what I want to achieve. The problem is that I have no idea how to make this work correctly. I am currently working on a 3D view of some measuring data. The user can rotate the camera around the signals and he can change the distance of the camera to the signals. The world's center remains at (0,0,0), only the camera is moved around using the code I posted above. So the camera always looks at (0,0,0) with varying distance. The signals are rendered as linestrips at certain z-positions. The world coordinates never exceed -1 and 1 in any direction. This part works perfectly already. Only one signal can be selected at any time. The user should now be able to place some markers on the samples of this signal using the mouse as illustrated in the image below: The code for picking mentioned earlier does not work correctly and I do not understand why. See the near vector: It always returns values between -0.5 and 0.5 regardless how far away the camera is located from the origin. If the camera was moved 5 units back from the center I would assume X coordinates ranging from -5 to 5 when moving the mouse to the left and right edge of the screen and the camera was not rotated around the signals. If this worked the next idea would be to place a plane at the z position of the selected signal spanning the whole x and y axis and then cast a ray for intersection test with that plane. Is it possible to determine where exactly a ray hit a plane? Any help is appreciated as I am really stuck on this. Best regards
  10. Hello Buckeye, thanks for your reply. I tried this but it was not successful. The bounding box still seems to be somewhere on the screen but not where I expect it to be. Are BoundingBoxes located in Worldspace? Regards OppiXP
  11. Hello guys, I am stuck on picking a certain point on a plane which is located anywhere on the z axis of my coordinate system. The coordinate system can be zoomed and rotated by using my chase camera. Here is what it looks like: The problem is that my coordinates seem to be messed up and I cannot figure out why. The camera is rotated and zoomed by setting up the projection and view matrices in this way: projectionMatrix = Matrix.PerspectiveFovLH( (float)Math.PI / 4, (float)ClientRect.Width / ClientRect.Height, 0.001f, 20f); Matrix trans = Matrix.Translation(0.0f, 0.0f, camDistance); Matrix rot = Matrix.Multiply(Matrix.RotationY(camAngleHorizontal), Matrix.Identity); rot = Matrix.Multiply(Matrix.RotationX(camAngleVertical), rot); viewMatrix = Matrix.Multiply(trans, rot); viewMatrix = Matrix.Invert(viewMatrix); Rotating the camera around my coordinate system works fine. I use this code to determine if a ray intersects a certain plane: protected override void MouseMove(System.Windows.Forms.MouseEventArgs e) { base.MouseMove(e); Plane plane = new Plane(new Vector3(1f, 0, 0), 0); DX.Instance.SetWorldMatrix(Matrix.Identity, Matrix.Identity); Vector3 nearPlane = Vector3.Unproject(new Vector3((float)e.X, (float)e.Y, currentCamDistance), DX.Instance.ViewPort, DX.Instance.CurrentProjectionMatrix, DX.Instance.CurrentViewMatrix, DX.Instance.CurrentWorldMatrix); Vector3 farPlane = Vector3.Unproject(new Vector3((float)e.X, (float)e.Y, 20f), DX.Instance.ViewPort, DX.Instance.CurrentProjectionMatrix, DX.Instance.CurrentViewMatrix, DX.Instance.CurrentWorldMatrix); Vector3 direction = farPlane - nearPlane; direction.Normalize(); Ray ray = new Ray(nearPlane, direction); float distance; Console.WriteLine(Ray.Intersects(ray, plane, out distance)); } Sometimes it seems that the plane is located flat in the upper right corner of the screen... Can please anybody have a look at this and tell me what is wrong? I also tried intersection using a BoundingBox: BoundingBox box = new BoundingBox(new Vector3(0), new Vector3(1)); It seems that the coordinates are not translated correctly. Any help is appreciated! Best Regards OppiXP
  12. OppiXP

    [SlimDX] Clip planes

    Hello guys, finally I managed to use the clip planes correctly. Maybe this could be helpful for some of you. The two clip planes clip all vertices below -0.5 and above 0.5 on the x axis: Plane clipPlane = new Plane(new Vector3(-0.501f, 0f, 0f), new Vector3(1f, 0f, 0.0f)); DX.Instance.Device.SetClipPlane(0, clipPlane); Plane clipPlane2 = new Plane(new Vector3(0.501f, 0f, 0f), new Vector3(-1f, 0f, 0.0f)); DX.Instance.Device.SetClipPlane(1, clipPlane2); DX.Instance.Device.SetRenderState(RenderState.Clipping, true); I did not see that RenderState.ClipPlaneEnable needs a bit link. So this line will enable planes 0 and 1: DX.Instance.Device.SetRenderState(RenderState.ClipPlaneEnable, 3); Whereas this line will disable all clip planes: DX.Instance.Device.SetRenderState(RenderState.ClipPlaneEnable, 0); That was easy! ;)
  13. Hello everybody, I am currently working on a 3 dimensional plot of measurement data (waterfall diagram). What I am trying to do is to implement zooming and scrolling by scaling and translating the trianglestrips. But I cannot figure out how to use the clip planes to clip the data at the left and right ends of the x-axis. Imagine a box with an edge length of 1. I only want to draw the data inside this box. I have tried this to clip the data on the left side of the x axis: Plane clipPlane = new Plane(new Vector3(-1f, 0f, 0f), new Vector3(0.0f, 1f, 0.0f)); DX.Instance.Device.SetClipPlane(0, clipPlane); DX.Instance.Device.SetRenderState(RenderState.ClipPlaneEnable, 0); DX.Instance.Device.SetRenderState(RenderState.Clipping, true); and: Plane clipPlane = new Plane(new Vector3(-1f, 0f, 0f), new Vector3(0.0f, 1f, 0.0f)); clipPlane.Normalize(); Matrix view = DX.Instance.Device.GetTransform(TransformState.View); view.Invert(); view = Matrix.Transpose(view); Matrix projection = DX.Instance.Device.GetTransform(TransformState.Projection); projection.Invert(); projection = Matrix.Transpose(projection); view *= projection; clipPlane = Plane.Transform(clipPlane, view); DX.Instance.Device.SetClipPlane(0, clipPlane); DX.Instance.Device.SetRenderState(RenderState.ClipPlaneEnable, 0); DX.Instance.Device.SetRenderState(RenderState.Clipping, true); Maybe I misunderstood clip planes but there is no clipping at all. Any help is appreciated! Best regards OppiXP EDIT: I figured out that SlimDX writes the following lines to the Output window: Direct3D9: (WARN) :Ignoring redundant SetRenderState - 152 Direct3D9: (WARN) :Ignoring redundant SetRenderState - 136 Could it be possible that this is a bug in SlimDX and the user clipping planes are never used? I just switched to the August Release and there the same issue occurs. Best regards OppiXP [Edited by - OppiXP on December 28, 2009 4:07:54 AM]
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!