To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > General Help > Games

Reply
 
Thread Tools Display Modes
Old 02-10-2009, 06:31 PM   #1
mr_malee
M.D.
 
mr_malee's Avatar
 
Join Date: Dec 2002
Location: Shelter
Posts: 4,058
Am I trying to do the impossible? (3d guru's apply)

http://soap.com.au/chris/rotateTest/v3/

keys to rotate the sphere.

What I'm trying to achieve is convert a 2D array of hexagons wrapped around a sphere.

here's the map:



I believe that this is impossible as spherical coordinates get squished at the poles. Guessing that If this was a cylinder it would work. I'm also guessing that the spacing between hexagons is different on the x/y axis because of this squishing.

Is there any way to resolve this? maybe a hexagons size can be changed to be smaller the closer it is to a pole? I'm not so sure how to go about doing that. Maths aint so good.

thanks for any help you guys can give me
__________________
lather yourself up with soap - soap arcade
mr_malee is offline   Reply With Quote
Old 02-10-2009, 07:56 PM   #2
renderhjs
Student
 
Join Date: Apr 2001
Location: -
Posts: 4,756
texture mapping is quite a strong interest of me (e.g my recent UV-scripts)

unwrapping spheres has always been kind of a paradox as it always comes with side effects see (sphere with cheker map and earth texture)
http://www.unwrap3d.com/tutorial_map.aspx
which are a better example.

but maybe you need a different shape? - from what I saw in the demo maybe something like this would work as well?

based on 2 circles of faces merged together in the 2nd model. Green shows the seams of the UV- map (where your texture stops and could produce a seam depending on your texture, less or not noteable ones are better). At the bottom is the UV- example of that 2nd model with way to much texture space waste. Just to give you more ideas


something else I found, for the math approach (not my turf)
http://tobias.preclik.de/codeblog/?p=9
renderhjs is offline   Reply With Quote
Old 02-10-2009, 09:08 PM   #3
Pazil
RevoGen Studio's
 
Pazil's Avatar
 
Join Date: Sep 2006
Location: Ontario, Canada
Posts: 788
I don't think that doing the hexagons ALL around the sphere is possible...

I'm not too sure at the moment about exactly how the geometry fits together, but you can make an IcoSphere with triangles, or maybe pentagons. Anything with a higher edge count is out of the question.

Or then again, you can texture map that onto a sphere, after (probably should check out that link render posted last) you run some calculations on the texture image to stretch out the 2 ends of it, so it texture maps perfectly, like they have those world maps stretched out at the top and bottom!

P.
__________________
WIP-OpenFL library

I love vegetarians! More meat for the rest of us!
Pazil is offline   Reply With Quote
Old 02-10-2009, 10:09 PM   #4
mr_malee
M.D.
 
mr_malee's Avatar
 
Join Date: Dec 2002
Location: Shelter
Posts: 4,058
thanks for the reply's. Render, I don't think I can use that method of shapes, the setup I have now is just a test scenario, imagine if a hexagon could appear anywhere on the sphere.

Basically what I'm doing right now is:

getting a 2D array of id's which represent the hexagons.
loop over the array, convert 2d array indexes to 2d hex coordinates
find the percentage of this coordinate in relation to a map size (px = hexX / (hexW * arrayW), py = hexY / (hexH * arrayH))
find the point on the sphere using this percent and the 2:1 ratio (sx = px * 360, sy = py * 180)
convert this angle to spherical coordinates
create hex polygon at this coordinate.

there is no texturing going on here. Hexagons are individual geometry in 3d space.

so yeah, unless somehow I can do hex to spherical to polar coordinates, or something like that, treating it like a texture map which has been creates for a sphere. Its not going to work.

on thew topic of spherical texturing, does anyone know how to take a flat image (like the one I posted) and move the pixels so the tops and bottoms are expanded and the middle is squished, so that it maps correctly around the sphere?

Thanks for the help.
__________________
lather yourself up with soap - soap arcade
mr_malee is offline   Reply With Quote
Old 02-10-2009, 10:32 PM   #5
rachil0
Senior Member
 
rachil0's Avatar
 
Join Date: Jul 2007
Location: Columbus, OH.
Posts: 465
I think euler's formula for polyhedra indicates it can't be done, at least not with a texture that's a regular tiling of hexagons (ie each vertex having valence 3).

For any genus G polyhedron you must have V-E+F=2-2G, where V is the number of vertices, E is the number of edges and F is the number of facets. The sphere (and any polyhedron homeomorphic to a sphere) has genus 0.

But if you consider the regular tiling of hexagons in 2D, if you have F hexagons then you have 6F/2 edges (each hex has 6 edges but we double counted them because each edge is shared among two hexes). Also, the number of vertices is 6*F/3, each hex has 6 vertices and each vertex is shared 3 ways. Plug these numbers into eulers formula:

V-E+F = 2-2G
6F/3-6F/2+F = 2-2G
2F-3F+F = 2-2G
0 = 2-2G
G= 1

So when you tile regular hexagons like that you can only make genus 1 shapes - a torus. You can envision this tiling by taking the texture and wrapping it up into a cylinder, then rolling that cylinder back onto itself. You won't be able to texture or facetize a sphere seamlessly with hexagons unless you have some nodes with valence!=3. (Vertices like that are called extraordinary points in subdivision surfaces - in the infinitesimal limit they have weaker curvature guarantees that the other spots on the surface).

// brain.explode();

Last edited by rachil0; 02-10-2009 at 10:35 PM.
rachil0 is offline   Reply With Quote
Old 02-10-2009, 11:06 PM   #6
mr_malee
M.D.
 
mr_malee's Avatar
 
Join Date: Dec 2002
Location: Shelter
Posts: 4,058
thankyou rachil I was gonna say the exact same thing

you have made my day.
__________________
lather yourself up with soap - soap arcade
mr_malee is offline   Reply With Quote
Old 02-10-2009, 11:59 PM   #7
abseeley
Adrian Seely
 
Join Date: Apr 2006
Posts: 28
Daag dont have anything productive to add, but im loving what people are making flash do these days, makes me want to bust out a 3d project!
abseeley is offline   Reply With Quote
Old 02-11-2009, 12:17 AM   #8
renderhjs
Student
 
Join Date: Apr 2001
Location: -
Posts: 4,756
I remember some demos from the flash 8 days when bitmapData and normal maps (displacement maps) were introduced showing some examples with a spherical displacement

it was not andre still he has a blog entry and demos as well:
http://blog.andre-michelle.com/2005/...mentmapfilter/

another something I found:
http://justin.everett-church.com/ind...es-on-spheres/

demo & code:
http://makc.coverthesky.com/FlashFX/ffx.php?id=8

in the end I could not find the article anymore (quite scientific but it used displacement and some higher math to do very accurate sphere mapping from a stretched texture in Flash)
renderhjs is offline   Reply With Quote
Old 02-11-2009, 12:32 AM   #9
justkevin
Member
 
Join Date: Jan 2009
Posts: 90
I think rachilo is right, you can't form a solid using just hexagons without gaps-- i.e., every hexagon touches exactly six others along each face.

You could do it with a mix of pentagons and hexagons, but that would probably cause more problems than it solved (I assume).
justkevin is offline   Reply With Quote
Old 02-11-2009, 02:06 AM   #10
ImprisonedPride
Pumpkin Carving 2008
 
ImprisonedPride's Avatar
 
Join Date: Apr 2006
Location: Grand Rapids MI
Posts: 2,280
I tried this already, and unfortunately for you, working in the 3d perspective makes it impossible. Faking it from a static 2d perspective is completely possible though.

http://board.flashkit.com/board/show...ht=grid+sphere

That probably doesn't help you now but there's some wisdom in that thread there.
__________________
ImprisonedPride is offline   Reply With Quote
Old 02-11-2009, 04:13 AM   #11
Sietjp
Senior Member
 
Sietjp's Avatar
 
Join Date: Jan 2005
Location: Paris, France
Posts: 696
Isn't it a similar problem ?


Maybe it would be possible to map the ball with hexagons if you use fake hexagons (6 sides but not perfectly symetric).
Sietjp is offline   Reply With Quote
Old 02-11-2009, 04:34 AM   #12
mr_malee
M.D.
 
mr_malee's Avatar
 
Join Date: Dec 2002
Location: Shelter
Posts: 4,058
yep, thats possible, but how do you get the hexagon coordinates like that?
__________________
lather yourself up with soap - soap arcade
mr_malee is offline   Reply With Quote
Old 02-11-2009, 08:18 AM   #13
yellowman
n00b
 
yellowman's Avatar
 
Join Date: May 2002
Location: Sweden
Posts: 163
Don´t know if it helps, but try googling for "truncated icosahedron". That´s the nerd-word for a soccer ball.
__________________
Personal: oos.moxiecode.com Work: www.northkingdom.com
yellowman is offline   Reply With Quote
Old 02-11-2009, 08:04 PM   #14
BlinkOk
ism
 
BlinkOk's Avatar
 
Join Date: Aug 2001
Location: , location, location
Posts: 4,970
Again, don't know if this helps but this texture maps to a soccer ball using spherical coordinates (i think there might be a bit of a seam though);
__________________
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
BlinkOk is online now   Reply With Quote
Old 02-11-2009, 09:11 PM   #15
Ray Beez
Senior Member
 
Ray Beez's Avatar
 
Join Date: Jun 2000
Posts: 2,741
Only the white sections of a soccer ball are hexagons. The black parts are pentagons.
;-)
Ray Beez is offline   Reply With Quote
Old 02-11-2009, 10:26 PM   #16
Pazil
RevoGen Studio's
 
Pazil's Avatar
 
Join Date: Sep 2006
Location: Ontario, Canada
Posts: 788
When I said you could texture map it on the sphere, I of course didn't mean that you would see no seems in it, but if you subdivide the triangles in the sphere enough, then that shouldn't matter too much. And of course, I got reminded by others just now about the Displacement Map Filter. I think that this will be your only alternative, but for rotation you'll have to work with moving the actual texture around in x/y's...

P.
__________________
WIP-OpenFL library

I love vegetarians! More meat for the rest of us!
Pazil is offline   Reply With Quote
Old 02-12-2009, 02:41 AM   #17
mr_malee
M.D.
 
mr_malee's Avatar
 
Join Date: Dec 2002
Location: Shelter
Posts: 4,058
well, thanks for all the help and replies. I convinced people that it wasn't possible and now I'm using a flat texture map, with hexagons placed roughly around the equator. With tweaking hex size, amount around the equator, spacing, the results looks good.

can't show you guys anything yet though, stay tuned

thanks again.
__________________
lather yourself up with soap - soap arcade
mr_malee is offline   Reply With Quote
Old 02-25-2009, 03:08 PM   #18
renderhjs
Student
 
Join Date: Apr 2001
Location: -
Posts: 4,756
I dug up today a nice page regarding this matter
http://www.maths.unsw.edu.au/school/articles/me100.html





but propably you already fixed it somehow
renderhjs is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > General Help > Games

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:19 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.