bool Animator::userInteraction() { if (TA3D::VARS::TheModel == NULL) return false; Vector3D pointer = getCursor(); Vector3D pos = 1.0f / zoom * cam.pos * RotateXYZ( -r1 * DEG2RAD, -r2 * DEG2RAD, -r3 * DEG2RAD ); Vector3D I; MATRIX_4x4 M = Scale(zoom); int nidx = TA3D::VARS::TheModel->hit(pos,pointer,NULL,&I,M); bool result = false; if (cursor_idx != nidx) { cursor_idx = TA3D::Math::Max(nidx,-1); result = true; pArea->set_caption("animator.pointed", cursor_idx >= 0 ? TA3D::VARS::obj_table[cursor_idx]->name : ""); } if (cursor_idx >= 0 && mouse_b == 1) { switch(pointing_mode) { case ANIMATOR_MODE_SELECTION: sel_idx = cursor_idx; result = true; pArea->set_caption("animator.selected", TA3D::VARS::obj_table[sel_idx]->name); break; case ANIMATOR_MODE_SET_FATHER: break; case ANIMATOR_MODE_ANIMATE: break; }; } return result; }
Vector3D Animator::getCursor() { GUIOBJ *render = pArea->get_object("animator.render"); if (render == NULL) return Vector3D(); int mx = mouse_x - render->x1; int my = mouse_y - render->y1; int w = render->x2 - render->x1; int h = render->y2 - render->y1; Vector3D cur_dir; cur_dir = cam.dir + cam.widthFactor * 2.0f * (mx - 0.5f * w) / w * cam.side - 1.5f * (my - 0.5f * h) / h * cam.up; cur_dir = cur_dir * RotateXYZ( -r1 * DEG2RAD, -r2 * DEG2RAD, -r3 * DEG2RAD ); // Return to object space coordinates cur_dir.unit(); // Direction pointée par le curseur return cur_dir; }
bool CSTransform::RotateZ(std::string angle, bool concatenate) { return RotateXYZ(2,angle,concatenate); }
void CSTransform::RotateZ(double angle, bool concatenate) { return RotateXYZ(2,angle,concatenate); }
bool CSTransform::RotateY(string angle, bool concatenate) { return RotateXYZ(1,angle,concatenate); }