we are talking sphere primitive here
the median that goes down left to top right is the one you want.
you need the face thats shares the two vertexes of that side.

on this primitive you have 3 possible candidates 01, 12, 20
they are left, right, top or down of your face

eliminate first the one you don't need. the one that is up or down of your face. you know this because 2 of your uv's or vertexes are sharing same y or v value.

then because the sphere is builded in a rotating fashion, you eleminate the second one using the third vertex
not shared by checking the uv.u.

now the second tri.
same process, but reversed

there you go, you have the face you need if you now average the normals of the two faces shared vertexes. so if you now use only the third normal(not shared) + the two average normals you just found, it might give what you want.

you have to skip this code at poles, because they are builded as stars. so you could keep original code for these. Also if you check on u, and reach 1, you might need to correct check as well.

for the selection of the face you could also look at the angle between the face 01 and 12, if 90 you know witch one it is


I 'll send you a crate of beer
cheers! :))

Fabrice


On Feb 18, 2009, at 4:20 PM, spog wrote:


Cool! we wanna see!

I'll post the result as soon as I am happy with it ;)

Because you are registered here, you have almost unlimited questions
account!
In case you exceed this limit, we have a donate a beer btn to refill
your account :))

heheh, ok good. Watch out: here comes a couple of questions...
I'll send you a crate of beer, when I'm finished with the project :)


On top of my head I would say
Just do same calculation as now, but average neighbourg20 or 10
depending witch tri you render.

Ehmm... I'm afraid, I'm not sure if I get it...
Ok, I have those three normals in my code that are coming from the
neighbours, right?

norm1.rotate( tri.faceVO.face.parent.neighbour01
( tri.faceVO.face ).normal, t );
norm2.rotate( tri.faceVO.face.parent.neighbour12
( tri.faceVO.face ).normal, t );
norm3.rotate( tri.faceVO.face.parent.neighbour20
( tri.faceVO.face ).normal, t );

Now I should average neighbour20 or neighbour01, depending on the tri?
But avarege of what? And how do I know which tri is renderd?

You render a bit like a quad face. You just have to test equal value
for the average 2 normals at vertexes at the shared side.

I have no clue how to get the "value for the average 2 normals at
vertexes at the same side"...
That's a bit to geek for me ;)

Could you explain that to me a bit more detailed? That would be great!

The function still looks like that:

override public function renderTriangle(tri : DrawTriangle) : void {
                        _session = tri.source.session;

                        function nscreen(_v0 : ScreenVertex, _v1 : 
ScreenVertex, _v2 :
ScreenVertex) : Number3D {
                                var d1x : Number = _v1.x - _v0.x;
                                var d1y : Number = _v1.y - _v0.y;
                                var d1z : Number = _v1.z - _v0.z;

                                var d2x : Number = _v2.x - _v0.x;
                                var d2y : Number = _v2.y - _v0.y;
                                var d2z : Number = _v2.z - _v0.z;

                                var pa : Number = d1y * d2z - d1z * d2y;
                                var pb : Number = d1z * d2x - d1x * d2z;
                                var pc : Number = d1x * d2y - d1y * d2x;

                                var pdd : Number = Math.sqrt( pa * pa + pb * pb 
+ pc * pc );
                                return new Number3D( pa / pdd, pb / pdd, pc / 
pdd );
                        }

                        var t : away3d.core.math.Matrix3D =
tri.view.cameraVarsStore.viewTransformDictionary[tri.source];

                        norm1.rotate( tri.faceVO.face.parent.neighbour01
( tri.faceVO.face ).normal, t );
                        norm2.rotate( tri.faceVO.face.parent.neighbour12
( tri.faceVO.face ).normal, t );
                        norm3.rotate( tri.faceVO.face.parent.neighbour20
( tri.faceVO.face ).normal, t );

                        _nn = nscreen( tri.v0, tri.v1, tri.v2 );
                        _nn.normalize( 1 );
                        _nn.rotate(tri.faceVO.face.normal, t);

                        eTri0.x = width * (     ( ( (_nn.x + norm1.x) * ox) * 
oy)       + off   );
                        eTri0.y = height* ( ( ( (_nn.y + norm1.y) * ox) * oy)   
+ off   );
                        eTri1.x = width * (     ( ( (_nn.x + norm2.x) * ox) * 
oy)       + off   );
                        eTri1.y = height* ( ( ( (_nn.y + norm2.y) * ox) * oy)   
+ off   );
                        eTri2.x = width * (     ( ( (_nn.x + norm3.x) * ox) * 
oy)       + off   );
                        eTri2.y = height* ( ( ( (_nn.y + norm3.y) * ox) * oy)   
+ off   );

                        var mat : Matrix = new Matrix( eTri1.x - eTri0.x, 
eTri1.y -
eTri0.y, eTri2.x - eTri0.x, eTri2.y - eTri0.y, eTri0.x, eTri0.y );
                        mat.invert( );

                        _session.renderTriangleBitmap( bitmap, mat, tri.v0, 
tri.v1, tri.v2,
smooth, false, _session.graphics );
                }

New hints are greatly appreciated!
cheers,
Spog







Reply via email to