广告牌技术:欺骗-圆柱体化广告牌

本文介绍了一种称为圆柱体化广告牌的技术,它通过调整模型视图矩阵中的right向量和lookAt向量来实现。这种方法适用于树木等不需要随摄像机上下移动的对象,能有效减少不必要的旋转。

As mentioned in the previous section, the modelview matrix contains the transformations required to perform the change of coordinates between local coordinates and world coordinates. It has been shown that by replacing the top 3x3 submatrix with the identity matrix a cheating version of spherical billboarding can be obtained. But what about Cylindrical billboarding?

正如先前提到的,模型视图矩阵包括使物体坐标在局部坐标空间与世界坐标空间转变的变换操作。已经展示过了,通过替换top3X3子矩阵为单位矩阵,一个欺骗性质的球体化广告牌获得了。但是圆柱体化的广告牌呢?

Let us analyze in depth what is actually the structure of the top 3X3 submatrix. This matrix contains 3 columns, and each has a special meaning. The first is the right vector, the second column is the up vector and the 3rd represents the lookAt vector. These vectors are relative to the cameras orientation. Setting the top 3x3 submatrix to the identity matrix effectively causes the camera's coordinate system to be aligned with the worlds coordinate system.

让我们深度分析一下top3X3子矩阵的实际结构。这个矩阵包括3列,每一列都有一个特殊含义。第一列是右向量,第二列是上向量,第三列是lookAt向量。这些向量是相机方向相关的。设置top3X3子矩阵为单位矩阵将引起相机坐标系统的坐标轴与世界坐标系的轴平行。

In order to achieve a (cheating) Cylindrical Billboard, it is sufficient to align the right and lookAt vectors, leaving the up vector unchanged. The difference between this version and the spherical one, presented in the previous section, is that when the camera looks up or down the billboard won't move. The billboard will only be rotated when the camera looks right or left.

为了获得(欺骗性质)圆柱体化广告牌,有必要调整right向量和lookAt向量,保持up向量不变。这个版本和球体化广告牌的区别在前文中已经讲述过,也就是当相机looks up或者down的时候广告牌不移动。当相机向右或向左看的时候广告牌仅仅被旋转。

This type of billboards can be applied to trees. Trees don't bend backwards and forwards as the camera looks down or up because the up vector is fixed, so it doesn't make much sense to use a spherical billboard. Beware that the illusion is broken when you fly over the tree. In this case you'll see your tree getting thinner and thinner and all is lost. However if you're application keeps you on the terrain then cylindrical billboarding is a good option.

这个类型的广告牌可以被应用于树木。树木不会向前或向后倾斜当相机向上或向下观察的时候,因为up向量是固定不变的,所以使用球体化的广告牌没有多大意义。要意识到当你从树木顶部飞过的时候这个假象会暴露。这种情况下你会发现你的树越来越细直至消失。然而如果你的应用程序保持你在地面那么圆柱体化广告牌将会是一个不错的选择。

The code for cheating cylindrical billboards is almost identical to the spherical version.
欺骗性质的圆柱体化广告牌的代码几乎和球体化的相同。
float modelview[16];
int i,j;

// save the current modelview matrix
glPushMatrix();

// get the current modelview matrix
glGetFloatv(GL_MODELVIEW_MATRIX , modelview);

// The only difference now is that
// the i variable will jump over the
// up vector, 2nd column in OpenGL convention

for( i=0; i<3; i+=2 ) 
	for( j=0; j<3; j++ ) {
		if ( i==j )
			modelview[i*4+j] = 1.0;
		else
			modelview[i*4+j] = 0.0;
	}

// set the modelview matrix with the 
// up vector unchanged
glLoadMatrixf(modelview);

drawObject();

// restores the modelview matrix
glPopMatrix();


As we did before, the above code can be divided in two functions, besides the rendering function, drawObject. The first function will setup the modelview matrix, and the second will restore the current matrix.
正如我们先前做的,上面的代码可以被分为两个函数,包括渲染函数,drawObject函数。第一个函数设置模型视图矩阵,第二个恢复当前矩阵。

void billboardCheatCylindricalBegin() {
	
	float modelview[16];
	int i,j;

	// save the current modelview matrix
	glPushMatrix();

	// get the current modelview matrix
	glGetFloatv(GL_MODELVIEW_MATRIX , modelview);

	for( i=0; i<3; i+=2 ) 
	    for( j=0; j<3; j++ ) {
		if ( i==j )
		    modelview[i*4+j] = 1.0;
		else
		    modelview[i*4+j] = 0.0;
	    }

	// set the modelview matrix
	glLoadMatrixf(modelview);
}



void billboardEnd() {

	// restore the previously 
	// stored modelview matrix
	glPopMatrix();
}


The source code for rendering a billboard object becomes:

渲染物体的源代码如下:

billboardCheatCylindricalBegin();
    drawObject();
billboardEnd();


Again, beware with scaling operations. Scaling in the X and Y axis will be undone using this approach, but scaling in the Z axis will persist. the best option is to scale after you call billboardCheatCylindricalBegin().

再一次要注意缩放操作。使用这个方法,缩放x y坐标轴将被撤销,但是缩放z轴的操作将被保持。最好的选择是在调用billboardCheatCylindricalBegin()函数之后缩放。

 

本项目采用C++编程语言结合ROS框架构建了完整的双机械臂控制系统,实现了Gazebo仿真环境下的协同运动模拟,并完成了两台实体UR10工业机器人的联动控制。该毕业设计在答辩环节获得98分的优异成绩,所有程序代码均通过系统性调试验证,保证可直接部署运行。 系统架构包含三个核心模块:基于ROS通信架构的双臂协调控制器、Gazebo物理引擎下的动力学仿真环境、以及真实UR10机器人的硬件接口层。在仿真验证阶段,开发了双臂碰撞检测算法和轨迹规划模块,通过ROS控制包实现了末端执行器的同步轨迹跟踪。硬件集成方面,建立了基于TCP/IP协议的实时通信链路,解决了双机数据同步和运动指令分发等关键技术问题。 本资源适用于自动、机械电子、人工智能等专业方向的课程实践,可作为高年级课程设计、毕业课题的重要参考案例。系统采用模块设计理念,控制核心与硬件接口分离架构便于功能扩展,具备工程实践能力的学习者可在现有框架基础上进行二次开发,例如集成视觉感知模块或优运动规划算法。 项目文档详细记录了环境配置流程、参数调试方法和实验验证数据,特别说明了双机协同作业时的时序同步解决方案。所有功能模块均提供完整的API接口说明,便于使用者快速理解系统架构并进行定制修改。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值