- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
目前我正在从事 ADAS 项目,使用 ROS 和 OGRE(面向对象的图形渲染引擎)可视化道路模型(车道中心、车道边界等)。输入是几何点 (x,y,z)。
我可以使用 Ogre::RenderOperation::OT_TRIANGLE_STRIP 绘制线条。我已经创建了 Material 来独特地可视化实线、虚线、双实线等。如何找到这些几何点的纹理坐标?
当前代码如下所示:
geometry_msgs::Point p0 = _msg.shape_points.front();
for(int i = 1; i < _msg.shape_points.size(); ++i)
{
const geometry_msgs::Point& p1(_msg.shape_points[i]);
const float dx = p1.x - p0.x;
const float dy = p1.y - p0.y;
const float phi = atan2(dy, dx);
const float wx = sin(phi) * lane_mark_width_;
const float wy = -cos(phi) * lane_mark_width_;
if (i == 1)
{
lane_boundary_->position(p0.x - wx, p0.y - wy, p0.z);
lane_boundary_->textureCoord(p0.x , p0.y);
lane_boundary_->position(p0.x + wx, p0.y + wy, p0.z);
lane_boundary_->textureCoord(p0.x, p0.y);
}
lane_boundary_->position(p1.x - wx, p1.y - wy, p1.z);
lane_boundary_->textureCoord(p1.x, p1.y);
lane_boundary_->position(p1.x + wx, p1.y + wy, p1.z);
lane_boundary_->textureCoord(p1.x, p1.y);
p0 = p1;
}
谢谢
最佳答案
纹理坐标需要在 [0, 1] 范围内。其中 [0, 0] 位于纹理的左上角,[1,1] 位于右下角。
我假设您希望纹理沿 y 轴(纹理中的垂直轴,Y 坐标范围)映射到一个条纹。我还假设您的坐标生成是沿线排序的。
geometry_msgs::Point p0 = _msg.shape_points.front();
//Offset in between two points is fixed
const float uv_step = 1.0f / _msg.shape_points.size();
for(int i = 1; i < _msg.shape_points.size(); ++i)
{
const geometry_msgs::Point& p1(_msg.shape_points[i]);
const float dx = p1.x - p0.x;
const float dy = p1.y - p0.y;
const float phi = atan2(dy, dx);
const float wx = sin(phi) * lane_mark_width_;
const float wy = -cos(phi) * lane_mark_width_;
//Compute the vertical texture coordinate
const float v = i * uv_step;
if (i == 1)
{
lane_boundary_->position(p0.x - wx, p0.y - wy, p0.z);
//First point is at the top left corner
lane_boundary_->textureCoord(0.0f, 0.0f);
lane_boundary_->position(p0.x + wx, p0.y + wy, p0.z);
//Second point is a the the top right corner
lane_boundary_->textureCoord(1.0f, 0.0f);
}
lane_boundary_->position(p1.x - wx, p1.y - wy, p1.z);
//Along the y axis on the left
lane_boundary_->textureCoord(0.0f, v);
lane_boundary_->position(p1.x + wx, p1.y + wy, p1.z);
//Along the Y axis on the right
lane_boundary_->textureCoord(1.0f, v);
p0 = p1;
}
确保您需要相同类型的纹理贴图。如果纹理或坐标不在右轴上,只需调整代码以在所需轴上进行插值。
关于c++ - Ogre 中的纹理坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43737075/
我使用 Ubuntu 10.10 编译并安装了最新的 Ogre 和 CEGUI 库。 例如,我可以#include,但是当我尝试添加 CEGUI header 时,我遇到了问题。 #include
所以我正在尝试使用 OGRE 在 C++ 中制作游戏。但我就是无法启动和运行 OGRE。 我遵循了本网站上的教程:http://www.ogre3d.org/tikiwiki/tiki-index.p
对于我在 c++ 中的项目 Ogre,我想使用 Ogre 的 SimpleSpline 创建一个对象的动画。一切正常,对象正确地沿着路径中的点序列进行动画处理。由于我需要使用正交 View 的场景,所
目前我正在从事 ADAS 项目,使用 ROS 和 OGRE(面向对象的图形渲染引擎)可视化道路模型(车道中心、车道边界等)。输入是几何点 (x,y,z)。 我可以使用 Ogre::RenderOper
到目前为止,我已经设法完成了我的 C++ 游戏编程生涯,几乎从未接触过异常,但最近我一直在使用 Ogre 引擎开发一个项目,并且我正在努力学习。我在这里发现了很多关于 C++ 异常的一般用法的很好的问
首先,先确认一下你的字段值是不是乱码,如果是,按照以下方法: 我的字段值是来自于一个geojson字符串,我在对它解析时做了如下处理: ?
我有一个有 body 和头部的角色。头和 body 相连,就像一根骨头,我已经知道骨头的名字了。现在我想得到头部的方向?那可能吗?我试过了,但它似乎不起作用: Entity *smith = m_sc
我正在使用 OGRE 1.7。我想制作一个有两个窗口的应用程序,第一个渲染场景(一堆 3D 点),第二个必须呈现一组控件(按钮、下拉菜单、标签等)。我目前正在使用 SDKTrays 来组织按钮,但由于
我尝试编译以下代码(来自 Felix Kerger 的 Ogre3d 初学者指南) #include "Ogre\ExampleApplication.h" class Example1 : p
假设我的世界中有一个 3d 对象,看起来像下面的东西.. http://en.wikipedia.org/wiki/File:Graftal3.png 我还有一个节点存储有关如何绘制的信息... ht
我在 Ogre3D 中用聚光灯照亮一架飞机。然而,热点上的边缘显示出之字形效果。看起来平面上的阴影是在每个顶点上完成的,没有任何插值。 线框渲染结果如下图: 如何在 Ogre3D 中启用逐像素照明,从
操作系统:Ubuntu 16.04 食人魔:v1.9 我正在尝试从这个 repository 编译代码.虽然它适用于 Ogre v1.9,但它给了我这个错误: In file included fro
我正在根据基本的 Ogre 教程编写自己的 Ogre 应用。 有谁知道在没有第一个设置对话框的情况下启动 OgreRenderWindow 的方法吗? 我知道 Ogre Basic tutorial
我已经在我的 PC 上安装了 Ogre 和依赖项,并下载了一些 Ogre 应用程序。当我启动我刚刚下载的项目的新 exe 文件时,它会生成以下错误: 05:37:59: Loading library
我已经成功编译并运行了 ogre3d.org 中提到的教程。它编译没有任何错误。 在那个教程中我使用了 http://www.ogre3d.org/tikiwiki/tiki-index.php?pa
我想做的是拥有一个应用程序(我目前正在使用示例框架应用程序)并在其中包含任何 ogre 库文件,而不是为整个系统安装它。这样一来,我就可以轻松地将应用程序移植到其他计算机上。 我使用的是 Mac OS
我正在开发将实时 View 设置为窗口背景的 Ogre 应用程序。 Hovewer 当我尝试使用 RenderTarget::getAverageFPS() 获取我的应用程序的帧速率时我有疑问,然后我
我正在尝试使用下面给出的代码将 Ogre 嵌入到 Qt 中: https://github.com/gklingler/QOgreWidget 它在我的系统上运行良好,没有任何问题,但是当我尝试在我的
在 CodeBlocks 中尝试在 linux 下编译时我得到 cannot find -lOgreMain_d 和 cannot find -lOIS_d. 在我的链接器设置下 /usr/lib/l
我已经使用 Code::Blocks 构建 Ogre 并将其安装到我的 Debian 中。接下来,我尝试编译教程应用程序,但出现以下错误: obj/Debug/BaseApplication.o: I
我是一名优秀的程序员,十分优秀!