![]() |
| ||
| Convert mouse position to Texture position on ball Hi All, I am an experienced Java developer and since a few weeks I joined a project which involved real time rendering of 3D objects and interaction with those objects. I have a problem for which I hope that an experienced 3D programmer can help me. Usage:
If you are able to help or if you need more information please let me know because I am really stuck with this. Martijn Hermanns |
| ||
| Re: Convert mouse position to Texture position on ball Ok kiddo, what api are you using? JOGL or java 3d? How much of this have you read. Have you been through the tutorials? |
| ||
| Re: Convert mouse position to Texture position on ball I read a lot but haven't found a solution for my problem so far. Please instruct me if there are any tutorials which could meet my problem. The problem is that we have to rotate the ball and that is where I get lost. |
| ||
| Re: Convert mouse position to Texture position on ball Ok, first of all I'd use the JOGL api. It looks good. Then I'd work throught the NeHe tutorials. Fortunately, some kind soul has ported them to JOGL. Read this |
| ||
| Re: Convert mouse position to Texture position on ball 1 Attachment(s) Have a look at this as well. It's a basic java program that rotates a wireframe object in 3d space. All you have to do is provide the coordinates of the model. (Source code provided) Just make sure you unzip the file after downloading it. (Right -clicked the folder icon and select extract all) http://img136.imageshack.us/img136/5761/oirz8.th.gif |
| ||
| Re: Convert mouse position to Texture position on ball thank you for responding. We will have a look at the link you provided to and hope to find the answer to the solution. Unfortunately the weee.zip sample does solve our problem because it simply rotates a sphere when user the user drags the mouse. I really need to know "How can I convert the mouse position to the Texture position in order to update the ball surface?". |
| ||
| Re: Convert mouse position to Texture position on ball I think the best way to do this is to download the JOGL stuff and work with some of the tutorials. Then you can apply the texture mapping in a 3d environment. The mouse listeners should be no different to the ones you use for any other bog standard java application. It's just the texture gets updated straight away. Try it. |
| ||
| Re: Convert mouse position to Texture position on ball Maybe you misunderstand my problem. Converting coodinates after applying texture mapping is not the same as simply applying texture mapping. I see that Zaknixon got the same problem but couldn't find a proper feedback in JOGL forum. http://www.javagaming.org/forums/index.php?topic=1595.0 Can you please clarify? |
| ||
| Re: Convert mouse position to Texture position on ball 1 Attachment(s) If you were only using a circle, not a sphere, it's simple trigonometry; sphere is abit more difficult though, do you have to take rotation (of the sphere) into account? For a circle though; see attached image, and you must know: - The distance (D) from the viewing platform to the center of the object - The distance (Y) from the line Y=0 (relative the sphere AND viewing platform) to the point where the click is received from. - The radius (R) of the object. This won’t work directly with spheres, it assumes a cylindrical object lateral to the viewing platform, with a zoom factor of 1, and no transformations. The point you’ll get is X,Y,Z where (X,Y) are the clicked co-ordinate, and Z is the result of: t = asin(Y/R) B = cos(t) x R Z = D – B If the X and Y values are within a distance (the object’s size as centred around the line X = 0, Y = 0) from the point X = 0, Y = 0; then the point is on the surface of the object, at the point X,Y,Z relative to the viewing platform. To map that to a texture co-ordinate is different, it depends on your texturing system/method of creating the object; you can find the point relative to the object as opposed to relative to the viewing platform by subtracting the value of Z from the value of D, or taking the initial value of B. Taking that from a circle function to a sphere function could be simple, but could be difficult depending on the potential for/possibility of rotation, particularly if it's about arbitrary axes. Hope that helps; but definately try looking for third party packages/extensions that implement point picking; there may be some in Java3D already somewhere, look in the Java3D examples folder, I remember seeing some nice picking demos in there. Another solution (if texture point picking isn't implemented) is to put objects (which CAN be picked easily using the mouse) at every texture point, store reference to the texture point in that object, catch the pick with a behaviour and mutate or return the reference depending on what kind of app you're making. Matt |
| ||
| Re: Convert mouse position to Texture position on ball Hi Matt, Thank you for the detailed explanation. Assuming that the convert formula t = asin(Y/R) B = cos(t) x R Z = D – B is correct this would answer a part of the problem. This only converts from Canvas coordinates (x, y) to Virtual World coordinates (x, y, z). How about convert from Virtual World coordinates (x, y, z) to Spherical coordinates (rho, phi, theta) and to Texture coordinates (u, v). Do you have any idea on that? |
| All times are GMT -4. The time now is 11:37 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC