Форум

Сообщения, созданные пользователем Евгений Родыгин
29 декабря 2015 18:48
Hello.
1. Does Blend4Web use the frame rate of a .blend to determine the refresh rate in the browser? Since animation playback speed is determined by frame rate I imagine it is important to pay attention to. However, I also realize that games are different from video, and more latency can occur depending on how heavy part of a level is.
If you speak about frames per second (FPS), Blend4Web tries to refresh as fast as possible.
blend framerate settings are used only for animation. So if you will use 60 fps, instead of 24, all animations will be almost thrice faster. And it will be the same speed no matter what FPS a user currently have.

3. Does frame rate play a role in the synchronization of game music?
No. Only animations are affected.
18 декабря 2015 14:21
Добрый день,

Создаю Куб (вернее, не удаляю первоначальный), также назначаю материал, в свойствах материала ставлю галочку "Special: Collision", пытаюсь выбрать "Physics" - "Object Physics", "Physics Type" - "Character" и получаю предупреждение - "unsupported physics type"
Для динамических физических объектов не нужно добавлять физический материал. Требуется только выбрать в настройках физики соответствующий "Physics Type". Об этом можно прочитать в документации. В вашем случае физический материал все-равно переопределиться физикой объекта, но лучше этот материал убрать с персонажа, чтобы не было путаницы.
Блендеровский Character действительно у нас не поддерживается, и используется свой Character. Возможно, в будущих релизах перейдем на блендеровскую модель.

Вроде все ОК, экспортирую как "first-person.json" прямо в копию каталога firstperson (с заменой) и получается мелькающая картинка с кубом, который бегает по всему экрану
Здесь нужно посмотреть в консоль. Она скажет, что у камеры неверный тип. Приложение firstperson писалось для камеры типа EYE. Именно этот тип вам и нужно выставить.

И ещё один момент. На статической физике (плоскость Plane) следует применить Scale, иначе будет использоваться меш с уменьшенным размером.
15 декабря 2015 19:13
Hello.
Also i was wondering how do i add a .JS file (obviously i can do that ) and make blender be aware of it when i export the scene???
Do i have to add the link in the HTML file every time???
You don't need to aware Blender about JavaScript code. When you prepared and exported some assets, you have to process them in your application, which consists of html and js files.
The best approach for creating a new project is to use Project Manager. It will do all dirty work for you.
Here is a video by Will Welker. He uses such an approach here.
15 декабря 2015 10:53
Evgeny, thank you so much for the explanation and example! This helps a lot.
You are welcome.
In what sort of cases should I choose to bundle my project? (What criteria should I base the decision on?)
And can a project that isn't bundled be converted to a bundled one later? Can we switch between these modes?
Generally, bundled projects are good for small projects. If you use this method, this means you are not going to make any changes to the b4w engine or write some additional modules for it. Also, you won't be able to compile a bundled project (obfuscate it and increase the performance a bit).

All this can be done with a non-bundled project. But it has a bit more complex structure.
Conversation is not possible because project manager doesn't know the exact structure of your application. But you can convert the project by yourself. You'll need to change the scripts paths in html files and put required assets to the required destination. But anyway it would be better to create a new project and just place source files to corresponding locations.
14 декабря 2015 20:12
When I created this project from the Project Manager I checked the 'Bundled Project' option. Was that the right thing to do? I still don't understand exactly what this option is bundling or where it bundles it.
This checkbox means that your project won't use external js files from blend4web/apps_dev/folder and asset files from /blend4web/deploy/assets and will use its own internal structure. All scripts and assets would be searched for in the local folder.
14 декабря 2015 20:05
Hello,

First of all, you've put new methods like setup_rotation, setup_jumping etc outside the module definition. They should be under the b4w.register function. Otherwise there'll be a problem with namespaces.
Another important issue is that you put enable_controls to the init_cb section. There are no controllable elements at this stage. Thus, it should be placed to the load_cb section. Also, if you want to control the camera the enable_camera_controls call is required.

The final js should look like this:
"use strict"

if (b4w.module_check("project_test002"))
    throw "failed to register module: project_test002";

b4w.register("project_test002", function(exports, require) {

var m_anim  = require("animation");
var m_app   = require("app");
var m_main  = require("main");
var m_data  = require("data");
var m_ctl   = require("controls");
var m_phy   = require("physics");
var m_cons  = require("constraints");
var m_scs   = require("scenes");
var m_trans = require("transform");
var m_cfg   = require("config");

var _character;
var _character_rig;

var rot_speed = 1.5;
var camera_offset = new float32array([0, 1.5, -4]);

exports.init = function() {
    m_app.init({
        canvas_container_id: "canvas3d",
        callback: init_cb,
        physics_enabled: true,
        alpha: false,
        physics_uranium_path: "uranium.js"
    });
}

function init_cb(canvas_elem, success) {

    if (!success) {
        console.log("b4w init failure");
        return;
    }

    window.addeventlistener("resize", on_resize);

    load();
}

function on_resize() {
    m_app.resize_to_container();
};

function load() {
    m_data.load("project_test002.json", load_cb);
}

function load_cb(root) {
    m_app.enable_controls();
    m_app.enable_camera_controls();
}

function setup_rotation() {
    var key_a     = m_ctl.create_keyboard_sensor(m_ctl.key_a);
    var key_d     = m_ctl.create_keyboard_sensor(m_ctl.key_d);
    var key_left  = m_ctl.create_keyboard_sensor(m_ctl.key_left);
    var key_right = m_ctl.create_keyboard_sensor(m_ctl.key_right);

    var elapsed_sensor = m_ctl.create_elapsed_sensor();

    var rotate_array = [
        key_a, key_left,
        key_d, key_right,
        elapsed_sensor
    ];

    var left_logic  = function(s){return (s[0] || s[1])};
    var right_logic = function(s){return (s[2] || s[3])};

    function rotate_cb(obj, id, pulse) {

        var elapsed = m_ctl.get_sensor_value(obj, "left", 4);

        if (pulse == 1) {
            switch(id) {
            case "left":
                m_phy.character_rotation_inc(obj, elapsed * rot_speed, 0);
                break;
            case "right":
                m_phy.character_rotation_inc(obj, -elapsed * rot_speed, 0);
                break;
            }
        }
    }

    m_ctl.create_sensor_manifold(_character, "left", m_ctl.ct_continuous,
        rotate_array, left_logic, rotate_cb);
    m_ctl.create_sensor_manifold(_character, "right", m_ctl.ct_continuous,
        rotate_array, right_logic, rotate_cb);
}

function setup_jumping() {
    var key_space = m_ctl.create_keyboard_sensor(m_ctl.key_space);

    var jump_cb = function(obj, id, pulse) {
        if (pulse == 1) {
            m_phy.character_jump(obj);
        }
    }

    m_ctl.create_sensor_manifold(_character, "jump", m_ctl.ct_trigger, 
        [key_space], function(s){return s[0]}, jump_cb);
}

function setup_camera() {
    var camera = m_scs.get_active_camera();
    m_cons.append_semi_soft_cam(camera, _character, camera_offset);
}

});
b4w.require("project_test002").init();


And don't forget to check the console output every time you run the application
07 декабря 2015 12:31
Hello and welcome to the forum!

Island demo is not the best example for your task. Petigor's Tale is a better choice. You can use similar camera constraints.

The most complicated part is physics. As there are no any flying presets in Bullet, I think, you should go with apply_force and apply_torque methods.

For example if you need a plane to move forward you should do something like this:
apply_force(plane_obj, 0, lifting_force, thrust_force)

Forces are applied in object's local space.

Anyway, this will require some experimentation. Wish luck to your project!
03 декабря 2015 14:46
Ответ на сообщение пользователя benoit-1842
Thank you for the answer !!! I will study further this .blend file. My question is more I am making bvh files with my kinect. Is it possible you think to have my character in blend4web in a html format and changing the animation from the html file and not passing at all from Blender. animated character as html file ———>changing the animation with a bvh file————-> having a new animation with the original html animated file.

Thanks for responding
Hello!
This can be done with our fresh bone api. You need to parse this bvh. For example, you can use this parser: https://github.com/hitsujiwool/bvh (I haven't tested it).

And then use following functions from b4w API:
This one for world space bones positioning.
And this for relative bones positioning.
03 декабря 2015 12:45
Hello,

Yes, this is a really acute problem and we have plans on making it easier to maintain changes made by users. The functions you described are a bit specific, so I'm not sure we'll put them into the original addon.
The best solution for now is to have your own some_addon.js which will implement required functionality. Thus, you won't need any updates when upgrading to a new b4w version.
02 декабря 2015 19:21
Ответ на сообщение пользователя jumpeak
Какая по модулю сила гравитации действует на объект единичной массы? Почему объект, оторванный от поверхности с помощью apply_force после обнуления силы продолжает некоторое время движение по инерции и потом "зависает в воздухе" - не падает, как будто теряет гравитацию, при этом его по прежнему можно двигать с помощью приложения сил. Как работает демпфирование движения объекта "в воздухе" т.е. в свободном полёте без столкновений и без приложения сил?
Я полагаю, что объект "засыпает". Можно попробовать включить опцию "Do not sleep" на этом объекте. А вообще это вопрос для отдельной темы. Нужно протестировать такое поведение.
Демпфирование снижает скорость независимо от того, есть столкновения с другими объектами или нет. Может быть, сам термин не совсем корректный, но так решили разработчики блендера =)