| | |
Convert mouse position to Texture position on ball
Please support our Game Development advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
it actually only converts a Y to a Z (2D), the value of Z also has to be in terms of the X to be a sphere; to convert them to a spherical system, rho will equal Z, phi will equal Y, and theta will be in terms of Z and X, the sphere co-ordinates and/or mapping to UV depend on the rotation, translation and scale of the sphere at any moment in time.
EDIT: no, rho will equal (distance from sphere to viewing platform) - Z, and phi will equal the distance from the Y origin of the viewing platform to the Y co-ordinate (as clicked on the Canvas)
do you have the java3d demos? look for ..\jdkx.x\j3d\demo\index.html and check out, PickTest and IntersectTest. These methods work by flagging collisions as the graphics are rendering as opposed to calculation positions from current transform3d objects.
Intersect test is quite good, shows picking of points rather than objects.
EDIT: no, rho will equal (distance from sphere to viewing platform) - Z, and phi will equal the distance from the Y origin of the viewing platform to the Y co-ordinate (as clicked on the Canvas)
do you have the java3d demos? look for ..\jdkx.x\j3d\demo\index.html and check out, PickTest and IntersectTest. These methods work by flagging collisions as the graphics are rendering as opposed to calculation positions from current transform3d objects.
Intersect test is quite good, shows picking of points rather than objects.
Last edited by MattEvans; Jul 23rd, 2006 at 11:27 am.
Plato forgot the nullahedron..
•
•
Join Date: Jul 2006
Posts: 9
Reputation:
Solved Threads: 0
Hi Matt,
Thanks again. We will try to implement the OpenGL document in Java3D.
Assuming that there are no rotation (dx=0; dy=0; dz=0), no translation (dx=0; dy=0; dz=0), no scale (=1.0) at that time, could you please provide the formula for computing U,V?
Terms
See the document: http://www.opengl.org/resources/code...s/node177.html
(This document is written for OpenGL sp it may be easier to implement in JOGL however we prefer Java3D because Java3D code could work in OpenGL and DirectX, meanwhile JOGL code doesn't work in DirectX)
Some terms I don't understand:
1. "The vector from the eye point to the vertex". How to get this in Java3D?
2. "The modelview matrix". How to get this in Java3D?
As always you feedback is much appreciated.
Thanks again. We will try to implement the OpenGL document in Java3D.
Assuming that there are no rotation (dx=0; dy=0; dz=0), no translation (dx=0; dy=0; dz=0), no scale (=1.0) at that time, could you please provide the formula for computing U,V?
Terms
See the document: http://www.opengl.org/resources/code...s/node177.html
(This document is written for OpenGL sp it may be easier to implement in JOGL however we prefer Java3D because Java3D code could work in OpenGL and DirectX, meanwhile JOGL code doesn't work in DirectX)
Some terms I don't understand:
1. "The vector from the eye point to the vertex". How to get this in Java3D?
2. "The modelview matrix". How to get this in Java3D?
As always you feedback is much appreciated.
I've attached a new image showing how to get rho,phi and theta values on a sphere; bear in mind these equations have only been tested mentally, so look carefully at the proofings. You may find that some of the axes are expressed upside down, that's a common mistake I make.
You'll notice that there's no longer a Z (distance from viewplatform (eye) to the surface of the circle) in terms of the Y and Z (that is; origin-to-origin displacement Z). It's no longer calculatable by those terms as it was before because the theta value (well, third dimension) affects that distance.
Once you have these; converting them to UV is dependant on your system of mapping UV co-ordinates to rho, phi and theta values. I'm assuming that you derive the UV co-ordinates from rho, phi and theta values, and in that case it'll be easy. I can't tell you how; because UV isn't finite/has no referenceable standard that I know of.
On your sphere, the vector from the eye point to the matrix is the vector from the origin of the camera/viewplatform to a vertex on a shere as it would be if it were a point in global space (so after rotation, scale etc), bear in mind the vertexes location is not the UV co-ordinate.
The modelview matrix is a mixture of the transform matrix * of a model and the transform matrix of the viewplatform/camera/eye. If the object is never moved but the eye is moved, the modelview matrix is the transform matrix of the eye; and if the object is moved and the eye is never moved, it's the INVERTED transform matrix of the object. If both are moved; it's the composite of the camera transform matrix and the inverted model transform matrix. There may be some kind of combine in the Transform3D class, I've never used it, I usually do all parts of 3D transforms separately and build Transform3D's ad-hoc.
* Call getTransform() of a TransformGroup object to access it, but if you're scenegraph/locale is compiled, you'll need to set the ALLOW_TRANSFORM_READ (and probably ALLOW_TRANSFORM_WRITE) capabilities of the transformgroup/object in question.
Looking at the class functions in JBuilder, it'd probably be:
I think I've earnt the right to tactlessly promote my own forum, so check it out: http://www.fusiongroupuk.com. I will post some topics/tutorials about 3D and Java3D there sometime. There'll definately be 3D programs, and maybe some textures and models if I can enlist my lil brother's help
there's not much now though, but check out the demos in the ElementSystem board. It makes me proud :mrgreen:
Good luck, let me know if you have any trouble (especially if you get the equations in and they do something unexpected).
Matt
You'll notice that there's no longer a Z (distance from viewplatform (eye) to the surface of the circle) in terms of the Y and Z (that is; origin-to-origin displacement Z). It's no longer calculatable by those terms as it was before because the theta value (well, third dimension) affects that distance.
Once you have these; converting them to UV is dependant on your system of mapping UV co-ordinates to rho, phi and theta values. I'm assuming that you derive the UV co-ordinates from rho, phi and theta values, and in that case it'll be easy. I can't tell you how; because UV isn't finite/has no referenceable standard that I know of.
On your sphere, the vector from the eye point to the matrix is the vector from the origin of the camera/viewplatform to a vertex on a shere as it would be if it were a point in global space (so after rotation, scale etc), bear in mind the vertexes location is not the UV co-ordinate.
The modelview matrix is a mixture of the transform matrix * of a model and the transform matrix of the viewplatform/camera/eye. If the object is never moved but the eye is moved, the modelview matrix is the transform matrix of the eye; and if the object is moved and the eye is never moved, it's the INVERTED transform matrix of the object. If both are moved; it's the composite of the camera transform matrix and the inverted model transform matrix. There may be some kind of combine in the Transform3D class, I've never used it, I usually do all parts of 3D transforms separately and build Transform3D's ad-hoc.
* Call getTransform() of a TransformGroup object to access it, but if you're scenegraph/locale is compiled, you'll need to set the ALLOW_TRANSFORM_READ (and probably ALLOW_TRANSFORM_WRITE) capabilities of the transformgroup/object in question.
Looking at the class functions in JBuilder, it'd probably be:
Transform3D modelMatrix = new Transform3D(); model.getTransform(modelMatrix); modelMatrix.invert(); Transform3D viewMatrix = new Transform3D(); view.getTransform(viewMatrix); Transform3D modelViewMatrix = new Transform3D(viewMatrix); modelViewMatrix.add(modelMatrix);
I think I've earnt the right to tactlessly promote my own forum, so check it out: http://www.fusiongroupuk.com. I will post some topics/tutorials about 3D and Java3D there sometime. There'll definately be 3D programs, and maybe some textures and models if I can enlist my lil brother's help
there's not much now though, but check out the demos in the ElementSystem board. It makes me proud :mrgreen: Good luck, let me know if you have any trouble (especially if you get the equations in and they do something unexpected).
Matt
Last edited by MattEvans; Jul 24th, 2006 at 8:02 am.
Plato forgot the nullahedron..
there's at least one mistake in the diagram; the line labeled "rho" is actually not rho; you need to calculate the length of that line to work out phi, so rename the line rho on the diagram to the line B.
rho now is equal to the "radius" and is constant for all values that fall on the sphere's surface.
rho now is equal to the "radius" and is constant for all values that fall on the sphere's surface.
Last edited by MattEvans; Jul 24th, 2006 at 9:32 pm. Reason: greek
Plato forgot the nullahedron..
•
•
Join Date: Jul 2006
Posts: 9
Reputation:
Solved Threads: 0
Hi Matt,
I am terrible sorry that I didn't reply earlier. Indeed you have well earnt the right to tactlessly promote your forum.
Your feedback is a great help. We are now working based on the information you provided and will let you know how we get on with it.
Thanks again,
Martijn
I am terrible sorry that I didn't reply earlier. Indeed you have well earnt the right to tactlessly promote your forum.
Your feedback is a great help. We are now working based on the information you provided and will let you know how we get on with it.
Thanks again,
Martijn
Last edited by 3DStarter; Jul 27th, 2006 at 8:40 am.
![]() |
Other Threads in the Game Development Forum
- Previous Thread: rectangle in vb
- Next Thread: 7.1 volume control
Views: 7779 | Replies: 16
| Thread Tools | Search this Thread |
Tag cloud for Game Development
3d advertising ai algorithm ban c++ cambridge camera censorship china competition console development engine fov fpx game gamedevelopment gameprogramming gamer games gaming gauntanamo government graphics idaho in-gameadvertisement intel intellectualproperty l-systems laracroft larrabee lindenmayer live manhunt math mathematics matrix mercenaries microsoft mmorpg modded msn multicore naked news nintendo obama opengl palin physics pirate playstation politics processor projection ps3 rpg search selection software sony stephenhawking stocks studio technology terrorism tombraider uk videogame web wii world-of-warcraft xbox xbox-live xbox360






