• Content count

  • Joined

  • Last visited

Community Reputation

594 Excellent

About ErnieDingo

  • Rank

Personal Information

  • Location
  • Interests

Recent Profile Visitors

1754 profile views
  1. This is my c# code, its my toolkit of functions i've collected over time, I had completely forgotten the implementation. public static void CalcRay(int x, int y, ref Vector3 p1, ref Vector3 p2, Matrix a_viewMatrix, Viewport a_viewPort) { float NEAR = 0.1f; float FAR = 1000.0f; float FOV = 0.9f; //float WIDTH = 1920.0f; //float HEIGHT = 1080.0f; float WIDTH_DIV_2 = (a_viewPort.Width * 0.5f); float HEIGHT_DIV_2 = (a_viewPort.Height * 0.5f); float ASPECT = a_viewPort.AspectRatio; //float ASPECT = 1.0f; float dx, dy; //D3DMATRIX invMatrix, viewMatrix; Matrix invMatrix = Matrix.Invert(a_viewMatrix); dx = (float)Math.Tan(FOV * 0.5f) * (x / WIDTH_DIV_2 - 1.0f) * ASPECT; dy = (float)Math.Tan(FOV * 0.5f) * (1.0f - y / HEIGHT_DIV_2); p1 = new Vector3(dx * NEAR, dy * NEAR, NEAR); p2 = new Vector3(dx * FAR, dy * FAR, -FAR); p1 = (Vector3)Vector3.Transform(p1, invMatrix); p2 = (Vector3)Vector3.Transform(p2, invMatrix); }
  2. If you want a peak wave then constrain the sine wave value returned to height > 0. This will give you a repeating arcs. Then just use z = 1 - height to flip this. You will get a series of u shaped waves. You need to play with the normal but should help get you the shape you want. I will play around with my code tonight.
  3. This one sort of gives me a headache because im facing into it at the moment with my game, the exact same problem. The issue is compounded when I feed the co-ordinate results back into the same function to generate additional wave data. Im not sure there is even a non brute force method. My thoughts, sample in 5 points, the central point, and 4 points (1 each side of the point in the XZ and YZ planes) equal to the max distance in the plane that it can travel (I assume you use Z as your height). Then approximate. This ends up being 5 times more costly than a single simulation point. But you should at the least be able to solve on a curve for x and y because you have 3 points in each plane. And that your required X and Y co-ordinate are within the sample space. Horrible, but my first thought to solve for now, and its an approximation of epic proportions.