Particle Mesh -> Polygons

Particle Mesh -> Polygons

Hi,
I would like to convert a particle mesh into a set of independent editable objects. Tools/Particle/Particle->Polygon converts the particle mesh into one object, splitting which would be a hard task. Is there a work around?
 
I have written a script that should do just what I want: it takes a particle mesh as a parameter, then it iterates through the particles, takes particle mesh children in order, copy them, and apply particle position, rotation and scale.

The only problem is that I can not make rotation work correctly: no matter what I do the meshes created with my script have correct position but incorrect orientation in 3d space. Could someone help me please?

I have attached the script and two files: one before script is used, one after.

PS the script should go int ~/Library/Application Support/Cheetah3D/Scripts/Tools When you run the script you should drop the particle mesh with at least one child on it.
 

Attachments

  • Archive.zip
    139.1 KB · Views: 362
Can't look at your code right now. Perhaps it's simply the wrong axis order. It's confusing with particles because they are XYZ whereas most objects (e.g. Meshes) are Heading (Y) pitch (X) bank (Z).

Good idea for a script BTW.
 
Thank you for your reply podperson! I have tried to switch X and Y rotation angles following your advice, and it almost worked: Some of the meshes are aligned properly, but some of them are still off (as you can see from the 'after.jas' in the attached archive). I wonder what I am missing?!
 

Attachments

  • Archive.zip
    139 KB · Views: 361
All right, I finally figured out the script: switching x and y rotation angles is not sufficient in general case, since z rotation is performed the last it is affected by the order of x and y rotation. The simple solution is to introduce an additional folder wrapping the instanciated object to perform z rotation correctly. Script and example are attached (in case if someone might need it). Thank you!
 

Attachments

  • Archive.zip
    192.4 KB · Views: 391
late follow up, though...

Hi,

nice script!

about rotation problem. from v6.0, new API is added for converting XYZ to HPB rotation. It seems to be undocumented at Help file. I used it BVH importer.js script.

Code:
Vec3D::convertEuler( int from_order, int to_order, [ rotation_hint ] );

// rot order constants: ROT_XYZ, ROT_XZY, ROT_YZX..., ROT_HPB

if you want convert XYZ to HPB, the codes will be..

Code:
var xyz_rot = new Vec3D( x, y, z );

var hpb_rot = xyz_rot.convertEuler( ROT_XYZ, ROT_HPB );

please try it for yours.

regards.

tg_jp, Hiroto
 
Thank you for your suggestion, however I could not make it work despite the fact that I have tried every possible combination of X, Y, Z
 
hi

I tried to modify your file with Vec3D::convertEuler function.

please check it. it seems to work as I expected..

regards.

tg_jp, Hiroto
 

Attachments

  • Particle Mesh -> Polygons_mod.js.zip
    1.7 KB · Views: 347
Hi, Hiroto,
thank you for the modified version. The new version of script looks very graceful, but it seems to have problems. In the attached test you can see that some of the cube particles orientation is correct, some of them are fine.
 

Attachments

  • mod_test.zip
    77.5 KB · Views: 331
Hi

you're right. I calculated result rotations with simply adding particle's rotation to copy object's rotation. It caused that problem.

I fixed it, so please check it.

modA: using folder for particle's geometry same as your original script.
modB: calculate combined rotation of particle and copy object from matrix.

I added some comments with my poor english, but please ask if you have any question.

BTW: I modified the script accept any particle object not only particle mesh. check line.9 :)

regards.

tg_jp, Hiroto
 

Attachments

  • Particle Mesh -> Polygons_modA.js.zip
    1.7 KB · Views: 385
  • Particle Mesh -> Polygons_modB.js.zip
    1.9 KB · Views: 388
Last edited:
Thank you, Hiroto,
modB is my favorite: I really like the fact that it is not creating unnecessary objects in the model.
 
Martin and/or Hiroto (or whomever),
I've been wondering about this for a while. When converting a particle mesh, some parameters don't translate, and I'm wondering about, especially, a parameter like "Random" in the "Aligned Particle Spline" particle script. If I use the "Random" setting (which is the default) instead of "Repeat" or "Sorted", the Particle Mesh->Polygons scripts seem to ignore that setting and force even distribution. Is that random setting at all accessible via scripting? I find I am almost always using "Random" and not having this translate to the poly-groups makes it unusable, at least as a 3D export (which, for me, is ideal).
Thanks in advance...

-cg
 
Back
Top