KaiKostack / bullet-constraints-builder

Add-on for Blender to connect rigid bodies via constraints in a physical plausible way. (You only need the ZIP file for installation in Blender. Click the filename and at the next page "Download", right click and "Save As" won't work!)
https://inachuslaurea.wordpress.com
GNU General Public License v2.0
140 stars 21 forks source link

Export Constraints #4

Closed caco26i closed 6 years ago

caco26i commented 6 years ago

Can we export the model with constraints using the three js exporter?

KaiKostack commented 6 years ago

It doesn't look like the exporter would store rigid body settings, so you would end up with only the constraint locations in your export file but without its physical properties.

caco26i commented 6 years ago

What do you think that is the best way, modify the bullet-constraints-builder to add the settings of constraints as "userData" (the exporter will export this data) or modify the Three.js Blender Export to save the settings? I'm working on a project to simulate earthquakes using Three.js. I want to do something like Dom-Ino House Exposed to Earthquake using Dynamic Fracture. Thank you.

KaiKostack commented 6 years ago

For some reason exporting custom properties doesn't work for me with this exporter. Not entirely sure if this is a bug in the exporter but it seems to be the case as custom_properties(obj) appears never to be called. Anyways, if you can get this to work then you can write a custom script that copies all available rigid body and constraint settings into custom properties so that it can be exported using the exporter. Edit: The exporter exports custom properties only when the Scene checkbox is enabled, so it's working.

caco26i commented 6 years ago

I am learning, this is my first time with blender and I am using blender because I saw your plugin. I don't know how to do that, but i will read the documentation. Thank you.

KaiKostack commented 6 years ago

Blender is of course a large software to learn but it shouldn't be too difficult to realize such a script if you have some coding experience. You only have to find out all the attributes you need to copy which can be found in the context menu of each setting. Here is a short snippet for two settings to get the idea:

import bpy
objs = bpy.context.scene.objects
objs["Cube"]["mass"] = objs["Cube"].rigid_body.mass
objs["Constraint"]["breaking_threshold"] = objs["Constraint"].rigid_body_constraint.breaking_threshold