GLGE API setRot / setRotX不起作用 [英] GLGE API setRot/setRotX doesn't work

查看:163
本文介绍了GLGE API setRot / setRotX不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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;
}

问题

现在模特躺着,而它应该站起来。该元素的各种方法似乎都有效。设置位置,并设置比例,但似乎忽略了对setRotX的调用。我尝试了api中的各种其他方法,但是setRotY,setRot,setQuatX和setDRotX似乎都失败了。我没有得到任何错误(不是这个方法)。我尝试了1.57的值(应该是大约90度),但其他值也是1到180.

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.

我找不到我的意思我做错了。当然我可以在Blender中旋转模型本身,但我想使用GLGE API来完成。

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.

更新

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

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.

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

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

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

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.

推荐答案

您需要在加载后旋转它。

You need to rotate it after it has been loaded.

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

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);
});

这篇关于GLGE API setRot / setRotX不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆