Esempio n. 1
0
void SkeletalModel::traverseLimbTree(Joint* j){

	Vector3f u,v,w;
	Vector4f c;
	Matrix4f rotate,scale,translate;
	
	translate =  Matrix4f::translation(0.0f,0.0f,0.5f);

	m_matrixStack.push(j->transform);

	for (int i = 0; i < j->children.size(); i++){
		
		c = j->children[i]->transform.getCol(3);

		w = c.xyz().normalized();
		v = Vector3f::cross(w,Vector3f(0,0,1)).normalized();
		u = Vector3f::cross(v,w).normalized();

		scale = Matrix4f::scaling(.025,.025,c.xyz().abs());
		rotate = Matrix4f(Vector4f(u,0),Vector4f(v,0),Vector4f(w,0),Vector4f(0,0,0,1));
	
		glLoadMatrixf(m_matrixStack.top()*rotate*scale*translate);
		glutSolidCube(1.0f);

		traverseLimbTree(j->children[i]);
	}
	
	m_matrixStack.pop();
}
Esempio n. 2
0
void SDFShadowDemo::UpdateScene(f32 /*dt*/)
{
    auto frames = (f32)mTimer.FrameCount() / 1000;
    //m_worldMat = Matrix4f::RotationMatrixY(frames);
    m_worldMat = Matrix4f::Identity();

    Matrix4f viewRot = Matrix4f::RotationMatrixY(frames);
    // Build the view matrix.
    m_cameraPos = Vector4f(0.0f, 1.0f, -5.0f, 1.0f);
    m_cameraPos = viewRot * m_cameraPos;
    Vector3f target;
    target.MakeZero();
    Vector3f up = Vector3f(0.0f, 1.0f, 0.0f);
    m_viewMat = Matrix4f::LookAtLHMatrix(m_cameraPos.xyz(), target, up);
}
Esempio n. 3
0
        void update()
        {
            if (targetCamera)
                view = look_at(position, target, Vector3f(0.f, 1.f, 0.f));
            else
            {
                Vector4f p = invert(view) * Vector4f(0.f, 0.f, 0.f, 1.f);
                p /= p.w;
                position = p.xyz();
            }

            Matrix4x4f m = perspective(fov, 1.f, 0.1f, 100.f) * view;
            viewToClip = m;

            clipToView = viewToClip;
            clipToView.invert();
        }