-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,840 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# ====================== BEGIN GPL LICENSE BLOCK ====================== | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software Foundation, | ||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
# | ||
# ======================= END GPL LICENSE BLOCK ======================== | ||
bl_info = { | ||
"name": "Molecular+", | ||
"author": | ||
"Jean-Francois Gallant (PyroEvil), " | ||
"Gregor Quade (u3dreal)", | ||
"version": (1, 12, 1), | ||
"blender": (2, 80, 0), | ||
"location": "Properties editor > Physics Tab", | ||
"description": | ||
"Addon for calculating collisions " | ||
"and for creating links between particles", | ||
"warning": "", # used for warning icon and text in addons panel | ||
"wiki_url": "http://q3de.com/research/molecular/", | ||
"tracker_url": "https://discord.gg/tAwvNEAfA3", | ||
"category": "Physics" | ||
} | ||
|
||
|
||
def register(): | ||
|
||
import bpy | ||
from . import properties, ui, operators, creators, addon_prefrences | ||
|
||
properties.define_props() | ||
|
||
for operator in operators.operator_classes: | ||
bpy.utils.register_class(operator) | ||
|
||
for panel in ui.panel_classes: | ||
bpy.utils.register_class(panel) | ||
|
||
for panel in creators.create_classes: | ||
bpy.utils.register_class(panel) | ||
|
||
bpy.utils.register_class(addon_prefrences.pref_classes) | ||
|
||
bpy.types.PHYSICS_PT_add.append(ui.append_to_PHYSICS_PT_add_panel) | ||
|
||
|
||
def unregister(): | ||
|
||
import bpy | ||
from . import ui, operators, creators, addon_prefrences | ||
|
||
bpy.types.PHYSICS_PT_add.remove(ui.append_to_PHYSICS_PT_add_panel) | ||
|
||
for operator in reversed(operators.operator_classes): | ||
bpy.utils.unregister_class(operator) | ||
|
||
for panel in reversed(ui.panel_classes): | ||
bpy.utils.unregister_class(panel) | ||
|
||
for panel in reversed(creators.create_classes): | ||
bpy.utils.unregister_class(panel) | ||
|
||
bpy.utils.unregister_class(addon_prefrences.pref_classes) | ||
|
||
if __name__ == "__main__": | ||
register() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import bpy | ||
from os.path import basename, dirname | ||
from bpy.types import AddonPreferences | ||
from bpy.props import IntProperty | ||
|
||
|
||
class MolecularAddonPreferences(AddonPreferences): | ||
bl_idname = __package__ | ||
|
||
log_size: IntProperty( | ||
name='Onscreen status size', | ||
default=25, | ||
min=1, | ||
max=200 | ||
) | ||
|
||
def draw(self, context): | ||
layout = self.layout | ||
row = layout.row() | ||
row.prop(self, "log_size") | ||
|
||
|
||
pref_classes = (MolecularAddonPreferences) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
import bpy | ||
|
||
|
||
class MolecularGrid3d(bpy.types.Operator): | ||
bl_idname = "molecular_operators.molecular_makegrid3d" | ||
bl_label = "Create Molecular 3d grid" | ||
bl_description = "Create / Set Gridobject 3d" | ||
bl_options = {'REGISTER'} | ||
|
||
def execute(self, context): | ||
|
||
voxel_size = context.scene.mol_voxel_size | ||
|
||
for obj in context.view_layer.objects.selected: | ||
init = False | ||
if obj.particle_systems.active == None: | ||
init = True | ||
bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) | ||
bpy.context.view_layer.objects.active = obj | ||
bpy.ops.object.particle_system_add() | ||
|
||
psys = obj.particle_systems.active.settings | ||
|
||
# ParticlsSystemSettings | ||
max_dim = max(obj.dimensions) | ||
|
||
psys.grid_resolution = int(max_dim/voxel_size) | ||
psys.particle_size = max_dim/psys.grid_resolution/2 | ||
psys.display_size = psys.particle_size/2 | ||
psys.hexagonal_grid = context.scene.mol_hexgrid | ||
psys.emit_from = 'VOLUME' | ||
psys.distribution = 'GRID' | ||
psys.normal_factor = 0.0 | ||
|
||
if init: | ||
psys.frame_start = 1 | ||
psys.frame_end = 1 | ||
psys.lifetime = 500 | ||
psys.grid_random = 0.02 | ||
psys.use_size_deflect = True | ||
psys.use_modifier_stack = True | ||
|
||
# Granular_Settings | ||
if not psys.mol_active: | ||
psys.mol_active = True | ||
|
||
psys.mol_selfcollision_active = True | ||
psys.mol_friction = 0.15 | ||
psys.mol_collision_damp = 0.25 | ||
psys.mol_link_length = 3.5 | ||
# update | ||
bpy.ops.object.reset_pcache() | ||
bpy.ops.object.mol_set_subs() | ||
|
||
return {'FINISHED'} | ||
|
||
|
||
class MolecularGrid2d(bpy.types.Operator): | ||
bl_idname = "molecular_operators.molecular_makegrid2d" | ||
bl_label = "Create Molecular 2d grid" | ||
bl_description = "Create / Set Gridobject 2d" | ||
bl_options = {'REGISTER'} | ||
|
||
def execute(self, context): | ||
|
||
voxel_size = context.scene.mol_voxel_size | ||
|
||
for obj in context.view_layer.objects.selected: | ||
init = False | ||
if obj.particle_systems.active == None: | ||
init = True | ||
bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) | ||
bpy.context.view_layer.objects.active = obj | ||
bpy.ops.object.particle_system_add() | ||
|
||
# ParctilsSystemSettings | ||
i = 1 | ||
for parsys in obj.particle_systems: | ||
parsys.name = "stack : " + str(i) | ||
psys = parsys.settings | ||
psys.name = "pstack : " + str(i) | ||
max_dim = max(obj.dimensions) | ||
psys.grid_resolution = int(max_dim/voxel_size) | ||
psys.particle_size = max_dim/psys.grid_resolution/2 | ||
psys.display_size = psys.particle_size/2 | ||
psys.hexagonal_grid = context.scene.mol_hexgrid | ||
psys.emit_from = 'FACE' | ||
psys.distribution = 'GRID' | ||
psys.normal_factor = 0.0 | ||
|
||
|
||
if init: | ||
psys.frame_start = i | ||
psys.frame_end = i | ||
psys.lifetime = 500 | ||
psys.grid_random = 0.02 | ||
psys.use_size_deflect = True | ||
psys.use_modifier_stack = True | ||
|
||
# Granular_Settings | ||
if psys.mol_active == False: | ||
psys.mol_active = True | ||
|
||
psys.mol_selfcollision_active = True | ||
psys.mol_othercollision_active = True | ||
psys.mol_friction = 0.15 | ||
psys.mol_collision_damp = 0.25 | ||
psys.mol_link_length = 2.1 | ||
|
||
i += 20 | ||
# update | ||
bpy.ops.object.reset_pcache() | ||
|
||
bpy.ops.object.mol_set_subs() | ||
|
||
return {'FINISHED'} | ||
|
||
class MolecularEmitter(bpy.types.Operator): | ||
bl_idname = "molecular_operators.molecular_makeemitter" | ||
bl_label = "Create Molecular Emitter object" | ||
bl_description = "Create / Set Emitter object" | ||
bl_options = {'REGISTER'} | ||
|
||
def execute(self, context): | ||
voxel_size = context.scene.mol_voxel_size | ||
|
||
for obj in context.view_layer.objects.selected: | ||
init = False | ||
if obj.particle_systems.active == None: | ||
init = True | ||
bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) | ||
bpy.context.view_layer.objects.active = obj | ||
bpy.ops.object.particle_system_add() | ||
|
||
psys = obj.particle_systems.active.settings | ||
|
||
# ParctilsSystemSettings | ||
max_dim = max(obj.dimensions) | ||
|
||
psys.grid_resolution = int(max_dim/voxel_size) | ||
psys.particle_size = voxel_size/2 | ||
psys.display_size = voxel_size/4 | ||
psys.hexagonal_grid = context.scene.mol_hexgrid | ||
psys.emit_from = 'FACE' | ||
psys.distribution = 'RAND' | ||
psys.normal_factor = 2.0 | ||
|
||
if init: | ||
psys.lifetime = 500 | ||
psys.count = 10000 | ||
psys.grid_random = 0.02 | ||
psys.use_size_deflect = True | ||
psys.use_modifier_stack = True | ||
psys.use_emit_random = True | ||
|
||
# Molecularular_Settings | ||
if psys.mol_active == False: | ||
psys.mol_active = True | ||
|
||
psys.mol_selfcollision_active = True | ||
psys.mol_othercollision_active = True | ||
psys.mol_friction = 0.15 | ||
psys.mol_collision_damp = 0.7 | ||
psys.mol_link_length = 2.1 | ||
|
||
# update | ||
bpy.ops.object.reset_pcache() | ||
bpy.ops.object.mol_set_subs() | ||
|
||
return {'FINISHED'} | ||
|
||
|
||
class MolecularCollider(bpy.types.Operator): | ||
bl_idname = "molecular_operators.molecular_makecollider" | ||
bl_label = "Create Molecular Collider object" | ||
bl_description = "Create / Set Collider object" | ||
bl_options = {'REGISTER'} | ||
|
||
def execute(self, context): | ||
for obj in context.view_layer.objects.selected: | ||
bpy.context.view_layer.objects.active = obj | ||
bpy.ops.object.modifier_add(type='COLLISION') | ||
obj.collision.damping_factor = 0.5 | ||
obj.collision.friction_factor = 0.5 | ||
|
||
return {'FINISHED'} | ||
|
||
create_classes = (MolecularEmitter, MolecularCollider, MolecularGrid2d, MolecularGrid3d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Matter descriptions | ||
MATTER_CUSTOM = 'put your parameter below' | ||
MATTER_SAND = '1555kg per meter cu' | ||
MATTER_WATER = '1000kg per meter cu' | ||
MATTER_IRON = '7800kg per meter cu' | ||
|
||
# Properties descriptions | ||
ACTIVE = 'Activate molecular script for this particles system' | ||
REFRESH = 'Simple property used to refresh data in the process' | ||
|
||
DENSITY_ACTIVE = 'Control particle weight by density' | ||
MATTER = 'Choose a matter preset for density' | ||
DENSITY = 'Density of the matter kg/cube meter' | ||
|
||
SELF_COLLISION_ACTIVE = 'Activate self collsion between particles in the system' | ||
OTHER_COLLISION_ACTIVE = 'Activate collision with particles from others systems' | ||
FRICTION = 'Friction between particles at collision 0 = no friction , 1 = full friction' | ||
COLLISION_DAMPING = 'Damping between particles at collision 0 = bouncy , 1 = no collision' | ||
COLLISION_GROUP = 'Choose a collision group you want to collide with' | ||
|
||
LINKS_ACTIVE = 'Activate links between particles of this system' | ||
LINK_OTHER_ACTIVE = '' | ||
LINK_GROUP = '' | ||
LINK_RELATIVE_LENGTH = 'Activate search distance relative to particles radius' | ||
LINK_FRICTION = 'Friction in links , a kind of viscosity. Slow down tangent velocity. 0 = no friction , 1.0 = full of friction' | ||
LINK_LENGTH = 'Searching range to make a link between particles' | ||
LINK_TENSION = 'Make link bigger or smaller than it\'s created (1 = normal , 0.9 = 10% smaller , 1.15 = 15% bigger)' | ||
LINK_TENSION_RANDOM = 'Tension random' | ||
LINK_MAX = 'Maximum of links per particles' | ||
LINK_STIFFNESS = 'Stiffness of links between particles' | ||
LINK_STIFFNESS_RANDOM = 'Random variation for stiffness' | ||
LINK_STIFFNESS_EXPONENT = 'Give a exponent force to the spring links' | ||
LINK_DAMPING = 'Damping effect on spring links' | ||
LINK_DAMPING_RANDOM = 'Random variation on damping' | ||
LINK_BROKEN = 'How much link can stretch before they broken. 0.01 = 1% , 0.5 = 50% , 2.0 = 200% ...' | ||
LINK_BROKEN_RANDOM = 'Give a random variation to the stretch limit' | ||
LINK_SAME_VALUE = 'When active , expansion and compression of the spring have same value' | ||
LINK_EXPENSION_STIFFNESS = 'Expension stiffness of links between particles' | ||
LINK_EXPENSION_STIFFNESS_RANDOM = 'Random variation for expansion stiffness' | ||
LINK_EXPENSION_STIFFNESS_EXPONENT = 'Give a exponent force to the expension spring links' | ||
LINK_EXPENSION_DAMPING = 'Damping effect on expension spring links' | ||
LINK_EXPENSION_DAMPING_RANDOM = 'Random variation on expension damping' | ||
LINK_EXPENSION_BROKEN = 'How much link can expand before they broken. 0.01 = 1% , 0.5 = 50% , 2.0 = 200% ...' | ||
LINK_EXPENSION_BROKEN_RANDOM = 'Give a random variation to the expension stretch limit' | ||
|
||
RELINK_GROUP = 'Choose a group that new link are possible' | ||
RELINK_CHANCE = 'Chance of a new link are created on collision. 0 = off , 100 = 100% of chance' | ||
RELINK_CHANCE_RANDOM = 'Give a random variation to the chance of new link' | ||
RELINK_TENSION = 'Make link bigger or smaller than it\'s created (1 = normal , 0.9 = 10% smaller , 1.15 = 15% bigger)' | ||
RELINK_TENSION_RANDOM = 'Tension random' | ||
RELINK_MAX = 'Maximum of links per particles' | ||
RELINK_STIFFNESS = 'Stiffness of links between particles' | ||
RELINK_STIFFNESS_RANDOM = 'Random variation for stiffness' | ||
RELINK_STIFFNESS_EXPONENT = 'Give a exponent force to the spring links' | ||
RELINK_DAMPING = 'Damping effect on spring links' | ||
RELINK_DAMPING_RANDOM = 'Random variation on damping' | ||
RELINK_BROKEN = 'How much link can stretch before they broken. 0.01 = 1% , 0.5 = 50% , 2.0 = 200% ...' | ||
RELINK_BROKEN_RANDOM = 'Give a random variation to the stretch limit' | ||
RELINK_SAME_VALUE = 'When active , expansion and compression of the spring have same value' | ||
RELINK_EXPENSION_STIFFNESS = 'Stiffness of links expension between particles' | ||
RELINK_EXPENSION_STIFFNESS_RANDOM = 'Random variation for expension stiffness' | ||
RELINK_EXPENSION_STIFFNESS_EXPONENT = 'Give a exponent force to the spring links' | ||
RELINK_EXPENSION_DAMPING = 'Damping effect on expension spring links' | ||
RELINK_EXPENSION_DAMPING_RANDOM = 'Random variation on damping' | ||
RELINK_EXPENSION_BROKEN = 'How much link can stretch before they broken. 0.01 = 1% , 0.5 = 50% , 2.0 = 200% ...' | ||
RELINK_EXPENSION_BROKEN_RANDOM = 'Give a random variation to the stretch limit' | ||
|
||
VAR_1 = 'Current number of particles to calculate substep' | ||
VAR_2 = 'Current substep' | ||
VAR_3 = 'Targeted number of particles you want to increase or decrease from current system to calculate substep you need to achieve similar effect' | ||
BAKE_UV = 'Bake uv when finish' | ||
|
||
TIME_SCALE_ACTIVE = 'Activate TimeScaling' | ||
TIME_SCALE = 'SpeedUp or Slow down the simulation with this multiplier' | ||
SUBSTEP = 'mol_substep. Higher equal more stable and accurate but more slower' | ||
BAKE = 'Bake simulation when finish' | ||
RENDER = 'Start rendering animation when simulation is finish. WARNING: It\'s freeze blender until render is finish' | ||
CPU = 'Numbers of cpu\'s included for process the simulation' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Labels text | ||
DENSITY = 'Density' | ||
COLLISION = 'Collision' | ||
LINKS = 'Links' | ||
INITIAL_LINKING = 'Initial Linking (at birth)' | ||
NEW_LINKING = 'New Linking (at collision)' | ||
UVS = 'UV\'s' | ||
SIMULATE = 'Simulate' | ||
CPU_USED = 'CPU used' | ||
MOLECULAR_TOOLS = 'Tools' | ||
PARTICLE_UV = 'Particle UV' | ||
SET_POSITION = 'Set current particles position' | ||
UV_HELP = 'Has global or current uv in angular velocity' | ||
CYCLES_HELP = 'Retrieve it with Cycles particle info node' | ||
SUBSTEPS_CALCULATOR = 'Substeps Calculator' | ||
THANKS = 'THANKS TO ALL DONATORS!' | ||
SUPPORT_WORK = 'If you want donate to support my work' | ||
VISIT = 'or visit:' | ||
SITE = 'www.q3de.com' |
Oops, something went wrong.