TA的每日心情![](source/plugin/dsu_paulsign/img/emot/kx.gif) | 开心 昨天 15:23 |
---|
签到天数: 69 天 [LV.6]常住居民II
管理员
- 积分
- 2704
|
void getViewXform(const AcGePoint3d& target,
const AcGeVector3d& viewDir,
const double& twist,
AcGeMatrix3d& xform)
{
AcGeVector3d vZ = -viewDir;
vZ.normalize();
AcGeVector3d vX = -vZ.perpVector().rotateBy(twist, vZ);
AcGeVector3d vY = vX.crossProduct(vZ);
xform(0,0) = vX.x; xform(0,1) = vX.y; xform(0,2) = vX.z;
xform(1,0) = vY.x; xform(1,1) = vY.y; xform(1,2) = vY.z;
xform(2,0) = vZ.x; xform(2,1) = vZ.y; xform(2,2) = vZ.z;
xform(3,0) = 0; xform(3,1) = 0; xform(3,2) = 0;
AcGeVector3d targ = target.asVector();
targ.transformBy(xform);
xform(0,3) = -targ.x;
xform(1,3) = -targ.y;
xform(2,3) = -targ.z;
xform(3,3) = 1;
}
void getViewXform(const AcGePoint3d& target,
const AcGePoint3d& position,
const AcGeVector3d & upVec,
AcGeMatrix3d& xform)
{
AcGeVector3d vZ = (target - position).normalize();
AcGeVector3d vY = upVec;
AcGeVector3d vX = vZ.crossProduct(vY);
xform(0,0) = vX.x; xform(0,1) = vX.y; xform(0,2) = vX.z;
xform(1,0) = vY.x; xform(1,1) = vY.y; xform(1,2) = vY.z;
xform(2,0) = vZ.x; xform(2,1) = vZ.y; xform(2,2) = vZ.z;
xform(3,0) = 0; xform(3,1) = 0; xform(3,2) = 0;
AcGeVector3d targ = target.asVector();
targ.transformBy(xform);
xform(0,3) = -targ.x;
xform(1,3) = -targ.y;
xform(2,3) = -targ.z;
xform(3,3) = 1;
}
void getProjXform(const double& dcsWidth,
const double& dcsHeight,
const double& cam2targDist,
bool isPersp,
AcGeMatrix3d& xform)
{
xform AcGeMatrix3d::kIdentity;
xform(0,0) = (double(2)) / dcsWidth;
xform(1,1) = (double(2)) / dcsHeight;
if (isPersp)
{
xform(2,2) = xform(3,2) = (double(1)) / cam2targDist;
}
else
{
xform(2,2) = (double(0.1)) / cam2targDist;
}
}
void getScrXform(int scrWidth,
int scrHeight,
bool isPersp,
AcGeMatrix3d& xform)
{
xform = AcGeMatrix3d::kIdentity;
xform(0,0) = xform(0,3) = (double(scrWidth)) / (double(2));
xform(1,1) = xform(1,3) = (double(scrHeight)) / (double(2));
if (isPersp)
{
xform(2,2) = 3276.75;
xform(2,3) = 62258.25;
}
else
{
xform(2,2) = xform(2,3) = 32767.5;
}
}
void getWcs2ScrXform(const AcGeMatrix3d& viewXform,
const AcGeMatrix3d& projXform,
const AcGeMatrix3d& scrXform,
AcGeMatrix3d& xform)
{
xform = scrXform * projXform * viewXform;
if ((xform(3,3) != double(1)) &&
(xform(3,3) != double(0)))
{
const double scale = (double(1))/(xform(3,3));
xform(0,0) *= scale;
xform(0,1) *= scale;
xform(0,2) *= scale;
xform(0,3) *= scale;
xform(1,0) *= scale;
xform(1,1) *= scale;
xform(1,2) *= scale;
xform(1,3) *= scale;
xform(2,0) *= scale;
xform(2,1) *= scale;
xform(2,2) *= scale;
xform(2,3) *= scale;
xform(3,0) *= scale;
xform(3,1) *= scale;
xform(3,2) *= scale;
xform(3,3) = double(1);
}
} |
|