对模型应用变换而不进行渲染
我正在为图形类构建光线追踪器,我们需要做的部分设置是在投射光线之前将模型缩放到世界空间。我已经构建了所需的 worldMatrix。然而,我第一次尝试转换模型的边界框的结果发生了变化,但 VertexBuffer 中的任何顶点都没有变化。
这是我的第一次尝试:
foreach (ModelBone b in model.Bones)
{
// apply the model transforms and the worldMatrix transforms to the bone
b.Transform = model.Root.Transform * worldMatrix;
}
我也尝试过设置模型网格中的效果值,就像每个模型绘图教程所示的那样,但没有效果。
我应该尝试其他方法来转换模型吗?
I'm working on building a ray tracer for a graphics class, part of the setup we are required to do is to scale the model into world space before casting my rays. I've built out the worldMatrix needed. However my first attempt at transforming results in the Bounding box of the model changing but none of the vertices in the VertexBuffer.
This is my first attempt:
foreach (ModelBone b in model.Bones)
{
// apply the model transforms and the worldMatrix transforms to the bone
b.Transform = model.Root.Transform * worldMatrix;
}
I've also tried setting the effect values found in the model meshes like every model drawing tutorial shows, but it is of no avail.
Is there some other way I should be attempting to transform the model?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
b.变换=根*世界;不考虑骨骼本身的任何数据。
可能你需要: b.Transform = root * b * world;
顶点缓冲区中的数据应在游戏/应用程序的整个生命周期中保持不变。发生的情况是,原始(未更改的)顶点数据在每一帧中都会通过您通过效果发送的任何不同的世界矩阵在顶点着色器中重新转换。
通常,它会是这样的:
b.Transform = root * world; doesn't take into account any data in the bone itself.
possibly you need: b.Transform = root * b * world;
The data in the vertex buffer should remain unchanged throughout the life of the game/app. What happens is that the original (unchanged) vertex data gets transformed in the vertex shader each frame anew by whatever different world matrix you send it through the effect.
Typically, it would go something like this: