Haha awesome.
I've always been meaning to sort out the WorldToScreen stuff. Looks like I need to do a bit of a refresher on matrix math...
Haha awesome.
I've always been meaning to sort out the WorldToScreen stuff. Looks like I need to do a bit of a refresher on matrix math...
I don't think it's anything on his part really, just using D3D functions. Surely there's a function in the API that draws a 3D line :P
EDIT: On second thought, nevermind.
Last edited by lanman92; 11-22-2009 at 11:15 PM.
It wouldn't be too much work..
Now all you need to create the Projection and View matrices is the Camera Position, your 'Target' Position (which can be easily calculated), Your FieldOfView (90?), and Aspect ratio.Code:public static Vector2 WorldToScreen(Vector3 world) { Vector3 Project = GraphicsDevice.Viewport.Project(world, Projection, View, Matrix.Identity); // Check our Z, otherwise return a huge Vector off-screen because I'm Lazy. if (Project.Z < 1.0f) return new Vector2((float)Math.Floor(Project.X), (float)Math.Floor(Project.Y)); else return new Vector2(GraphicsDevice.Viewport.Width * 4, GraphicsDevice.Viewport.Height * 4); }
That leaves you really with only Two things you need to find (Camera position/Camera Angle or 'Target' Position), because the rest can be calculated or found with simpler methods.
Then all you would have to do to create the matrices is a couple lines of code.
Simple. Easy. Plus it works.Code:float AspectRatio = GraphicsDevice.Viewport.Width / GraphicsDevice.Viewport.Height; Matrix View = Matrix.CreateLookAt(CameraPosition, Target, Vector.Up); Matrix Projection = Matrix.CreatePerspectiveFieldOfView(90.0f, AspectRatio, 0.01f, 8192.0f);
What Matrix library do you recommend for simple things like this? Custom?
Old code, new face!
Bots using waypoint graphs instead of the more advanced polygons mesh suffer badly from the "on rails"-syndrome though
[ame=http://www.youtube.com/watch?v=A33aO9bF3Q0]YouTube - Wannabe NavMesh Generation[/ame]
Edit: Looks like the embedded version doesn't have the audio removed. How awesome. Watch in HD!
Edit2: Nvm they deleted the music. Hf with this -,-
Last edited by Robske; 11-25-2009 at 05:47 PM.
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding
"I cried a little earlier when I had to poop" - Sku
Very cool!
Looks nice Robske.
I'm widely known as TheUltimateParadox
very nice robske, looks amazing
The yellow is the WMO (Orgrimmar in this case)
The pink is our nav mesh. And yes; pathfinding works.
Omg , i'm , i'm ...ahhhh *crying*