GLGE API setRot/setRotX 不起作用

发布于 2024-12-09 07:12:26 字数 1275 浏览 0 评论 0原文

我正在尝试制作一个用于查看 3D 模型的小场景。

我修改了 GLGE Collada 示例以从代码添加 .dae 模型。

http://goleztrol.nl/SO/GLGE/01/

我是什么我有
到目前为止它有效。使用动画旋转相机。

使用“添加”和“删除”按钮,使用以下代码在场景中添加和删除模型(不要介意“鸭子”。在原始示例中它是一只鸭子。)

var duck = null;
function addDuck()
{
    if (duck) return;
    duck = new GLGE.Collada();

    doc.getElement("mainscene").addCollada(duck);

    duck.setId("duck");
    duck.setDocument("amyrose.dae");
    duck.setLocY(-15);
    duck.setRotX(1);
    duck.setScale(2);
}

function removeDuck()
{
    if (!duck) return;
    doc.getElement("mainscene").removeChild(duck);
    duck = null;
}

问题
现在模型是躺着的,而它应该站着。该元素的各种方法似乎都有效。位置已设置,比例已设置,但对 setRotX 的调用似乎被忽略。我尝试了 api 中的各种其他方法,但 setRotY、setRot、setQuatX 和 setDRotX 似乎都失败了。我没有收到任何错误(当然不是关于此方法的错误)。我尝试了 1.57 的值(应该约为 90 度),但也尝试了其他值,范围从 1 到 180。

我无法找出我做错了什么。当然,我可以在 Blender 中旋转模型本身,但我想使用 GLGE API 来完成。

更新
当我加载演示模型 seymourplane_triangulate.dae 时,旋转起作用了。显然我的模型的不同之处在于它不能旋转。我只是不明白为什么。我想这可能是因为模型是由各种单独的网格构建的,但我不明白为什么缩放和移动确实有效。

有谁知道这个模型有什么问题,以及我可以做些什么来修复它(也许使用 Blender)?

在包含场景的 XML 文件中设置初始旋转确实有效。在另一个元素(如整个场景)上设置旋转也有效。

I'm trying to make a little scene for viewing 3D models.

I modified the GLGE Collada example to add a .dae model from code.

http://goleztrol.nl/SO/GLGE/01/

What I've got
So far it works. The camera is rotated using an animation.

Using the buttons 'Add' and 'Remove' the model is added and removed from the scene, using the following code (Don't mind 'duck'. It was a duck in the original example.)

var duck = null;
function addDuck()
{
    if (duck) return;
    duck = new GLGE.Collada();

    doc.getElement("mainscene").addCollada(duck);

    duck.setId("duck");
    duck.setDocument("amyrose.dae");
    duck.setLocY(-15);
    duck.setRotX(1);
    duck.setScale(2);
}

function removeDuck()
{
    if (!duck) return;
    doc.getElement("mainscene").removeChild(duck);
    duck = null;
}

Problem
Now the model is lying down, while it should stand up. The various methods of the element seem to work. The location is set, and the scale is set, but the call to setRotX seems to be ignored. I tried various others methods from the api, but setRotY, setRot, setQuatX and setDRotX all seem to fail. I don't get any errors (well not about this method). I tried values of 1.57 (which should be about 90 degrees), but other values as well, ranging from 1 to 180.

I can't find out what I'm doing wrong. Of course I could rotate the model itself in Blender, but I'd like to do it using the GLGE API.

Update
When I load the demo-model, seymourplane_triangulate.dae, the rotation works. Apparently my model differs in that it cannot be rotated. I just don't understand why. I figured it may be because the model is built of various separate meshes, but I don't understand why scaling and moving does work.

Does anyone know what's wrong with this model, and what I could do to fix it (maybe using Blender)?

Setting an initial rotation in the XML file that contains the scene does work. Setting rotation on another element (like the whole scene) works as well.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冬天旳寂寞 2024-12-16 07:12:26

加载后您需要旋转它。

您可以在 setDocument 的回调中执行此操作

duck.setDocument("amyrose.dae", null, function() {
    duck.setLocY(-15);
    duck.setScale(2);
    duck.setRotX(0);
    duck.setRotY(0);
    duck.setRotZ(3);
});

You need to rotate it after it has been loaded.

You can do this in the callback to setDocument

duck.setDocument("amyrose.dae", null, function() {
    duck.setLocY(-15);
    duck.setScale(2);
    duck.setRotX(0);
    duck.setRotY(0);
    duck.setRotZ(3);
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文