Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Returning UV coordinates on a rotating sphere

Author
Message
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 24th Nov 2012 17:10 Edited at: 24th Nov 2012 17:13
I'm trying to use the images width and height from the texture on the object - using the object's size to attain the scaling factor and multiply that by the pick locations to attain where in 2d the mouse has clicked on the object's texture... but sphere's are tricky and I can't for the life of me get it to run.

I should also mention that the sphere is rotating as well as orbiting around another object

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 24th Nov 2012 20:22
argh, I wrote a nice post, but long story short...

Post this data,
Quote: "
I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
"


I was going to post about Ray Casting, but then I re-read your post... ^^

I find this topic interesting, so I shall keep posted here and if anything sprouts to mind, shall post, hope somebody has the answer to this

Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 24th Nov 2012 21:03
Here's a link to an example program written by TheComet which allows you to draw on a couple of objects, so essentially solving your problem. It works with Sparky collision.

https://forumfiles.thegamecreators.com/download/2360518

I asked the same sort of question in this thread ...

http://forum.thegamecreators.com/?m=forum_view&t=197498&b=1

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 24th Nov 2012 21:14
Though just note that that example is buggy. I'm gonna have a play and see what I can come up with by working out the barycentric coordinates like I did for quads.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 25th Nov 2012 07:59
Okay well let me first say that I just need to report the location of the 2d mouse on an objects texture. Here's a short why.

I have a sun and planet. The planet is rotating on it's axis and around the sun. It has a planet texture on it. The image of the texture was entered into a memblock, where the colors were analized and a dot product (0.0 to 1.0) was returned... this equaled the Reflective-Absorptive of the surface.

Now using the cursor I need to relay the information at the present picture into another loop that edits the image's extra values of temp, pressure, humidity and color. This information is run through a few functions and will simulate weather... in order to both read the info pulled by the 2d mouse and inflict changes to data - i need to simply report the XY position of the cursor relative to the object's texture. I have everything else

@ Mr. Feb 14th - I understand raycasting and use it often - particularly like in my plane grid for custom large terrains. But sphere's to circles are easier than spheres to square/box textures... like from plotting a three object to making a Very large array... mini black hole kind... oi my head.



I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 25th Nov 2012 12:31


TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Nov 2012 18:05
The reason why the example is buggy is because of the way the coordinates are transformed to the 2D texture. If the surface is at an exact 90° angle, the function returns false information because it's trying to divide by 0.

The demo in the links posted by Fallout will solve your problem.

Alternately, you could also use the 3D coordinates from the pick object command and mathematically determine the coordinates rather than relying on the UV data of the object (as in my example).

TheComet

Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 25th Nov 2012 19:33
Well here is the issue with the pick commands.

On a stationary plane, you can divide the object size x and z and then multiply that factor by the pick commands to give you the position in 2d of the objects texture... But you have to update the scaleXZ# to pickXZ#... like if you have say four planes each with the same image textured on them next to each other - and want to call the same position on the image over each object, pick xz and scale xz have to be adjusted...

The same, so I've gathered is true with an orbiting rotating sphere.

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Nov 2012 11:07 Edited at: 26th Nov 2012 11:09
Try this:



TheComet

Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 26th Nov 2012 20:49
Okay - this is remarkably close - but I am simulating real weather - which only occurs if the planet rotates on two or more axis' - the earth rotates around the sun, but because of it's 15 degree angled wobble - we have seasons. If I wasn't interpreting data in such away that it didn't rely on that wobble, I would take this and use it off the bat like a good code stealer - but instead I will see if I can adapt something from this to a multi-axis' wobble.

The point being - there are several factors that directly go into why the weather is the way it is - and they all rely on the sun. these are

Pressure, which influences:
Gas density (constant value depending on oxy, nitro, and so forth)
Temp
humidity
cloud formation and dissolving

THESE values create variances in the weather itself. But beyond these values, the angle of the planet's wobble directly correlates to the type of Weather. A planet with no wobble would experience minor changes - aka, it's always sunny in Philadelphia... But shift that axis to 5 - 15 degrees from the center and someone in Texas is losing a trailer - and not through a divorce.

This axis type, along with the velocity of the spin of the planet, and the values above will conduct the weather. It is a VERY COMPLEX calculation, but buy orchestrating values that can influence other values I have eliminated 95% of the math and have only the calculation of a sphere's UV data to 3d coordinates stopping me... how 'astronomically' funny.

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 26th Nov 2012 20:56
Actually and forgive the double post - think I have it... What I need to do is convert the pick vector/3d locations into object space from the sphere - then using the same scaling factor you would to obtain the x,y of a texture on a plane, I could obtain the texture position regardless of the location, angle or etc - now, how do I convert the pick X, Y, Z, locations into positions in object space?

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Nov 2012 21:00
My code pretty much does that, you just have to rotate the pick coordinates back to their point of origin. I'll see if I can get it working for X rotations as well.

TheComet

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Nov 2012 21:39 Edited at: 26th Nov 2012 21:40
Here it is, X,Y,Z rotations are supported.



TheComet

Login to post a reply

Server time is: 2026-07-08 07:04:52
Your offset time is: 2026-07-08 07:04:52