论坛

由用户创建的信息 Ivan Lyubovnikov
10 December 2015 10:19
Приведи, пожалуйста, пример, как это сделать для target камеры. Самому, с моим знанием js, пока не получается, появляется всё та же ошибка.

Ну как-то так:

var m_cam = require("camera");
var m_mouse = require("mouse");
var m_phy = require("physics");
var m_scs = require("scenes");

var _vec2_tmp = new Float32Array(2);

function rotation_cb(rot_x, rot_y) {
    var character = m_scs.get_first_character();
    var camera    = m_scs.get_active_camera();
    m_cam.target_rotate(camera, rot_x, rot_y);
    if (character) {
        var angles = m_cam.get_camera_angles_char(camera, _vec2_tmp);
        m_phy.set_character_rotation(character, angles[0], angles[1]);
    }
}

m_mouse.request_pointerlock(elem, null, null, null, null, rotation_cb);
08 December 2015 14:31

но не прыгает обезьянка…
Хмм, это похоже на баг, вообщем посмотрим. Конкретно с этим мешем сейчас заработает, если в настройках физики объекта выставить Bounds: Cylinder или Box.
08 December 2015 12:57
Ответ на сообщение пользователя trepaning
Using the B4W UI, I have one option for an audio source, no fallback. There is no one format for all browsers.

Hi, sorry for the late answer. A single HTML file can contain multiple media formats for the purpose to adapt to different browsers. The easiest way to create them is to use our SDK's converter. There is a "convert resources" operation available from the Project Manager: link. There is also a topic in the documentation about how to do the conversion through the console: link. Converted media files are placed near the original file.

And, finally, the export option "Export Converted Media" should be checked if you want to include all this media files into the resulting HTML.
08 December 2015 10:34

все просмотрел… вроде все так же…. а обезьяна не падает на пол как
У вас в функции load_cb() инициализируется режим управления камерой (enable_camera_controls) - он, видимо, конфликтует с режимом управления персонажем, который задаётся в setup_movement().

Закомментируйте строчку:
m_app.enable_camera_controls();

и должно заработать.
07 December 2015 10:37
С ошибкой разобрался. Видимо request_pointerlock по дефолту использует EYE камеру, а как его использовать с другими типами камер? Мне нужно вращать камеру вокруг разных объектов на сцене (с захватом указателя), как это лучше реализовать?

У request_pointerlock() есть параметр rotation_cb. По умолчанию используется вот этот: default_rotation_cb(). Можно переопределить для разных типов камер.
27 November 2015 16:14
идеально получить код цвета не суммы всех наложенных текстур, а отдельно цвет одного слоя uv текстуры, в которой будет просчитана освещённость
Вот, если модель не находится в видимости камеры, то это будет довольно сложно сделать.

По-честному, нужно рендерить эту точку из камеры и дальше брать нужный цвет. Можно попробовать рендеринг в текстуру из дополнительной сцены, которая будет как-то повторять главную сцену. Например, в дополнительной сцене зависаем над нужной точкой и берем цвет пикселя. Это может ударить по производительности, насколько сильно - зависит от конкретной сцены. Однако, при рендеринге доп. сцены можно хорошо снизить разрешение, т.к. в вашем случае важен не конечный результат, а цвет одной точки.

Если не по-честному, а имитацией, то тут надо знать специфику приложения/сцены/объектов/источников света. Освещение объекта, допустим, можно как-то сымитировать нодой Lamp Data и переключением в нодовом материале веток с основным материалом и подкрашиваемым при удалении на определённое расстояние (через set_nodemat_value()). А можно ещё попробовать извлечь массивы данных атрибутов из материала самого пола функцией extract_vertex_array(). Тогда, зная геометрию пола и позицию конкретной точки, можно было бы сопоставить остальные атрибуты и взять "сырое" значение из массива, соотвтетствующего uv-текстуре или вертексному цвету, и потом как-то применять освещение.

А вообще, такое подкрашивание больше похоже на сложный функционал, а не на оптимизацию.
27 November 2015 11:17
Если менять цвет материала затратно, можно ли влиять на вертексный цвет меша?
Не так уж затратно. Для стековых материалов можно воспользоваться функцией set_diffuse_color(). Для нодового - set_nodemat_rgb().
26 November 2015 18:23
Hi!

I am trying to have the ability to mask parts of objects out so that the background is visible where things are masked out.I use a static camera for my project so that makes things a bit easier.
The app user has to be able to "paint" on the canvas which would reveal the background behind the 3d objects.

I suppose that you're talking about some sort of eraser.

This can be done through using the canvas textures, which can be easily modified from your script.
I've made a simple example of how to use it. Try to move the mouse with the left button pressed and the cube will start to disappear.

The idea is to setup a canvas texture in the object's material and then modify it somehow. The main problem is to transform the mouse coordinates into the texture coordinates properly, so the "erasing" will happen right under the mouse cursor. It depends on how the application should work. If you have a constant point of view you can use a simple plane (with such material) which billboards to the camera and "reveals" the background - in this case it should be easy to transform the coordinates. You can try to use this material with a complex 3d-object (like the cube in the example) but it will be harder to achieve a satisfying result.
25 November 2015 18:23
Hi!

Does someone knows how I can get camera altitude and translation speed to dynamically display it ( like flights instruments ) ?

1) Transform API allows to obtain camera position: get_translation(). The second coordinate (Y) is the altitude.

2) Translation speed needs some calculation. You can use set_render_callback() method. In this callback you'll have the amount of time elapsed since the application started and the amount of time elapsed from the previous frame. Here goes the calculation: (camera translation since the previous frame)/(time elapsed since the previous frame).
25 November 2015 16:58
Проблема работает только на серваке. И только при версии 15.10
А в этом случае консоль какие-либо ошибки выдаёт? Можете ещё 15.11 попробовать, уже доступен релиз-кандидат.