Forum

Collision with or walking on bumpy terrain

13 March 2018 17:22
Dear Forum-Users
I have the following problem, I'm not able to solve: I have an uneven or bumpy terrain on which I want to "walk" in first person view. For this I created a capsule as character and set the camera to "eye". Everything is working fine exept that I don't know how to set up the properties, so that the "charakter" cannot move through the terrain. Normaly I would use the collision box set to "triangle mesh" but unfortunately this isn't supported by blend4web. Is there an other way to set this up?
For better understanding I attached a small example .blend file.
Thank you very much for any help :-)
13 March 2018 20:51
Under Materials->Special: Collision, your terrain material is set to "ghost". You must uncheck that box. ("Ghost" means collisions are ignored.)

An easy way to get all your settings right is to simply copy (or append) the materials/character settings from the B4W example "Jungle Outpost" because that is a First-Person terrain demo.
15 March 2018 18:35
Thanks very much for your answer.
Ok, now it works with one material. Problem is, I have a textured mesh with 4 materials. If I check the box "Special: Collision" on all four materials, the preview is loading just up to 74% then it stops. If I create a 5th material an check this box, it doesn't work, I can "walk" through the mesh. Is there a way how I could manage this?
And second: where can I chance the walking speed? Neither "Translation Velocity" in the camera-settings, nor "Walk Speed" in the character-settings have any effects. I saw this code in the "Jungle Outpost-Tutorial":


case "FORWARD":
move_state.forw_back = 1;
break;
case "BACKWARD":
move_state.forw_back = -1;
break;
case "LEFT":
move_state.left_right = 1;
break;
case "RIGHT":
move_state.left_right = -1;
break;


Here I think it would be possible to set not 1/-1 but 0.5/-0.5 as velocity, but I have no idea to which file this code belongs to.

Can someone maybe help me out here? Thanks very much for all tips
15 March 2018 18:57
Ok, now it works with one material. Problem is, I have a textured mesh with 4 materials. If I check the box "Special: Collision" on all four materials, the preview is loading just up to 74% then it stops

Could you show the web browser console output (F12)?
Alexander (Blend4Web Team)
twitter
15 March 2018 19:14
Thanks for your help :-)
here would be the console output of the web browser:

B4W LOG: INIT ENGINE 18.03 DEBUG (15.03.2018 17:08:50)
print.js:48
B4W LOG: USER AGENT: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
print.js:48
B4W LOG: INIT WEBGL 2
print.js:48
B4W LOG: GET EXTENSION WEBGL_debug_renderer_info
print.js:48
B4W LOG: RENDERER INFO: Google Inc., ANGLE (Intel(R) HD Graphics 530 Direct3D11 vs_5_0 ps_5_0)
print.js:48
B4W WARN: Firefox and WebGL 2 detected, applying framebuffer hack.
print.js:114
B4W WARN: Firefox detected, disabling multisample
print.js:114
B4W LOG: GET EXTENSION (WebGL 2) ANGLE_instanced_arrays
print.js:48
B4W LOG: GET EXTENSION (WebGL 2) OES_vertex_array_object
print.js:48
B4W LOG: GET EXTENSION (WebGL 2) WEBGL_depth_texture
print.js:48
B4W WARN: Firefox detected, disabling workers
print.js:114
B4W LOG: GET EXTENSION WEBGL_compressed_texture_s3tc
print.js:48
B4W LOG: GET EXTENSION EXT_texture_filter_anisotropic
print.js:48
B4W LOG: GET EXTENSION (WebGL 2) EXT_shader_texture_lod
print.js:48
B4W LOG: GET EXTENSION (WebGL 2) OES_texture_float
print.js:48
B4W LOG: GET EXTENSION (WebGL 2) OES_texture_half_float
print.js:48
B4W LOG: GET EXTENSION (WebGL 2) OES_texture_float_linear
print.js:48
B4W LOG: GET EXTENSION (WebGL 2) EXT_color_buffer_float
print.js:48
B4W LOG: SET PRECISION: highp
print.js:48
B4W LOG: LOAD METADATA ../../tmp/preview/preview.json?v=15032018170850
print.js:48
B4W LOG: LOAD BINARY ../../tmp/preview/preview.bin?v=15032018170850
print.js:48
B4W LOG: LOAD PHYSICS Using Same Thread, Max FPS: 60
print.js:48
B4W LOG: PHYSICS PATH /dist/uranium/uranium_wasm.js?v=15032018170852
print.js:48
B4W LOG: GET EXTENSION (WebGL 2) OES_standard_derivatives
print.js:48
B4W LOG: GET EXTENSION (WebGL 2) OES_element_index_uint
print.js:48
wasm streaming compile failed: TypeError: Response has unsupported MIME type
uranium_wasm.js:1:109285
falling back to ArrayBuffer instantiation
uranium_wasm.js:1:109285
B4W LOG: LOAD IMAGE 1024x1024 ../../projects/Aramus_2014/src/ftp030_unten_Agisoft3.jpg?v=15032018170853
print.js:48
B4W LOG: LOAD IMAGE 1024x1024 ../../projects/Aramus_2014/src/ftp030_unten_Agisoft2.jpg?v=15032018170853
print.js:48
B4W LOG: LOAD IMAGE 1024x1024 ../../projects/Aramus_2014/src/ftp030_unten_Agisoft1.jpg?v=15032018170853
print.js:48
B4W LOG: LOAD IMAGE 1024x1024 ../../projects/Aramus_2014/src/ftp030_unten_Agisoft.jpg?v=15032018170853
print.js:48
B4W LOG: LOADED ALL IMAGES
print.js:48
B4W LOG: PHYSICS READY
print.js:48
uncaught exception: abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 67108864, (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ") at jsStackTrace@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:1:123652
stackTrace@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:1:123823
abort@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:1:183042
abortOnCannotGrowMemory@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:1:124890
enlargeMemory@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:1:125246
wasm-function[768]@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:481674:1
wasm-function[691]@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:453206:1
wasm-function[549]@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:283263:1
wasm-function[670]@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:411890:1
wasm-function[548]@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:281828:1
wasm-function[38]@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:17340:1
b4w.module.__bindings/Module._du_create_mesh_shape@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:1:171475
append_static_mesh_body@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:1:57939
process_message@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:1:101135
preprocess_message_cb@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:1:25832
Int_IPC/exports.attach_handler/<@http://localhost:6687/dist/uranium/uranium_wasm.js?v=15032018170852:1:25935
postMessage@http://localhost:6687/tmp/viewer/b4w_app_bundle.js:99472:17
Int_IPC/exports.post_msg@http://localhost:6687/tmp/viewer/b4w_app_bundle.js:99835:9
init_static_mesh_physics@http://localhost:6687/tmp/viewer/b4w_app_bundle.js:29161:5
Int_physics/exports.append_object@http://localhost:6687/tmp/viewer/b4w_app_bundle.js:28680:27
add_physics_objects@http://localhost:6687/tmp/viewer/b4w_app_bundle.js:61222:25
process_stage@http://localhost:6687/tmp/viewer/b4w_app_bundle.js:86158:13
process_stages_queue@http://localhost:6687/tmp/viewer/b4w_app_bundle.js:86046:28
Int_loader/exports.update_scheduler@http://localhost:6687/tmp/viewer/b4w_app_bundle.js:85994:17
Int_data/exports.update@http://localhost:6687/tmp/viewer/b4w_app_bundle.js:58138:5
loop@http://localhost:6687/tmp/viewer/b4w_app_bundle.js:76689:9

If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.
Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 67108864, (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0
uranium_wasm.js:1:109200
Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 67108864, (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0


uhh think to less memory? I know the mesh and textures/materials are big but I wouldn't need it for games with much interacting, I would need it to show archaeological sites and that visitors could "walk" through some excavations… Is there a way to work with bigger datas?
16 March 2018 02:27
where can I change the walking speed?
The velocity is changed in Blender in the Physics->Character section of your character object. (You need to be in "B4W" render mode to see this.)

Or, via the API, the velocity is changed with physics module functions ("set_character_walk_velocity" etc.).

uhh think to less memory? I know the mesh and textures/materials are big but I wouldn't need it for games with much interacting, I would need it to show archaeological sites and that visitors could "walk" through some excavations… Is there a way to work with bigger datas?
Your mistake is probably that you have your complex terrain, complex objects with many polygons and complex materials and you set all that directly to collision. That's not the way to do it. Do it like this:

1. Make one new material in B4W mode and call it "collision" or "invisible walls". Set that material to "DOES NOT RENDER" and "COLLISION ON". That's your super-simple collision material for invisible walls. One material for the entire scene for everything that needs collision.

2. Don't set your complex, high-poly objects directly to collision. Rather, for every object that needs collision, make a second "invisible wall" version, a very simple approximation of the original object, and put that over the original object. Give that second object the collision material.

Please look at the Jungle Outpost example's .blend file to get the idea: You don't set the building itself to collision. You make a second, collision version:

 
Please register or log in to leave a reply.