gryff Posted June 8, 2014 Author Share Posted June 8, 2014 Here is a sample where this feature rocks Throws a lot of errors in my web console (around 85) and all look like this:Error: http://www.babylonjs.com/experiments/instances/Babylon/Math/babylon.math.js is being assigned a //# sourceMappingURL, but already has oneError: http://www.babylonjs.com/experiments/instances/Babylon/Tools/babylon.tools.tga.js is being assigned a //# sourceMappingURL, but already has oneError: http://www.babylonjs.com/experiments/instances/Babylon/Tools/babylon.tools.dds.js is being assigned a //# sourceMappingURL, but already has oneError: http://www.babylonjs.com/experiments/instances/Babylon/Tools/babylon.smartArray.js is being assigned a //# sourceMappingURL, but already has oneError: http://www.babylonjs.com/experiments/instances/Babylon/Tools/babylon.tools.js is being assigned a //# sourceMappingURL, but already has one....all the same comment but with a different script. Not sure why - but I do see a scene - hopefully all of it. cheers, gryff Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 9, 2014 Share Posted June 9, 2014 This is due to the fact that i published the source alongside sourcemap files I think Quote Link to comment Share on other sites More sharing options...
gryff Posted June 9, 2014 Author Share Posted June 9, 2014 I've been running some more tests to explore instancing. As I understand it the instances are copies of original geometry including the materials. In the image below (Blender screenshot) I have produced three linked duplicates of an object (the original is left most scaled red cube). I set the original object babylon property to "check collisions" and in Blender this cascades to the linked duplicates - a copy, Cube.001, highlighted in yellow, automatically has check collisions checked. Here is the babylon code for that original object and the instances - all seemed fine: {"name":"Cube","id":"Cube","materialId":"cube", "position":[-5.0000,0.0000,0.0000],"rotation":[-0.0000,-0.0000,0.0000],"scaling":[1.0000,1.0000,1.0000],"isVisible":true,"isEnabled":true,"useFlatShading":true,"checkCollisions":true,"billboardMode":0,"receiveShadows":false, "positions":[-0.1000,2.0000,1.0000,-0.1000,0.0000,-1.0000,-0.1000,2.0000,-1.0000,0.1000,2.0000,1.0000,-0.1000,0.0000,1.0000,0.1000,2.0000,-1.0000,0.1000,0.0000,1.0000,0.1000,0.0000,-1.0000] ,"normals":[-0.5773,0.5773,0.5773,-0.5773,-0.5773,-0.5773,-0.5773,0.5773,-0.5773,0.5773,0.5773,0.5773,-0.5773,-0.5773,0.5773,0.5773,0.5773,-0.5773,0.5773,-0.5773,0.5773,0.5773,-0.5773,-0.5773] ,"indices":[0,1,2,0,3,4,3,5,6,5,2,7,1,4,7,5,3,2,4,1,0,3,6,4,5,7,6,2,1,7,4,6,7,3,0,2] ,"subMeshes":[{"materialIndex":0,"verticesStart":0,"verticesCount":8,"indexStart":0,"indexCount":36}], "instances":[ {"name":"Cube.003","position":[0.0000,0.0000,-5.0000],"rotation":[-0.0000,-1.5708,0.0000],"scaling":[1.0000,1.0000,1.0000]}, {"name":"Cube.002","position":[0.0000,0.0000,5.0000],"rotation":[-0.0000,-1.5708,0.0000],"scaling":[1.0000,1.0000,1.0000]}, {"name":"Cube.001","position":[5.0000,0.0000,0.0000],"rotation":[-0.0000,-0.0000,0.0000],"scaling":[1.0000,1.0000,1.0000]}] } Only problem is that "check collisions" is true for only the original object not copies. If you are creating a forest (for example), it seems that all the "check collisions" would have to be set to true in code after the trees are loaded as the check collision checkbox in Blender for the linked duplicates is ignored. Any easy solution for this? No idea whether this will post as all the formating options are greyed out cheers, gryff Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 9, 2014 Share Posted June 9, 2014 I will fix this for you Quote Link to comment Share on other sites More sharing options...
gwenael Posted June 9, 2014 Share Posted June 9, 2014 and here comes the question: up to where an instance should be a perfect copy of a mesh? Do they share all properties (or the properties at least are synced) (physices, geometry...) except transform or some of them could/must be overriden? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 9, 2014 Share Posted June 9, 2014 Everything related to material and shaders is share. Everything else can be different (physics, collisions, etc,,,) Quote Link to comment Share on other sites More sharing options...
gryff Posted June 9, 2014 Author Share Posted June 9, 2014 "I will fix this for you"Thanks DK "up to where an instance should be a perfect copy of a mesh?" All I was trying to do gwenael was try to ensure that the babylon parameters (flat shading, check collisions etc) for export that could be set in the Blender were transferred to the babylon file. It does not export any animations that are attached to the original object that was duplicated for the duplicates - but those are not mentioned in the exporter parameters, so a work around would have to be found. I don't want to create work for DK (although he did ask further up this thread what features I might like to see for the Blender exporter - and I have a couple of those ) cheers, gryff Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 9, 2014 Share Posted June 9, 2014 Animations will also be cloned in the next version Quote Link to comment Share on other sites More sharing options...
gwenael Posted June 9, 2014 Share Posted June 9, 2014 It could be nice to have something parametrable: pretty much everything is cloned by default but you can use flags to clone only what you want. Quote Link to comment Share on other sites More sharing options...
gryff Posted June 9, 2014 Author Share Posted June 9, 2014 Well done DK - the new version of babylon.1.12-beta.js is passing on the "check collisions" parameter to the duplicates. Now lets see what I can do with it cheers, gryff GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
gryff Posted June 9, 2014 Author Share Posted June 9, 2014 Well a quick experiment, after I walked the dog, I can change the material on the original and it cascades to the duplicates. But altering the "checkCollisions" only impacts the original. I was kind of hoping that would cascade too without having to loop through all the copies. cheers, gryff Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted June 9, 2014 Share Posted June 9, 2014 Blender also has a use flat shading & cast shadows custom properties. Might want to do these, if wanted. Now avoid going back to edit the InstancedMesh class, I believe. Quote Link to comment Share on other sites More sharing options...
gryff Posted June 9, 2014 Author Share Posted June 9, 2014 Blender also has a use flat shading & cast shadows custom properties JC the "flat shading" is a property of the material - Scrap that JC it is "back face culling" that is a material property and any changes to the material seem to propagate.. I tried a test with the alpha value of material with this kind of code:theColour = newScene.getMaterialByName("cube");theColour.alpha = .5;and it sets all of them. Will test the flat shading. (Edit :tested and it seems to propagate). Not tried the shadow stuff. cheers, gryff Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted June 9, 2014 Share Posted June 9, 2014 mesh has the method convertToFlatShadedMesh(), not sure where it is called though. Looking closely at the python script, cast shadows property is used by the script to build the shadow generator for the lamp and does not end up in the mesh itself. The property is evaluated in the script for every lamp that has the custom shadow map property set. If it is true, the mesh gets added to the generators renderList. Implementing this might mean similar checking. Jeff Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 10, 2014 Share Posted June 10, 2014 Everything related to rendering is propagated (Because instances reference internally the root mesh)Change on checkCollisions is NOT propagated because you may want to set up on somes instances but not all Quote Link to comment Share on other sites More sharing options...
gryff Posted June 10, 2014 Author Share Posted June 10, 2014 Change on checkCollisions is NOT propagated because you may want to set up on somes instances but not all I had a feeling it might be that way. For the situation you hypothesis about, I would create two sets of instances with different checkCollision settings. With propagation I could easily flip their status. So for example nearby trees checkCollisions true, faraway trees checkCollisions false. If you enter that faraway area, flip the checkCollision properties of both. And experimenting with cast shadows - I'm getting some odd results. But more about that after more experiments. cheers, gryff Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 10, 2014 Share Posted June 10, 2014 In the meantime this is easy to browse all instances and set checkCollisions: mesh.instances Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 10, 2014 Share Posted June 10, 2014 And in your example (trees), you should keep only one root mesh and set all trees as instance of the same mesh to achieve maximum performance Quote Link to comment Share on other sites More sharing options...
gryff Posted June 10, 2014 Author Share Posted June 10, 2014 In the meantime this is easy to browse all instances and set checkCollisions: Will give that a try cheers, gryff Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.