Jump to content

  • Log In with Google      Sign In   
  • Create Account

third-person camera


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 meiryousa   Members   -  Reputation: 113

Like
0Likes
Like

Posted 06 March 2014 - 09:32 AM

Well, I have a third-person camera working. It's "ok" I guess. It just doesn't quite work the way I want it to.  It rotates around the target perfectly. Exactly how I want it to. It zooms in and out on the target perfectly too. What I am having troubles with is having it rotate over the target. The reason this is difficult is because it depends on the direction I am facing. These are my functions so far:
 

void ViewManager::rotateOver(float amt){

    y_theta += amt;

    position.y = target.y + radius * cos(y_theta * M_PI / 180.0f);

    v_matrix = glm::lookAt(position, target, glm::vec3(0.0f,1.0f,0.0f));

    return;

}



void ViewManager::rotateAround(float amt){

    x_theta += amt;

    z_theta += amt;

    position.x = target.x + radius * sin(x_theta * M_PI / 180.0f);

    position.z = target.z + radius * cos(z_theta * M_PI / 180.0f);

    v_matrix = glm::lookAt(position, target, glm::vec3(0.0f,1.0f,0.0f));

    return;

}



void ViewManager::zoomIn(float amt){

    radius += amt;

    position.x = target.x + radius * sin(x_theta * M_PI / 180.0f);

    position.y = target.y + radius * cos(y_theta * M_PI / 180.0f);

    position.z = target.z + radius * cos(z_theta * M_PI / 180.0f);

    v_matrix = glm::lookAt(position, target, glm::vec3(0.0f,1.0f,0.0f));

    return;

}

I've tried a lot of different things. I've had it rotating over one axis, both axes, but never the correct axes. I don't think I need 3 angles... I just did that recently trying different ideas... there are angles created between the x-y axes and x-z axes. This is based on polar coordinates.

I hope I gave enough information...



Sponsor:

#2 WiredCat   Members   -  Reputation: 367

Like
0Likes
Like

Posted 08 March 2014 - 11:33 AM

try the formula that you add x minus y and z

 

(in this case glop is a true heading angle, and heading angle is i dont know what (upside-down roattion angle ;])

SUPERPOINT.x = 100000*(sin(glop*imopi)*cos(heading*imopi));
SUPERPOINT.z = 100000*(cos(glop*imopi)*cos(heading*imopi));
SUPERPOINT.y = 100000*(sin(heading*imopi));

 

 

gluLookAt(old.x,old.y,old.z,old.x+SUPERPOINT.x,old.y-SUPERPOINT.y,old.z-SUPERPOINT.z,0,1,0);






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS