Jump to content

How to use 3D model in already existing scene


yerzhik
 Share

Recommended Posts

As it says in tutorials, if I am using some model I can load scene by using:

BABYLON.SceneLoader.Load("", "scene.babylon", engine, function (newScene) {  // Wait for textures and shaders to be ready  newScene.executeWhenReady(function () {  // Attach camera to canvas inputs  newScene.activeCamera.attachControl(canvas);  // Once the scene is loaded, just register a render loop to render it  engine.runRenderLoop(function() {  newScene.render();  });  });  }, function (progress) {    // To do: give progress feedback to user});

But I already have one scene and objects on it. How can I add that 3D object with several duplications to existing scene, with collisions supported?

Link to comment
Share on other sites

Try this : 

 

http://www.html5gamedevs.com/topic/3200-pick-mesh-in-the-scene/?p=20710

 

Importmesh imports a specific mesh in an existing scene. If you want to import all meshes from an existing 3D model, your first parameter shoulod be an empty string ("")

Thank you, it worked. But how about collisions?

Usually the physics is done by calling:

 

box.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 2, friction: 0.4, restitution: 0.3 });

 

But in case of a non standard figure, is there a way to create Impostor for a 3D model?

Link to comment
Share on other sites

I would try to create a compound impostor : http://blogs.msdn.com/b/eternalcoding/archive/2013/12/19/create-wonderful-interactive-games-for-the-web-using-webgl-and-a-physics-engine-babylon-js-amp-cannon-js.aspx

 

It depends of your 3D model, but try to get several simple impostors (box or sphere) attached to your model.

For example, a character can have a sphere impostor linked to its head, a box character linked to its body, ...

 

It won't be pixel perfect (as you said, very time-consuming) but it will do the trick.

 

You can check this too : http://www.andybeaulieu.com/Home/tabid/67/EntryID/238/Default.aspx

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...