Jump to content

position particle on a loaded mesh vertex


al404
 Share

Recommended Posts

I'm loading a mesh exported from blender with 

BABYLON.SceneLoader.ImportMesh("", "../3d-models/", "model.babylon", scene, function (newMeshes) 

i than access my mesh

myimportedmesh = newMeshes[0];

and count vertices

var verticesCount = myimportedmesh.getTotalVertices();

i see almost 9000 vertices if a log to console verticesCount that is about the sam number displayed from blander

i than create a SolidParticleSystem of 9000 

this works correctly but i don't know how to retrive vertex position so i can position my particles on my loaded mesh vertices

create something similar from example and i used a sphere instead of my loaded mesh

http://www.babylonjs-playground.com/#1LIVJD#1

what i can't understand how to do it is hot to retrive vertices position

I also try with sps.digest(); but i get a javascript error: SPS.digest is not a function

Im not even sure that digest can do what i expect

 

the other thing i don't know how to do is assigned a name or an id to each particle, i need to retrive that on click

Link to comment
Share on other sites

[EDITED]

quite difficult to understand without a playground

anyway ... if you create a SPS with addShape(model, 9000), this will create 9000 particles similar to your model. It is to say that if your model has 9000 vertices, you'll get a sps mesh of 9000 * 9000 vertices !!!

If you want to transform a 9000 vertices mesh in a sps, you have to use digest(model). The sps mesh will be built with the same geometry than the mesh model, it is to say that each of its particles will be set in the (mesh local) space at the same positions than the subparts of the model.

You can then read each particle position property what will be set for you by the method digest().

If you have an original mesh with 9000 vertices already set at the right position, I guess you need digest() to transform it into a particle system in a single call ;-)

Everything is documented, with examples, here : http://doc.babylonjs.com/overviews/Solid_Particle_System

In the sps, each particle is pickable (please read the pickability part in the doc) and you can access its ID.

You can set every of your own property (like a name if you want) to each particle whenever you want, say, maybe in initializeParticles(). Well, a solid particle is just a JS object, it's extensible dynamically as you need.

 

Link to comment
Share on other sites

i download this example

http://www.babylonjs-playground.com/#HDHQN

that load babylon.js from here http://www.babylonjs.com/babylon.js

if i switch to the version i used for my test i also get the same error "sps-digest.html:68 Uncaught TypeError: sps.digest is not a function"

i did download babylon from github not more than a week ago, i use the /script-library/Babylon.js-master/dist/babylon.2.3.js i also try with the max version

is it a bug or i'm missing something?

 

Link to comment
Share on other sites

did you download the BJS core version ? the SPS is in the full version... the core version is a very light one.

anyway if you search for the word "digest" here : http://www.babylonjs.com/babylon.js  you'll find it ;-) and this is the lone method called like this in the whole framework

 

but you are right the digest() method is not in the 2.3 version, this feature is added in the forthcoming 2.4 only : https://github.com/BabylonJS/Babylon.js/blob/master/dist/preview%20release/what's%20new.md

Link to comment
Share on other sites

from what i read and seen in examples particles in this case ( with digest function ) are the "skin" ok a mesh split in pieces = particles 

i need to position little circles / dots or little spheres on my mash to cover it, and i guess this is not possible with digest

Link to comment
Share on other sites

yes, digest() decomposes the mesh in facets or group of facets

if you want dots or circles or any solid particles, you should then build them first as models, then add them to the sps with addShape() and finally set their positions that you could retrieve with getVerticesData() applied to the big mesh whom you want to get the geometry 

Link to comment
Share on other sites

7 hours ago, JohnK said:

@al404  if you are going to place a particle for each vertex then you need plenty of vertices. In the following playground I have added them by increasing the number of segments from 10 to 50 (line 11) and converting the mesh to flatshaded ( line 13).

http://www.babylonjs-playground.com/#1LIVJD#2

wow this really looks cool, i'm loading a mesh exported from blander and i guess is not possible to increase vertex after loading, but i'm not sure

thanks, for the examples 

Link to comment
Share on other sites

Check out the function increasedFacets http://doc.babylonjs.com/extensions/Fur#meshes-where-the-number-of-facets-is-not-user-controlled-on-creation

This will increase the number of facets of an existing mesh and so also the number of vertices.  To get a good spread of vertices you will probably find it better, for example, to do

increasedFacets(mesh, 10)
increasedFacets(mesh, 10)

rather than

increasedFacets(mesh, 100)

 

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...