This is G o o g l e's cache of http://www.flashsandy.org/forum/lofiversion/index.php/t398.html as retrieved on 10 Aug 2007 04:49:59 GMT.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
This cached page may reference images which are no longer available. Click here for the cached text only.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:sMG1e8mXi3kJ:www.flashsandy.org/forum/lofiversion/index.php/t398.html+site:www.flashsandy.org/forum&hl=en&ct=clnk&cd=35


Google is neither affiliated with the authors of this page nor responsible for its content.

Full Version: Camera Rotation
kosmo
Hello Every one! First of all I want to say that sandy... rules, I m really surprised how good it is! Great Job!

For my first project I want to create 3d menu with sprites as buttons.

http://www.soulsurfer.pl/menu.html

For this I have create the object... ect. To move camera around I m using this function:


CODE
function camRotate(){
    if (this.pad_mc.hitTest(_root._xmouse , _root._ymouse, true)) {
        // do what you want it to do when the mouse rolls over
        running = true;
    } else {
        // do what you want in to do when the mouse rolls out
        running = false;
    }
    if( running ){ // Move only if running == true
        pozx = pozx - p*(_xmouse-Stage.width/2)/120;
        pozy = pozy - p*(_ymouse-Stage.height/2)/80;
    }else{
          pozx = pozx - p*(_xmouse-Stage.width/2)/2000;
        pozy = pozy - p*(_ymouse-Stage.height/2)/1000;
    }
        
    var _rad:Number = 500;
    var phi = pozx * (Math.PI / 180);
    var theta = pozy * (Math.PI / 180);
    var y = p * _rad * Math.sin(theta);            
    var z = _rad * Math.cos(theta) * Math.cos(phi);
    var x = p * _rad * Math.cos(theta) * Math.sin(phi);
    
    if( ok and ((y >= 499) or (y <= -499))){
        //replace button positions
        p = p*-1;
        op = 0;
        ok = false;
        
        var tempTrans = vZ1;
        vZ1 = vZ2;
        vZ2 = tempTrans;
        
        var tempTrans = vZ6;
        vZ6 = vZ4;
        vZ4 = tempTrans;
        
        var tempTrans = vZ5;
        vZ5 = vZ3
        vZ3 = tempTrans;
        
        trans1.translateVector(vZ1);
        trans2.translateVector(vZ2);
        trans3.translateVector(vZ3);
        trans4.translateVector(vZ4);
        trans5.translateVector(vZ5);
        trans6.translateVector(vZ6);

    }
    if(op > 8){
        ok = true;
    }    
    //we are moving    
    world.render();
    cam.setPosition( x, y, z );
    cam.lookAt(0,0,0);
    op++;
}

The problem is in point when the camera gets to y=500 point, as we know it wont go any further and show the object from other side. Thats why I m using the p to make the movement reverse and flip the object. It almost ok, but you can see when it is happening and it doesn't look good. Do you have any ideas how to improve the rotation of this menu.

Thanks !
Petit
QUOTE(kosmo @ Mar 22 2007, 02:31 PM) *

The problem is in point when the camera gets to y=500 point, as we know it wont go any further and show the object from other side. Thats why I m using the p to make the movement reverse and flip the object. It almost ok, but you can see when it is happening and it doesn't look good. Do you have any ideas how to improve the rotation of this menu.


Welcome to the gang!
What you've done there is really beautiful!

About the problem with camera position (0, 500, 0 ), this is the classical problem in many 3D engines.
You are looking straight down, and the camera rotation around its line of sight (roll ) is no longer defined.
The system gets unstable. You could possibly avoid this position, by not letting x = 0, y = 0 simultaneously.
( Maybe you don't have to do the reverse and flip? )
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2007 Invision Power Services, Inc.