Zooming textures

Software: Away3D 4.x

Pokey, Newbie
Posted: 13 May 2013 06:07 PM   Total Posts: 23

Hello,

I am very new to Away3D, so I ask your patience with my ignorance.

First I would like to say that I am very impressed by the Away3D project and I am extremely grateful to all the contributors.

I am trying to make a globe that supports extensive zooming. The approach I have used in a simple 2D version of my project is to split the image into multiple tiles (3600 in this case) and then use JavaScript to load (swap out the image url) higher resolution jpegs for the tiles that are visible and load low res jpegs for the tiles that are not visible (to save memory).

The further in the user zooms, the fewer tiles are visible but are in higher resolution. When the user zooms out, more tiles are visible but loaded with lower resolution.

Is there a way to do something similar with a sphere in Away3D?

Thanks in advance for your patience and help!

   

Avatar
Fabrice Closier, Administrator
Posted: 13 May 2013 07:10 PM   Total Posts: 1265   [ # 1 ]

yes, tho you need only 2 maps. not 3600.
one is the globe map, call it low res. Once you have your coordinates, you move camera to there and simply load the tile that you need. Make then a temp material with your highres material. At this point you can descide if you preffer to have a geometry already mapped slightly above the earth surface , redefined the earth uv map (and reset on zoom out) or composite the material texture bitmapdata itself. You could even project the loaded map onto the earth.

   

Pokey, Newbie
Posted: 14 May 2013 06:02 AM   Total Posts: 23   [ # 2 ]

Thank you Fabrice! That is very helpful. Is it possible to load multiple jpegs (tiles) to the same geometry using UV coordinates to position them?

I am thinking that I could divide the globe into maybe 8 sections and swap out the section textures depending on the zoom.

(If this works out I will write a tutorial for this as I am sure others could benefit from it.)

   

Avatar
Fabrice Closier, Administrator
Posted: 14 May 2013 10:44 AM   Total Posts: 1265   [ # 3 ]

Yes its possible, yet doing this way, forces you to keep track of what is visible in viewport and possibly load more maps (for instance 4 maps if the zoom target location is near the point where 4 section of your hemisphere meet)
While offseting and multiplying the uv’s is way more easy, non destructive and allowing you to zoom closer to the surface where zoom limitation would be the detailing/res of the server maps.

   

Pokey, Newbie
Posted: 14 May 2013 10:06 PM   Total Posts: 23   [ # 4 ]

Thank you again!

If I am understanding you correctly, the UV manipulation could be tied to the camera and object movement thereby eliminating the need for visibility detection.

That sounds really exciting and promising.

However, I am embarrassed to say I have no idea how to manipulate UVs. Where can I go to learn more about UVs in Away3D?

   

Pokey, Newbie
Posted: 15 May 2013 05:55 PM   Total Posts: 23   [ # 5 ]

I have been browsing through the API reference and between the arcane code there and wild guessing I have figured out how to scale UVs with the following code:

_earth1.geometry.scaleUV(1,.9); 

where _earth1 is a mesh of a sphere.

I cannot figure out how to offset UVs though. I would be grateful for any clues!

   

Pokey, Newbie
Posted: 17 May 2013 05:07 AM   Total Posts: 23   [ # 6 ]

After more searching and head scratching I think I have made some progress. I am using

public var _earthUVs:Vector.<Number>;
...
_earthUVs _earth1.geometry.subGeometries[0].UVData;
...
trace(_earthUVs); 

I am getting about 100 pages of the following:

0,100,0,0,1,0,1,0,0,0,0,0,0,0,100,0,0,1,0,1,0,0,0.005,0,0,0,0,100,0,0,1,0,1,0,0,0.01,0,0,0,0,100,0,0,1,0,1,0,0,0.015,0,0,0,0,100,0,0,1,0,1,0,0,0.02,0,0,0,0,100,0,0,1,0,1,0,0,0.025,0,0,0,0,100,0,0,1,0,1,0,0,0.03,0,0,0,0,100,0,0,1,0,1,0,0,0.035,0,0,0,0,100,0,0,1,0,1,0,0,0.04,0,0,0,0,100,0,0,1,0,1,0,0,0.045,0,0,0,0,100,0,0,1,0,1,0,0,0.05,0,0,0,0,100,0,0,1,0,1,0,0,0.055,0,0,0,0,100,0,0,1,0,1,0,0,0.06,0,0,0,0,100,0,0,1,0,1,0,0,0.065,0,0,0,0,100,0,0,1,0,1,0,0,0.07,0,0,0,0,100,0,0,1,0,1,0,0,0.075,0,0,0,0,100,0,0,1,0,1,0,0,0.08,0,0,0,0,100,0,0,1,0,1,0,0,0.085,0,0,0,0,100,0,0,1,0,1,0,0,0.09,0,0,0,0,100,0,0,1,0,1,0,0,0.095,0,0,0,0,100,0,0,1,0,1,0,0,0.1,0,0,0,0,100,0,0,1,0,1,0,0,0.105,0,0,0,0,100,0,0,1,0,1,0,0,0.11,0,0,0,0,100,0,0,1,0,1,0,0,0.115,0,0,0,0,100,0,0,1,0,1,0,0,0.12,0,0,0,0,100,0,0,1,0,1,0,0,0.125,0,0,0,0,100,0,0,1,0,1,0,0,0.13,0,0,0,0,100,0,0,1,0,1,0,0,0.135,0,0,0,0,100,0,0,1,0,1,0,0,0.14,0,0,0,0,100,0,0,1,0,1,0,0,0.145,0,0,0,0,100,0,0,1,0,1,0,0,0.15,0,0,0,0,100,0,0,1,0,1,0,0,0.155,0,0,0,0,100,0,0,1,0,1,0,0,0.16,0,0,0,0,100,0,0,1,0,1,0,0,0.165,0,0,0,0,100,0,0,1,0,1,0,0,0.17,0,0,0,0,100,0,0,1,0,1,0,0,0.175,0,0,0,0,100,0,0,1,0,1,0,0,0.18,0,0,0,0,100,0,0,1,0,1,0,0,0.185,0,0,0,0,100,0,0,1,0,1,0,0,0.19,0,0,0,0,100,0,0,1,0,1,0,0,0.195,0,0,0,0,100,0,0,1,0,1,0,0,0.2,0,0,0,0,100,0,0,1,0,1,0,0,0.205,0,0,0,0,100,0,0,1,0,1,0,0,0.21,0,0,0,0,100,0,0,1,0,1,0,0,0.215,0,0,0,0,100,0,0,1,0,1,0,0,0.22,0,0,0,0,100,0,0,1,0,1,0,0,0.225,0,0,0,0,100,0,0,1,0,1,0,0,0.23,0,0,0,0,100,0,0,1,0,1,0,0,0.235,0,0,0,0,100

Does anyone know what all of these numbers mean?

TIA

   

Avatar
Fabrice Closier, Administrator
Posted: 17 May 2013 08:49 AM   Total Posts: 1265   [ # 7 ]

These are uv’s. they represent 2 coordinates, u and v. The equivallent of x and y coordinates of your map, but expressed in values 0 to 1. Each 2 are coupled to the x,y,z values of a given vertice. so you have 6 uv numbers per face. They are expressed in 0 to 1 values, because if they would be defined according to a specific bitmap coordinates they would fit only this specific map dimension. Instead, to stay generic, each value is internally multiplied by the texture map width and height. Say you would have a 256x256 map, 0 u would be the left side 0 (0 x 256), .5 would become the middle (.5 x 256) 128 and 1, (1 x 256) 256. In some cases values may exceed or be smaller than 0 or 1. In this case, you need to set the repeat property to true, to prevent rendering artefacts. In case of your globe, if you would place a massive map, yet located at lon/lat, to prevent it to be spreaded over the entire sphere, you will need to multiply these 0-1 values to a smaller than 1 scale, because they would by the rule stick to left side, an offset left and right will be required as well.

I suggest you play around a bit with these concepts before you take any technical descisions for your project as its success is directly linked to them.

   

Pokey, Newbie
Posted: 18 May 2013 01:15 PM   Total Posts: 23   [ # 8 ]

I will spend some time playing with these numbers. I am hopeful that this approach will work nicely once I figure out the algorithm.

Thank you again Fabrice.

   

Dlate, Newbie
Posted: 21 May 2013 08:25 AM   Total Posts: 21   [ # 9 ]

Any updates on this topic? What is the solution?

   

Pokey, Newbie
Posted: 21 May 2013 05:08 PM   Total Posts: 23   [ # 10 ]

Well, I am still trying to figure out how to manipulate the UV data, what particular methods to use, etc. (The API reference is very scanty in the way of descriptions…)

At this rate it will probably take me several months, but if I ever do figure this out, I will definitely post about it.

...sorry I can’t be of more help.

   

Dlate, Newbie
Posted: 22 May 2013 07:07 AM   Total Posts: 21   [ # 11 ]

Thanks for the response.

Ive tried several approaches for the sphere. Closest i have gotten is “tiling” the sphere, making meshes out of the faces. And giving each mesh a material. Problem is that the uv coordinates need to be set per face.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X