•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Game Development section within the Software Development category of DaniWeb, a massive community of 391,549 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,543 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Game Development advertiser:
Views: 5932 | Replies: 16 | Solved
![]() |
•
•
Join Date: Jul 2006
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
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
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:
- I’ve rendered an 3D Sphere object which in this case is a perfect ball (not eggs shape) using Spherical Texture mapping.
- The idea is that a user can interact with this ball and rotate the ball. The user clicks a location on the ball and the user is to enter a ‘dot’ on the ball. Thereafter the user can rotate the ball and place other dots on the ball.
- When a user clicks the surface of the ball our application is able to get the mouse position (x, y) in Canvas2D.
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
Last edited by 3DStarter : Jul 20th, 2006 at 12:10 pm.
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
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
Member of: F-ugly code club
Join today don't delay!
Join today don't delay!
•
•
Join Date: Jul 2006
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
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?".
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?".
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.
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.
Member of: F-ugly code club
Join today don't delay!
Join today don't delay!
•
•
Join Date: Jul 2006
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
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?
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?
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 936
Reputation:
Rep Power: 5
Solved Threads: 47
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
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
•
•
Join Date: Jul 2006
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
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?
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?
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Game Development Marketplace
•
•
•
•
activex advertising ajax asp blog blogging browser business code console development firefox game games google hardware html innovation intel internet linux marketing microsoft mozilla news nintendo os playstation programming ps3 revenue rss search security software sony stocks video video game vista w3c web web development wii wiki windows xbox 360 xml xp yahoo
- Previous Thread: rectangle in vb
- Next Thread: 7.1 volume control



Linear Mode