User posts ovalence
14 November 2016 11:52
04 November 2016 16:54
04 November 2016 16:52
Hello, I tried again, but the yellowball (in the attached json file) does not collide with red ball, because they are static and I used "move local". And if I use rigid, they fall.
The balls should not fall since they are planets.
And then I decided to push up the blueball by 9.8 to achieve equilibrium but it looks like the engine is not working as it should be. There is a push going forward (y), I do not know where did it come from. I guess it is an engine bug.
Here is my code and it is also in the attachment.
The balls should not fall since they are planets.
And then I decided to push up the blueball by 9.8 to achieve equilibrium but it looks like the engine is not working as it should be. There is a push going forward (y), I do not know where did it come from. I guess it is an engine bug.
Here is my code and it is also in the attachment.
————————————————————————–
"use strict"
b4w.register("gravity_simulation", function(exports, require) {
var m_app = require("app");
var m_data = require("data");
var m_scs = require("scenes");
var m_obj = require("objects");
var m_trans = require("transform");
var m_phy = require("physics");
var m_ctl = require("controls");
var m_cfg = require("config");
var m_version = require("version");
var DEBUG = (m_version.type() === "DEBUG");
var obj;
var yellowplanet;
var blueplanet;
var elapsed_sensor;
exports.init = function() {
m_app.init({
canvas_container_id: "canvas_cont",
callback: init_cb,
physics_enabled: true,
show_fps: true,
alpha: false,
autoresize: true,
assets_dds_available: !DEBUG,
assets_min50_available: !DEBUG,
console_verbose: true
});
}
function init_cb(canvas_elem, success) {
if (!success) {
console.log("b4w init failure");
return;
}
load();
}
function load() {
m_data.load("gravity_simulation.json", load_cb);
}
var speed = 1;
function main_cb (obj, id) {
var elapsed = m_ctl.get_sensor_value(obj, id, 0);
//m_trans.set_translation(planet,2, 0, 0);
m_phy.apply_force(blueplanet,0,0,9.81,true)
m_trans.move_local(yellowplanet, speed*elapsed, 0, 0);
}
function load_cb(data_id) {
m_app.enable_camera_controls();
elapsed_sensor = m_ctl.create_elapsed_sensor();
m_ctl.create_sensor_manifold(null, "MAIN", m_ctl.CT_CONTINUOUS, [elapsed_sensor], null, main_cb);
yellowplanet = m_scs.get_object_by_name("Yellow");
blueplanet = m_scs.get_object_by_name("Blue");
//m_phy.apply_force_world(obj, 5, -1, 0)
//m_phy.apply_force(src_obj,0,9.8,9.8,false)
//m_trans.set_translation(obj,5, 0, 0);
}
//var loop = function () {
// requestAnimationFrame(loop);
//m_trans.set_translation(obj,2, 0, 0);
//m_phy.apply_force(src_obj,10,0,0,false)
//};
// requestAnimationFrame(loop);
});
b4w.require("gravity_simulation").init();
———————————————————————
28 October 2016 15:22
28 October 2016 15:15
Hello,
I needed the scene or world to have zero gravity (the objects, or the balls I created from Blender should not fall).
If I set the objects as static in Blender, the set_translation does not work because the object should be dynamic.
But if I use dynamic/rigid, the objects fall (with gravity). I followed the example here.
I needed the scene or world to have zero gravity (the objects, or the balls I created from Blender should not fall).
If I set the objects as static in Blender, the set_translation does not work because the object should be dynamic.
But if I use dynamic/rigid, the objects fall (with gravity). I followed the example here.
28 October 2016 15:11
Hello,
I am making a simulation of planetary gravity, and so I needed the scene or world to have zero gravity.
If I set the objects as static the set_translation does not work because the object should be dynamic.
But if I use dynamic/rigid, the objects fall (with gravity). I followed the example here: https://www.blend4web.com/en/community/article/254/
But I wonder how you were able to do the translation??
I am making a simulation of planetary gravity, and so I needed the scene or world to have zero gravity.
If I set the objects as static the set_translation does not work because the object should be dynamic.
But if I use dynamic/rigid, the objects fall (with gravity). I followed the example here: https://www.blend4web.com/en/community/article/254/
But I wonder how you were able to do the translation??