nysos Calculating status...

Hi floks, i have strange problem.

I'm trying to make a sphere of vertices but it seems to work partly right now http://audionysos.cba.pl/Test.html

As you can see, only the north and part of south america is visible.

I'm sure that vertices are in appriopriate positions and indices are set correctly. I was trace it and even wrote on paper with low complexity - everything is all right. Buffers also seems to be set correctly.

It's calculated in this way(I don't know if this is the best solution for that but it's one that came to my mind):

I'm making grid modeled on geographical latitude and longitude.

To begin with, i set two first vertices, which will be common for all longitude, starting from bottom, so it looks like this:

Kod :

vertices.push(0, -1, 0, 0.5, 1, 0, 1, 0, 0.5, 0);

For every longitude, I'm creating count of vertices corresponding to the quanity of latitudes, so i do this loop:

Kod :

for (var j:uint = 0; j < longsCount; ++j) {

for (var k:uint = 1; k <= latsCount; ++k) {

}

}

In the loop above i'm calculateing vertices positions on Y axis from formula below:

Kod :

var xy:Point = Point.polar(1, ((angStep * k-90) * Math.PI / 180));

So position of vertex on this axis will be, depends on angle, xy.y

Value of angle between consecutive vertices(angStep) is calculated like this:

Kod :

var angStep:Number = 180 / (latsCount+1);

Position on X and Z axis is calculated in similar way

Kod :

var xz:Point = Point.polar(xy.x, ((longAStep * j-90) * Math.PI / 180));

Except that for the vector length in "polar" function I'm passing previously calculeted x value form X-Y surface.

...longAStep = 360 / longsCount;

Finally I'm pushing values into vertices array.

Kod :

vertices.push(xz.x, xy.y, xz.y, textXStep*j, 1-textYStep*k);

Last two values are of course uv

So, complete function which sets verices positions looks like this:

Kod :

private function createVerts():void {

var angStep:Number = 180 / (latsCount+1);

var longAStep:Number = 360 / longsCount;

var textXStep:Number = 1 / longsCount;

var textYStep:Number = 1 / latsCount;

vertices.push(0, -1, 0, 0.5, 1, 0, 1, 0, 0.5, 0);

for (var j:uint = 0; j < longsCount; ++j) {

for (var k:uint = 1; k <= latsCount; ++k) {

var xy:Point = Point.polar(1, ((angStep * k-90) * Math.PI / 180));

var xz:Point = Point.polar(xy.x, ((longAStep * j-90) * Math.PI / 180));

vertices.push(xz.x, xy.y, xz.y, textXStep*j, 1-textYStep*k);

}

}

}

And setting indices, which is just moving it along:

Kod :

private function createInds():void {

for (var j:uint = 0; j < longsCount; ++j) {

var f:uint; var s:uint;

var t:uint;

for (var k:uint = 0; k < latsCount +1; ++k) {

if (k == 0) {

f = 0;

s = 2 + j * latsCount;

if (j != longsCount -1) t = s + latsCount;

else t = 2;

indices.push(f, s, t);

}else if (k == latsCount){

f = s;

s = t;

t = 1;

indices.push(f, s, t);

}else{

f = s;

s = t;

t = f + 1;

indices.push(f, s, t);

f = s; s = t;

if (j != longsCount -1) t = f + 1;

else t -= latsCount * (longsCount -1);

indices.push(f, s, t);

}

}

}

}

Rest of the code is just standard stage3d settings.

Kod :

vertBuff = con3D.createVertexBuffer(s.vertsCount, 5);

vertBuff.uploadFromVector(s.vertices, 0, s.vertsCount);

indBuff = con3D.createIndexBuffer(s.indsCount);

indBuff.uploadFromVector(s.indices, 0, s.indsCount);

s - my sphere object.

vertsCount = latsCount * longsCount + 2;

indsCount = latsCount * longsCount * 2;

and just as in tutorials at http://www.adobe.com/devnet/flashplayer/stage3d.html...

The big question is what i missed? I have no idea what is wrong. Why part of sphere can be visible and rest of it can't?

I regred that there is not much documentation of it. I spent much time searching web and found nothing. :/

I'm totally stuck rigth now so i'll be very happy when someone would help me just a little.

You can download full project here http://speedy.sh/mqQst/New-Project.rar

Thanks for attention!

1044 Views
0 Replies

Actions

- Retrieving data ...

Adobe Community powered by Jive SBS ® 4.5.6.3 forum software

Jive Software Version: 154630

© Jive Software

Help
Terms of Use
Privacy Policy and Cookies (UPDATED)
© 2013 Adobe Systems Incorporated. All Rights Reserved.