/// <summary> /// World to screen (pixel) /// </summary> /// <param name="src"></param> /// <param name="frame"></param> /// <returns></returns> public Vector3f ProjectedCoordinatesOf( Vector3f src, Frame frame ) { Vector3f tmp; if( frame != null ) { tmp = frame.InverseCoordinatesOf( src ); } else { tmp = src; } Vector4f clip = ProjectionViewMatrix * new Vector4f( tmp, 1.0f ); Vector3f ndc = clip.Homogenized(); float sx = ScreenSize.x * 0.5f * ( ndc.x + 1.0f ); float sy = ScreenSize.y * 0.5f * ( ndc.y + 1.0f ); // OpenGL // float sz = 0.5f * ( ndc.Z + 1.0f ); // D3D float sz = ndc.z; // float w = 1; return new Vector3f( sx, sy, sz ); }