- 积分
- 34
- 帖子
- 29
- 主题
- 9
- 精华
- 0
- 最后登录
- 2019-5-10
- 在线时间
- 28 小时
- 私信
|
发表时间 : 2007-12-12 16:35:56
|
浏览 : 1141 评论 : 2
#include <vgutil.h>
#include <vg.h>
void
setObjectScale( vgObject *obj, float* xyzScale ){
// -------------------------------------------------------
//
// Public Function
//
// Set the Scale of the vgObject using the XYZ scale
// values passed in thru xyzScale[3]
//
// -------------------------------------------------------
vgMat scaleMat;
double x,y,z,h,p,r;
//
// Sanity check we need an object and scale
//
if( obj == NULL || xyzScale == NULL){
return;
}
//
// We need a Matrix stack so create one
//
vgMatStack *scaleStack = vgNewMatStack();
//
// We need to grab the Real coordinate position
// of the object
//
vgPosition *objPos = vgNewPos();
vgGetWCSPos ( obj, objPos );
vgGetPosVecD( objPos, &x, &y, &z, &h, &p, &r);
//
// Set up the Matrix stack for the operation
// required to set a scale matric on the object
//
vgPushMatStack( scaleStack);
vgTransMat( scaleStack, x, y, z);
vgRotMat( scaleStack, h, 'z' );
vgRotMat( scaleStack, p, 'x' );
vgRotMat( scaleStack, r, 'y' );
vgScaleMat( scaleStack, sxyz[0], sxyz[1], sxyz[2]);
//
// Grab the accumlate matrix from the stack
//
vgGetMat( scaleStack, scaleMat );
//
// Clear the stack
//
vgPopMatStack( scaleStack );
//
// Apply the Matrix to the vgPos and then to the vgObject
//
vgPosMat( objPos, scaleMat );
vgPos( obj, objPos );
//
// Now Free the dynamically create variables
//
vgDelMatStack( scaleStack );
vgDelPos( objPos );
} // setObjectScale
###############################################################################
以上是vega百例中对物体进行缩放的源代码,请问以下几句是什么意思啊:
vgPushMatStack( scaleStack);
vgTransMat( scaleStack, x, y, z);
vgRotMat( scaleStack, h, 'z' );
vgRotMat( scaleStack, p, 'x' );
vgRotMat( scaleStack, r, 'y' );
vgScaleMat( scaleStack, sxyz[0], sxyz[1], sxyz[2]); |
|