|
本帖最后由 oirrm 于 2014-5-14 14:06 编辑
#include <osg/Geometry>
#include <osg/MatrixTransform>
#include <iostream>
#pragma comment( lib, "osgd.lib")
#pragma comment( lib, "osgViewerd.lib")
#pragma comment( lib, "osgDBd.lib")
#pragma comment( lib, "OpenThreadsd.lib")
#pragma comment( lib, "osgUtild.lib")
#pragma comment( lib, "osgGAd.lib")
#pragma comment( lib, "osgTextd.lib")
#pragma comment( lib, "osgSimd.lib")
osg::Vec3d postMultloca(double _mat[][4],osg::Vec3d v )
{
osg::Vec3d::value_type d = 1.0f/(_mat[3][0]*v.x()+_mat[3][1]*v.y()+_mat[3][2]*v.z()+_mat[3][3]);
return osg::Vec3d((_mat[0][0]*v.x() + _mat[0][1]*v.y() + _mat[0][2]*v.z() + _mat[0][3])*d,
(_mat[1][0]*v.x() + _mat[1][1]*v.y() + _mat[1][2]*v.z() + _mat[1][3])*d,
(_mat[2][0]*v.x() + _mat[2][1]*v.y() + _mat[2][2]*v.z() + _mat[2][3])*d);
}
int _tmain(int argc, _TCHAR* argv[])
{
/*osg::Matrixd a;
a.setTrans(4,0,1);*/
osg::Vec3 b;
b.set(1,2,3);
double _mat[4][4] = {
1,0,0,0,
0,1,0,0,
0,0,1,0,
4,0,1,1
};
osg::Vec3 f = postMultloca(_mat,b);//f=0.125,0.25,0.375
getchar();
return 0;
} |
|