关于3d图像子节点的问题
c++吧
全部回复
仅看楼主
level 2
liu896285864 楼主
机器人的胳膊没了,完全没有子节点的显示,求大神指教:
代码如下:
//更新节点的矩阵
void UpdateMatrix(Lib3dsNode *node)
{
if(!node)return;
float newMatrix[4][4],t[4][4];
float tx,ty,tz,theta,rx,ry,rz,sx,sy,sz,(*localMatrix)[4]=NULL;
SetIdentity(t);
//获取父节点的矩阵
if(node->parent)
GetNodeMatrix(newMatrix,node->parent);
else SetIdentity(newMatrix);
//对不同节点区别对待
if(strcmp(node->name,LEFTARMNAME)==0)
{
//如果是左胳膊节点
//node相对于父节点的局部坐标系的各变换分量如下
tx=LATX;ty=LATY;tz=LATZ;
theta=LATHETA;rx=LARX;ry=LARY;rz=LARZ;
sx=LASX;sy=LASY;sz=LASZ;
//局部变换矩阵是ArmComT;
localMatrix=LArmComT;
}
else if(strcmp(node->name,lEFTHANDNAME)==0)
{
//如果是左手节点
tx=LHTX;ty=LHTY;tz=LHTZ;
theta=LHTHETA;rx=LHRX;ry=LHRY;rz=LHRZ;
sx=LHSX;sy=LHSY;sz=LHSZ;
localMatrix=LHandComT;
}
else if (strcmp(node->name, RIGHTARMNAME) == 0)
{
//如果是右胳膊节点
//node相对于父节点的局部坐标系的各变换分量如下
tx = RATX; ty = RATY; tz = RATZ;
theta = RATHETA; rx = RARX; ry = RARY; rz = RARZ;
sx = RASX; sy = RASY; sz = RASZ;
//局部变换矩阵是ArmComT;
localMatrix = RArmComT;
}
else if (strcmp(node->name, RIGHTHANDNAME) == 0)
{
//如果是右手节点
tx = RHTX; ty = RHTY; tz = RHTZ;
theta = RHTHETA; rx = RHRX; ry = RHRY; rz = RHRZ;
sx = RHSX; sy = RHSY; sz = RHSZ;
localMatrix = RHandComT;
}
else return;
//3d模型是由多个节点(node)组成,节点之间有父子关系(比如身体节点是手臂节点的父节点)。
//要得到级联的效果,节点应首先相对于其父节点的局部坐标系变换,再相对于自身的局部坐标系变换
//node相对于父节点局部坐标系变换的各分量,以及相对于自身局部坐标系的变换矩阵本函数已提供
//矩阵newMatrix存储了node的父节点的变换矩阵
//请利用提供的变量对newMatrix进行计算,得到最终node的变换矩阵,矩阵的计算见 transformation.h
//添加代码
matTxyz(localMatrix, tx, ty, tz);
MatMul(newMatrix, localMatrix, newMatrix);
matRx(localMatrix, theta);
MatMul(newMatrix, localMatrix, newMatrix);
matRy(localMatrix, theta);
MatMul(newMatrix, localMatrix, newMatrix);
matRz(localMatrix, theta);
MatMul(newMatrix, localMatrix, newMatrix);
matR(localMatrix, theta, rx, ry, rz);
MatMul(newMatrix, localMatrix, newMatrix);
matSxyz(localMatrix,sx,sy,sz);
MatMul(newMatrix, localMatrix, newMatrix);
//更新矩阵
SetNodeMatrix(newMatrix,node);
}
2015年11月23日 14点11分 1
level 1
请问楼主解决了吗
2018年05月17日 05点05分 2
1