Beispiel #1
0
void PathFollow2D::_update_transform() {


	if (!path)
		return;

	Ref<Curve2D> c =path->get_curve();
	if (!c.is_valid())
		return;


	float o = offset;
	if (loop)
		o=Math::fposmod(o,c->get_baked_length());

	Vector2 pos = c->interpolate_baked(o,cubic);

	if (rotate) {

		Vector2 n = (c->interpolate_baked(o+lookahead,cubic)-pos).normalized();
		Vector2 t = -n.tangent();
		pos+=n*h_offset;
		pos+=t*v_offset;

		set_rot(t.atan2());

	} else {

		pos.x+=h_offset;
		pos.y+=v_offset;
	}

	set_pos(pos);

}
Beispiel #2
0
void camera::set_rot(const nya_math::vec3 &dir)
{
    const float eps=1.0e-6f;
    const nya_math::vec3 v=nya_math::vec3::normalize(dir);
    const float xz_sqdist=v.x*v.x+v.z*v.z;

    const float new_yaw=(xz_sqdist>eps*eps)? (-std::atan2(v.x,v.z)-nya_math::constants::pi) : m_rot.get_euler().y;
    const float new_pitch=(fabsf(v.y)>eps)? (-std::atan2(v.y,sqrtf(xz_sqdist))) : 0.0f;

    set_rot(nya_math::quat(new_pitch,new_yaw,0));
}
Beispiel #3
0
void Node2D::rotate(float p_radians) {

	set_rot( get_rot() + p_radians);
}
Beispiel #4
0
void Node2D::_set_rotd(float p_angle) {

	set_rot(Math::deg2rad(p_angle));
}
Beispiel #5
0
//----------------------------------------------------------------------------------------------
 Matrix::Matrix(const Quaternion& rot, const Vector& pos)
{
	set_rot(rot);
	set_translation(pos);
}
Beispiel #6
0
//----------------------------------------------------------------------------------------------
void Matrix::set_rot(const Quaternion & q)
{
	Matrix3f m;
	q.ToMatrix(m);
	set_rot(m);
}
Beispiel #7
0
void mat4::set_rot(const quat& q)
{
	mat3 m;
	q.ToMatrix(m);
	set_rot(m);
}
Beispiel #8
0
void camera::set_rot(float yaw,float pitch,float roll)
{
    const float a2r=nya_math::constants::pi/180.0f;
    set_rot(nya_math::quat(pitch*a2r,yaw*a2r,roll*a2r));
}
Beispiel #9
0
void Node2D::rotate(float p_degrees) {

	set_rot( get_rot() + p_degrees);
}
Beispiel #10
0
void VMDTitle::prepare() {
  double elapsed = time_of_day() - starttime;
  double delta;

  // Prevent the title screen from hogging the CPU/GPU when there's
  // nothing else going on.  This is particularly important for users
  // that start VMD and immediately start using Multiseq with no structure
  // data loaded at all.
  vmd_msleep(1); // sleep for 1 millisecond or more

  if (elapsed < 5 + 3) {  // display the title screen, no animation
    if (!letterson) {
      letterson = TRUE;
      redraw_list();
    }
    return;
  }

  elapsed -= 3;
  if (letterson) {
    letterson = FALSE;
    redraw_list();
  }

  if (elapsed < 30) { // just spin the VMD logo
    delta = elapsed - 5;
    rot_on();
    set_rot(solve_position((float) delta, 25.0f, 0.0f, 360.0f*8.0f), 'y');
    rot_off();
  }

  if (elapsed < 15) { 
    delta = elapsed - 5;
    scale_on();
    set_scale( 1.0f/(1.0f+ ((float) delta)/3.0f)); // and getting smaller
    scale_off();
    glob_trans_on();

    // and moving up
    set_glob_trans(0, 0.5f, solve_position((float) delta, 10.0f, 0.0f, 0.5f)); 
    glob_trans_off();
    return;
  }

  if (elapsed < 20) {
    return;
  }

  // I am at          ( 0  ,  0.5, 0.5)
  // I want to get to ( -.7  ,  0.9  , 0.5) in 10 secs
  if (elapsed < 30) {
    delta = elapsed - 20;
    glob_trans_on();
    set_glob_trans(
       solve_position((float) delta, 10.0f, 0.0f, -0.6f * disp->aspect()),
       solve_position((float) delta, 10.0f, 0.5f, 0.8f),
       solve_position((float) delta, 10.0f, 0.5f, 0.5f));
    glob_trans_off();
    scale_on();
    set_scale(solve_position((float) delta, 10.0f, 1.0f/(1.0f+10.0f/3.0f), 0.25f));
    scale_off();
    return;
  }

  if (elapsed < 35) 
    return;

  // just spin the VMD logo
  delta = elapsed - 35;
  rot_on();
  set_rot((float) delta * 360.0f / 6.0f, 'y');  
  rot_off();
}