OSG创建柱元
作者:互联网
- 名词翻译:
法向量:normal vector
法线:normal
- 代码:
//分支判断start
if (_columnType == Circle1) //圆形规则
{
for (size_t i = 0; i < 120; i++)
{
osg::Vec3 Point = _temp + L * osg::Matrix::rotate(osg::inDegrees(i * 3.0), normal);
//osg::Vec3f L = osg::Vec3f(1, 0, 0) * _diameter / 2; L指某一个半径长度的向量,即单位向量(1,0,0)*直径/2
//关键点temp+向量L绕法线normal旋转i*3度(转120次是近似圆)
Point.z() = 1;
//竖坐标?
column->push_back(Point);
//压入,最终一起组成图元column
}
}
else if (_columnType == Squre) //矩形规则
{
float theHalfofLength = _length * 0.5;
float theHalfofWidth = _width * 0.5;
osg::Vec3f xDirection = _direction ^ osg::Z_AXIS; //叉乘:柱子方向^竖单位向量(0,0,1),右手法则判断方向
//辅助点
osg::Vec3f supPoint = (xDirection * theHalfofWidth) + _temp;
//点A
osg::Vec3f pointA = (_direction * theHalfofLength) + supPoint;
//点A辅助线镜像A'
osg::Vec3f pointMirrorASup = supPoint - pointA + supPoint;
//点A对角线镜像点B
osg::Vec3f pointB = _temp - pointA + _temp;
//点A'对角线镜像B'
osg::Vec3f pointMirrorBSup = _temp - pointMirrorASup + _temp;
colunm->push_back(pointA);
colunm->push_back(pointMirrorASup);
colunm->push_back(pointB);
colunm->push_back(pointMirrorBSup);
this->addCaptureLine(colunm);
}
标签:colunm,temp,创建,back,Vec3f,柱元,OSG,push,osg 来源: https://www.cnblogs.com/jessicaland/p/16535085.html