Exemplo n.º 1
0
void GUI3DDirectionArrow::handleMsg( ZMsg *msg ) {
	if( zmsgIs(type,MouseClickOn) && zmsgIs(which,L) && zmsgIs(dir,D) ) {
		startDrag = FVec2( zmsgF(localX), zmsgF(localY) );
		startDragMat = mat;
		requestExclusiveMouse( 1, 1 );
		zMsgUsed();
		sendMsg();
	}
	else if( zmsgIs(type,MouseReleaseDrag) ) {
		requestExclusiveMouse( 1, 0 );
		zMsgUsed();
	}
	else if( zmsgIs(type,MouseDrag) ) {
		FVec2 mouseDelta( zmsgF(localX), zmsgF(localY) );
		mouseDelta.sub( startDrag );
		mouseDelta.mul( 0.03f );
		mat = startDragMat;
		FMat4 eye = mat;
		eye.setTrans( FVec3::Origin );
		eye.inverse();
		FVec3 yEye = eye.mul( FVec3::YAxisMinus );
		FVec3 xEye = eye.mul( FVec3::XAxis );
		mat.cat( rotate3D( yEye, mouseDelta.x ) );
		mat.cat( rotate3D( xEye, mouseDelta.y ) );
		zMsgUsed();
		sendMsg();
	}
	else if( zmsgIs(type,SetDir) ) {
		FVec3 xaxis( zmsgF(x), zmsgF(y), zmsgF(z) );
		xaxis.mul(-1.f);
		FVec3 yaxis( 0.f, 1.f, 0.f );
		yaxis.cross( xaxis );
		FVec3 zaxis = yaxis;
		zaxis.cross( xaxis );
		xaxis.normalize();
		yaxis.normalize();
		zaxis.normalize();
		mat.m[0][0] = xaxis.x;
		mat.m[0][1] = xaxis.y;
		mat.m[0][2] = xaxis.z;
		mat.m[0][3] = 0.f;
		mat.m[1][0] = yaxis.x;
		mat.m[1][1] = yaxis.y;
		mat.m[1][2] = yaxis.z;
		mat.m[1][3] = 0.f;
		mat.m[2][0] = zaxis.x;
		mat.m[2][1] = zaxis.y;
		mat.m[2][2] = zaxis.z;
		mat.m[2][3] = 0.f;
		mat.m[3][0] = 0.f;
		mat.m[3][1] = 0.f;
		mat.m[3][2] = 0.f;
		mat.m[3][3] = 1.f;
	}
}
Exemplo n.º 2
0
void		rotateImage(t_bunny_pixelarray *s,
			    t_bunny_pixelarray *d, double r)
{
  t_mat3	m;
  t_ivec2	incr;
  t_color	color;
  t_ivec2	v[3];
  t_vec3	tmp;

  v[0] = ivec2(d->clipable.clip_width / 2, d->clipable.clip_height / 2);
  v[2] = subiVec2(v[0], ivec2(s->clipable.clip_width / 2.0,
			      s->clipable.clip_height / 2.0));
  m = mat3();
  translate3(&m, to_vec2(v[0]));
  rotate3D(&m, vec3(0, 0, -r));
  translate3(&m, vec2(-v[0].x, -v[0].y));
  incr.y = -1;
  while (++incr.y < d->clipable.clip_height)
    {
      incr.x = -1;
      while (++incr.x < d->clipable.clip_width)
	{
	  tmp = multMatVec3(&m, vec3(incr.x, incr.y, 1));
	  v[1] = to_ivec2(vec2(tmp.x, tmp.y));
	  color.full = getPixel(s, subiVec2(v[1], v[2]));
	  tekpixel(d, &incr, &color);
	}
    }
}
//-------------------------------------------------------------------------
void FKCW_3D_Node::rotate3D(const FKCW_3D_Vector4&axis,float A)
{
	float fValue = static_cast<float>(A*M_PI/180.0f);
	rotate3D(axis, cosf(fValue), sinf(fValue));
}
Exemplo n.º 4
0
/// <summary>
/// A utility function for obtaining a matrix that rotates a point with respect to the
/// axis (1, 0, 0), (0, 1, 0), (0, 0, 1)
/// </summary>
///
/// <param name="rotation">A vec3 of the form (x angle, y angle, z angle).</param>
inline glm::mat4 rotate3D(glm::vec3 rotation) {
    return rotate3D(rotation, glm::vec3(1, 0, 0), glm::vec3(0, 1, 0), glm::vec3(0, 0, 1));
}