iperez Posted June 27, 2008 Report Share Posted June 27, 2008 Hi all, I have been working on a complete remake of X-COM for a little while, and I realized that instead of branching off into my own project, I should try to provide whatever help I can to this existing project. I have mostly been working on the Geoscape, where I have actually come quite far I think. I have the Geoscape rendered (in wireframe so far) exactly how it is in the game. I already know how to add the texture, I just haven't got to it yet because I'm stuck on one part: Translating screen (i.e. mouse) coordinates to the geoscape coordinates. I could really use some help with this if anyone is really good at math. Here is a link to my test program: http://www.ianandmonica.com/geoscapetest.zip Arrow Keys = rotate globeHome = zoom inEnd = zoom out Thanks,Ian Link to comment Share on other sites More sharing options...
kafros Posted June 28, 2008 Report Share Posted June 28, 2008 (edited) Very nice try iperez Concerning your question, you may want to have a look at the source of another open source project, for example Xenocide or Alien Invasion. Edited June 29, 2008 by Kratos Link to comment Share on other sites More sharing options...
Kratos Posted June 28, 2008 Report Share Posted June 28, 2008 What we (ufo2000) have so far: - A globe with texture- Left and right rotation using arrow keys (could be better).- Time (not noticeable) using the function keys. If you want to help with the Geoscape, read here and here. Btw, I cannot run your program, I don't have Windows. UFO2000 and Xenocide are two different entities. In UFO2000 we use C++ for programming, and Lua for scripting, while staying closest, graphically, to the original X-com. Xenocide uses C# (and something else?) while using mostly newer graphics such as 3D, straying from X-com somewhat. Link to comment Share on other sites More sharing options...
Guest Azrael Strife Posted June 29, 2008 Report Share Posted June 29, 2008 Alright... here we go... take two... hopefully this time my post will pass the test... iperez, I don't seem to be allowed to comment on the previous two posts, but expanding on kafros post, you could very well take a look at the Project Xenocide codebases to look at how our programmers dealt with the issue you are having, you even have two flavors to pick from: C++ and C# hopefully you'll get a good idea of how to do it there. Good luck! Link to comment Share on other sites More sharing options...
feliciafan89 Posted August 26, 2008 Report Share Posted August 26, 2008 I've been getting back into XCOM slowly... but I'd love to see what comes out after that prototype globe from ufo2000! Any word on adding labels to the regions and countries? (Sorry, been gone a while!) Link to comment Share on other sites More sharing options...
[dteviot] Posted August 26, 2008 Report Share Posted August 26, 2008 Sorry for delay in replying, but I usually don't monitor the UFO2000 threads.The function used in Xenocide to convert the mouse position to location on earth is WindowToGeoPosition() found in http://svn.projectxenocide.com/xenocide/xn...eoscapeScene.cs /// <summary> /// Convert a position in the viewport to a geoposition on the globe /// </summary> /// <param name="coords">The position in the viewport (in relative co-ords)</param> /// <returns>The geoposition or null if point isn't on globe</returns> /// <remarks>Uses equation from http://wikipedia.org/Ray-sphere_intersection.htm</remarks> public GeoPosition WindowToGeoPosition(PointF coords) { double lx = Math.Tan(ViewAngle / 2.0) * (coords.X - 0.5) * 2.0 * AspectRatio; double ly = Math.Tan(ViewAngle / 2.0) * (coords.Y - 0.5) * -2.0; double sz = CameraPosition.Z; double term = (sz * sz) - ((lx * lx) + (ly * ly) + 1) * ((sz * sz) - 1); // if term is negative, then postion isn't on the globe // we're also going to ignore the result when we're close to edge of globe // because it's difficult to hit a point accurately around there if (term < 0.1f) { return null; } // we're only interested in the near solution double d = (sz - Math.Sqrt(term)) / ((lx * lx) + (ly * ly) + 1); // convert back to get cartesian co-ordinates double x = lx * d; double y = ly * d; double z = sz - d; // convert to polar GeoPosition origin = new GeoPosition(0.0f, 0.0f); GeoPosition offset = new GeoPosition((float)Math.Atan(x / z), (float)Math.Asin(y)); // add in camera's displacement float distance = origin.Distance(offset); float azimuth = origin.GetAzimuth(offset); GeoPosition camera = new GeoPosition(CameraPosition.X, CameraPosition.Y); return camera.GetEndpoint(azimuth, distance); } Basic process is sending a ray through the screen based on the pixel selected, and computing the line/sphere intersection.http://en.wikipedia.org/wiki/Line%E2%80%93...re_intersectionNote, the math is simplified by modeling the earth as a sphere with a radius of 1, centered at 0, 0, 0, and the center of the camera is looking at 0, 0, 0. Link to comment Share on other sites More sharing options...
Raptor29 Posted September 6, 2008 Report Share Posted September 6, 2008 Sweet! It's been a long time since I have posted sorry about that Anyways it's good to hear that people are willing to help out with geoscape I for one feel it could use some work, but I am glad it is there. Anyways any help is appresiated Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now