render same axis
// 当前渲染相机的参数
QGlobalCamera* curRenderCamera = _getWorld()->getMainCam();
const Matrix4& matView = curRenderCamera->_getCamMatView();
float zNear = curRenderCamera->getNearClipDistance();
float fovYHalf = curRenderCamera->getFOVy().valueRadians() * 0.5f;
float tanFov = Math::Tan(fovYHalf);
float asp = curRenderCamera->getAspectRatio();
float heightNear = tanFov * zNear * 2;
float widthNear = asp * heightNear;
float screenMaxSize = std::max( widthNear, heightNear );
// 自己的参数
Vector3 rsPos = _getRSPosWorld();
Vector3 posInViewSpace = matView * rsPos;
float zView = -posInViewSpace.z;
// 调节
const float projRef = 0.1f * screenMaxSize; // 要求占屏幕大小比例
float zViewMin = zNear + 0.01f;
if ( zView < zViewMin )
zView = zViewMin;
float projRefLong = Math::Sqrt( zNear * zNear + projRef * projRef );
// ref / ref_l = r / z_view
float r = projRef / projRefLong * zView;
float s_adj = r / AXIS_LEN;
Vector3 v_adj(s_adj);