Node Wrangler: Add more specific poll methods
[blender-addons.git] / render_povray / model_properties.py
blob300d5dbbe43f0460d8cddf6cbe1ca5a4b3b43cde
1 # SPDX-FileCopyrightText: 2021-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 """Declare object level properties controllable in UI and translated to POV"""
6 import bpy
7 from bpy.utils import register_class, unregister_class
8 from bpy.types import PropertyGroup
9 from bpy.props import (
10 BoolProperty,
11 IntProperty,
12 FloatProperty,
13 FloatVectorProperty,
14 StringProperty,
15 EnumProperty,
16 PointerProperty,
20 # ---------------------------------------------------------------- #
21 # Object POV properties.
22 # ---------------------------------------------------------------- #
25 class RenderPovSettingsObject(PropertyGroup):
26 """Declare object and primitives level properties controllable in UI and translated to POV."""
28 # Pov inside_vector used for CSG
29 inside_vector: FloatVectorProperty(
30 name="CSG Inside Vector",
31 description="Direction to shoot CSG inside test rays at",
32 precision=4,
33 step=0.01,
34 min=0,
35 soft_max=1,
36 default=(0.001, 0.001, 0.5),
37 options={"ANIMATABLE"},
38 subtype="XYZ",
41 # Importance sampling
42 importance_value: FloatProperty(
43 name="Radiosity Importance",
44 description="Priority value relative to other objects for sampling radiosity rays. "
45 "Increase to get more radiosity rays at comparatively small yet "
46 "bright objects",
47 min=0.01,
48 max=1.00,
49 default=0.50,
52 # Collect photons
53 collect_photons: BoolProperty(
54 name="Receive Photon Caustics",
55 description="Enable object to collect photons from other objects caustics. Turn "
56 "off for objects that don't really need to receive caustics (e.g. objects"
57 " that generate caustics often don't need to show any on themselves)",
58 default=True,
61 # Photons spacing_multiplier
62 spacing_multiplier: FloatProperty(
63 name="Photons Spacing Multiplier",
64 description="Multiplier value relative to global spacing of photons. "
65 "Decrease by half to get 4x more photons at surface of "
66 "this object (or 8x media photons than specified in the globals",
67 min=0.01,
68 max=1.00,
69 default=1.00,
72 # ----------------------------------- CustomPOV Code ----------------------------------- #
73 # Only DUMMIES below for now:
74 replacement_text: StringProperty(
75 name="Declared name:",
76 description="Type the declared name in custom POV code or an external .inc "
77 "it points at. Any POV shape expected e.g: isosurface {}",
78 default="",
81 # -------- POV specific object properties. -------- #
82 object_as: StringProperty(maxlen=1024)
84 imported_loc: FloatVectorProperty(
85 name="Imported Pov location", precision=6, default=(0.0, 0.0, 0.0)
88 imported_loc_cap: FloatVectorProperty(
89 name="Imported Pov location", precision=6, default=(0.0, 0.0, 2.0)
92 unlock_parameters: BoolProperty(name="Lock", default=False)
94 # not in UI yet but used for sor (lathe) / prism... pov primitives
95 curveshape: EnumProperty(
96 name="Povray Shape Type",
97 items=(
98 ("birail", "Birail", ""),
99 ("cairo", "Cairo", ""),
100 ("lathe", "Lathe", ""),
101 ("loft", "Loft", ""),
102 ("prism", "Prism", ""),
103 ("sphere_sweep", "Sphere Sweep", ""),
105 default="sphere_sweep",
108 mesh_write_as: EnumProperty(
109 name="Mesh Write As",
110 items=(("blobgrid", "Blob Grid", ""), ("grid", "Grid", ""), ("mesh", "Mesh", "")),
111 default="mesh",
114 object_ior: FloatProperty(name="IOR", description="IOR", min=1.0, max=10.0, default=1.0)
116 # shape_as_light = StringProperty(name="Light",maxlen=1024)
117 # fake_caustics_power = FloatProperty(
118 # name="Power", description="Fake caustics power",
119 # min=0.0, max=10.0,default=0.0)
120 # target = BoolProperty(name="Target",description="",default=False)
121 # target_value = FloatProperty(
122 # name="Value", description="",
123 # min=0.0, max=1.0,default=1.0)
124 # refraction = BoolProperty(name="Refraction",description="",default=False)
125 # dispersion = BoolProperty(name="Dispersion",description="",default=False)
126 # dispersion_value = FloatProperty(
127 # name="Dispersion", description="Good values are 1.01 to 1.1. ",
128 # min=1.0, max=1.2,default=1.01)
129 # dispersion_samples = IntProperty(name="Samples",min=2, max=100,default=7)
130 # reflection = BoolProperty(name="Reflection",description="",default=False)
131 # pass_through = BoolProperty(name="Pass through",description="",default=False)
132 no_shadow: BoolProperty(name="No Shadow", default=False)
134 no_image: BoolProperty(name="No Image", default=False)
136 no_reflection: BoolProperty(name="No Reflection", default=False)
138 no_radiosity: BoolProperty(name="No Radiosity", default=False)
140 inverse: BoolProperty(name="Inverse", default=False)
142 sturm: BoolProperty(name="Sturm", default=False)
144 double_illuminate: BoolProperty(name="Double Illuminate", default=False)
146 hierarchy: BoolProperty(name="Hierarchy", default=False)
148 hollow: BoolProperty(name="Hollow", default=False)
150 boundorclip: EnumProperty(
151 name="Boundorclip",
152 items=(
153 ("none", "None", ""),
154 ("bounded_by", "Bounded_by", ""),
155 ("clipped_by", "Clipped_by", ""),
157 default="none",
160 boundorclipob: StringProperty(maxlen=1024)
162 addboundorclip: BoolProperty(description="", default=False)
164 blob_threshold: FloatProperty(name="Threshold", min=0.00, max=10.0, default=0.6)
166 blob_strength: FloatProperty(name="Strength", min=-10.00, max=10.0, default=1.00)
168 res_u: IntProperty(name="U", min=100, max=1000, default=500)
170 res_v: IntProperty(name="V", min=100, max=1000, default=500)
172 contained_by: EnumProperty(
173 name="Contained by", items=(("box", "Box", ""), ("sphere", "Sphere", "")), default="box"
176 container_scale: FloatProperty(name="Container Scale", min=0.0, max=10.0, default=1.00)
178 threshold: FloatProperty(name="Threshold", min=0.0, max=10.0, default=0.00)
180 accuracy: FloatProperty(name="Accuracy", min=0.0001, max=0.1, default=0.001)
182 max_gradient: FloatProperty(name="Max Gradient", min=0.0, max=100.0, default=5.0)
184 all_intersections: BoolProperty(name="All Intersections", default=False)
186 max_trace: IntProperty(name="Max Trace", min=1, max=100, default=1)
188 # -------- Cylinder
189 def prop_update_cylinder(self, context):
190 """Update POV cylinder primitive parameters at creation and anytime they change in UI."""
191 if bpy.ops.pov.cylinder_update.poll():
192 bpy.ops.pov.cylinder_update()
194 cylinder_radius: FloatProperty(
195 name="Cylinder R", min=0.00, max=10.0, default=0.04, update=prop_update_cylinder
198 cylinder_location_cap: FloatVectorProperty(
199 name="Cylinder Cap Location",
200 subtype="TRANSLATION",
201 description="Position of the 'other' end of the cylinder (relative to object location)",
202 default=(0.0, 0.0, 2.0),
203 update=prop_update_cylinder,
206 imported_cyl_loc: FloatVectorProperty(
207 name="Imported Pov location", precision=6, default=(0.0, 0.0, 0.0)
210 imported_cyl_loc_cap: FloatVectorProperty(
211 name="Imported Pov location", precision=6, default=(0.0, 0.0, 2.0)
214 # -------- Sphere
215 def prop_update_sphere(self, context):
217 """Update POV sphere primitive parameters at creation and anytime they change in UI."""
219 if bpy.ops.pov.sphere_update.poll():
220 bpy.ops.pov.sphere_update()
222 sphere_radius: FloatProperty(
223 name="Sphere radius", min=0.00, max=10.0, default=0.5, update=prop_update_sphere
226 # -------- Cone
227 def prop_update_cone(self, context):
229 """Update POV cone primitive parameters at creation and anytime they change in UI."""
231 if bpy.ops.pov.cone_update.poll():
232 bpy.ops.pov.cone_update()
234 cone_base_radius: FloatProperty(
235 name="Base radius",
236 description="The first radius of the cone",
237 default=1.0,
238 min=0.01,
239 max=100.0,
240 update=prop_update_cone,
243 cone_cap_radius: FloatProperty(
244 name="Cap radius",
245 description="The second radius of the cone",
246 default=0.3,
247 min=0.0,
248 max=100.0,
249 update=prop_update_cone,
252 cone_segments: IntProperty(
253 name="Segments",
254 description="Radial segmentation of proxy mesh",
255 default=16,
256 min=3,
257 max=265,
258 update=prop_update_cone,
261 cone_height: FloatProperty(
262 name="Height",
263 description="Height of the cone",
264 default=2.0,
265 min=0.01,
266 max=100.0,
267 update=prop_update_cone,
270 cone_base_z: FloatProperty()
272 cone_cap_z: FloatProperty()
273 # -------- Generic isosurface
274 isosurface_eq: StringProperty(
275 name="f (x,y,z)=",
276 description="Type the POV Isosurface function syntax for equation, "
277 "pattern,etc. ruling an implicit surface to be rendered",
278 default="sqrt(pow(x,2) + pow(y,2) + pow(z,2)) - 1.5",
280 # -------- Parametric
281 def prop_update_parametric(self, context):
283 """Update POV parametric surface primitive settings at creation and on any UI change."""
285 if bpy.ops.pov.parametric_update.poll():
286 bpy.ops.pov.parametric_update()
288 u_min: FloatProperty(name="U Min", description="", default=0.0, update=prop_update_parametric)
290 v_min: FloatProperty(name="V Min", description="", default=0.0, update=prop_update_parametric)
292 u_max: FloatProperty(name="U Max", description="", default=6.28, update=prop_update_parametric)
294 v_max: FloatProperty(name="V Max", description="", default=12.57, update=prop_update_parametric)
296 x_eq: StringProperty(
297 maxlen=1024, default="cos(v)*(1+cos(u))*sin(v/8)", update=prop_update_parametric
300 y_eq: StringProperty(
301 maxlen=1024, default="sin(u)*sin(v/8)+cos(v/8)*1.5", update=prop_update_parametric
304 z_eq: StringProperty(
305 maxlen=1024, default="sin(v)*(1+cos(u))*sin(v/8)", update=prop_update_parametric
308 # -------- Torus
310 def prop_update_torus(self, context):
312 """Update POV torus primitive parameters at creation and anytime they change in UI."""
314 if bpy.ops.pov.torus_update.poll():
315 bpy.ops.pov.torus_update()
317 torus_major_segments: IntProperty(
318 name="Segments",
319 description="Radial segmentation of proxy mesh",
320 default=48,
321 min=3,
322 max=720,
323 update=prop_update_torus,
326 torus_minor_segments: IntProperty(
327 name="Segments",
328 description="Cross-section segmentation of proxy mesh",
329 default=12,
330 min=3,
331 max=720,
332 update=prop_update_torus,
335 torus_major_radius: FloatProperty(
336 name="Major radius",
337 description="Major radius",
338 min=0.00,
339 max=100.00,
340 default=1.0,
341 update=prop_update_torus,
344 torus_minor_radius: FloatProperty(
345 name="Minor radius",
346 description="Minor radius",
347 min=0.00,
348 max=100.00,
349 default=0.25,
350 update=prop_update_torus,
353 # -------- Rainbow
354 arc_angle: FloatProperty(
355 name="Arc angle",
356 description="The angle of the raynbow arc in degrees",
357 default=360,
358 min=0.01,
359 max=360.0,
362 falloff_angle: FloatProperty(
363 name="Falloff angle",
364 description="The angle after which rainbow dissolves into background",
365 default=360,
366 min=0.0,
367 max=360,
370 # -------- HeightFields
372 quality: IntProperty(name="Quality", description="", default=100, min=1, max=100)
374 hf_filename: StringProperty(maxlen=1024)
376 hf_gamma: FloatProperty(name="Gamma", description="Gamma", min=0.0001, max=20.0, default=1.0)
378 hf_premultiplied: BoolProperty(name="Premultiplied", description="Premultiplied", default=True)
380 hf_smooth: BoolProperty(name="Smooth", description="Smooth", default=False)
382 hf_water: FloatProperty(
383 name="Water Level", description="Wather Level", min=0.00, max=1.00, default=0.0
386 hf_hierarchy: BoolProperty(name="Hierarchy", description="Height field hierarchy", default=True)
388 # -------- Superellipsoid
389 def prop_update_superellipsoid(self, context):
391 """Update POV superellipsoid primitive settings at creation and on any UI change."""
393 if bpy.ops.pov.superellipsoid_update.poll():
394 bpy.ops.pov.superellipsoid_update()
396 se_param1: FloatProperty(name="Parameter 1", description="", min=0.00, max=10.0, default=0.04)
398 se_param2: FloatProperty(name="Parameter 2", description="", min=0.00, max=10.0, default=0.04)
400 se_u: IntProperty(
401 name="U-segments",
402 description="radial segmentation",
403 default=20,
404 min=4,
405 max=265,
406 update=prop_update_superellipsoid,
409 se_v: IntProperty(
410 name="V-segments",
411 description="lateral segmentation",
412 default=20,
413 min=4,
414 max=265,
415 update=prop_update_superellipsoid,
418 se_n1: FloatProperty(
419 name="Ring manipulator",
420 description="Manipulates the shape of the Ring",
421 default=1.0,
422 min=0.01,
423 max=100.0,
424 update=prop_update_superellipsoid,
427 se_n2: FloatProperty(
428 name="Cross manipulator",
429 description="Manipulates the shape of the cross-section",
430 default=1.0,
431 min=0.01,
432 max=100.0,
433 update=prop_update_superellipsoid,
436 se_edit: EnumProperty(
437 items=[("NOTHING", "Nothing", ""), ("NGONS", "N-Gons", ""), ("TRIANGLES", "Triangles", "")],
438 name="Fill up and down",
439 description="",
440 default="TRIANGLES",
441 update=prop_update_superellipsoid,
444 # -------- Used for loft but also Superellipsoid, etc.
445 curveshape: EnumProperty(
446 name="Povray Shape Type",
447 items=(
448 ("birail", "Birail", ""),
449 ("cairo", "Cairo", ""),
450 ("lathe", "Lathe", ""),
451 ("loft", "Loft", ""),
452 ("prism", "Prism", ""),
453 ("sphere_sweep", "Sphere Sweep", ""),
454 ("sor", "Surface of Revolution", ""),
456 default="sphere_sweep",
459 # -------- Supertorus
460 def prop_update_supertorus(self, context):
462 """Update POV supertorus primitive parameters not only at creation and on any UI change."""
464 if bpy.ops.pov.supertorus_update.poll():
465 bpy.ops.pov.supertorus_update()
467 st_major_radius: FloatProperty(
468 name="Major radius",
469 description="Major radius",
470 min=0.00,
471 max=100.00,
472 default=1.0,
473 update=prop_update_supertorus,
476 st_minor_radius: FloatProperty(
477 name="Minor radius",
478 description="Minor radius",
479 min=0.00,
480 max=100.00,
481 default=0.25,
482 update=prop_update_supertorus,
485 st_ring: FloatProperty(
486 name="Ring",
487 description="Ring manipulator",
488 min=0.0001,
489 max=100.00,
490 default=1.00,
491 update=prop_update_supertorus,
494 st_cross: FloatProperty(
495 name="Cross",
496 description="Cross manipulator",
497 min=0.0001,
498 max=100.00,
499 default=1.00,
500 update=prop_update_supertorus,
503 st_accuracy: FloatProperty(
504 name="Accuracy", description="Supertorus accuracy", min=0.00001, max=1.00, default=0.001
507 st_max_gradient: FloatProperty(
508 name="Gradient",
509 description="Max gradient",
510 min=0.0001,
511 max=100.00,
512 default=10.00,
513 update=prop_update_supertorus,
516 st_R: FloatProperty(
517 name="big radius",
518 description="The radius inside the tube",
519 default=1.0,
520 min=0.01,
521 max=100.0,
522 update=prop_update_supertorus,
525 st_r: FloatProperty(
526 name="small radius",
527 description="The radius of the tube",
528 default=0.3,
529 min=0.01,
530 max=100.0,
531 update=prop_update_supertorus,
534 st_u: IntProperty(
535 name="U-segments",
536 description="radial segmentation",
537 default=16,
538 min=3,
539 max=265,
540 update=prop_update_supertorus,
543 st_v: IntProperty(
544 name="V-segments",
545 description="lateral segmentation",
546 default=8,
547 min=3,
548 max=265,
549 update=prop_update_supertorus,
552 st_n1: FloatProperty(
553 name="Ring manipulator",
554 description="Manipulates the shape of the Ring",
555 default=1.0,
556 min=0.01,
557 max=100.0,
558 update=prop_update_supertorus,
561 st_n2: FloatProperty(
562 name="Cross manipulator",
563 description="Manipulates the shape of the cross-section",
564 default=1.0,
565 min=0.01,
566 max=100.0,
567 update=prop_update_supertorus,
570 st_ie: BoolProperty(
571 name="Use Int.+Ext. radii",
572 description="Use internal and external radii",
573 default=False,
574 update=prop_update_supertorus,
577 st_edit: BoolProperty(
578 name="", description="", default=False, options={"HIDDEN"}, update=prop_update_supertorus
581 # -------- Loft
582 loft_n: IntProperty(
583 name="Segments", description="Vertical segments", default=16, min=3, max=720
586 loft_rings_bottom: IntProperty(
587 name="Bottom", description="Bottom rings", default=5, min=2, max=100
590 loft_rings_side: IntProperty(name="Side", description="Side rings", default=10, min=2, max=100)
592 loft_thick: FloatProperty(
593 name="Thickness",
594 description="Manipulates the shape of the Ring",
595 default=0.3,
596 min=0.01,
597 max=1.0,
600 loft_r: FloatProperty(name="Radius", description="Radius", default=1, min=0.01, max=10)
602 loft_height: FloatProperty(
603 name="Height",
604 description="Manipulates the shape of the Ring",
605 default=2,
606 min=0.01,
607 max=10.0,
610 # -------- Prism
611 prism_n: IntProperty(name="Sides", description="Number of sides", default=5, min=3, max=720)
613 prism_r: FloatProperty(name="Radius", description="Radius", default=1.0)
615 # -------- Isosurface
616 iso_function_text: StringProperty(
617 name="Function Text", maxlen=1024
618 ) # ,update=iso_props_update_callback)
620 # -------- PolygonToCircle
621 polytocircle_resolution: IntProperty(
622 name="Resolution", description="", default=3, min=0, max=256
625 polytocircle_ngon: IntProperty(name="NGon", description="", min=3, max=64, default=5)
627 polytocircle_ngonR: FloatProperty(name="NGon Radius", description="", default=0.3)
629 polytocircle_circleR: FloatProperty(name="Circle Radius", description="", default=1.0)
631 # ---------------------------------------------------------------- #
632 # Modifiers POV properties.
633 # ---------------------------------------------------------------- #
634 # class RenderPovSettingsModifier(PropertyGroup):
635 boolean_mod: EnumProperty(
636 name="Operation",
637 description="Choose the type of calculation for Boolean modifier",
638 items=(
639 ("BMESH", "Use the BMesh Boolean Solver", ""),
640 ("CARVE", "Use the Carve Boolean Solver", ""),
641 ("POV", "Use POV Constructive Solid Geometry", ""),
643 default="BMESH",
646 # -------- Avogadro
647 # filename_ext = ".png"
649 # filter_glob = StringProperty(
650 # default="*.exr;*.gif;*.hdr;*.iff;*.jpeg;*.jpg;*.pgm;*.png;*.pot;*.ppm;*.sys;*.tga;*.tiff;*.EXR;*.GIF;*.HDR;*.IFF;*.JPEG;*.JPG;*.PGM;*.PNG;*.POT;*.PPM;*.SYS;*.TGA;*.TIFF",
651 # options={'HIDDEN'},
655 classes = (RenderPovSettingsObject,)
658 def register():
659 for cls in classes:
660 register_class(cls)
661 bpy.types.Object.pov = PointerProperty(type=RenderPovSettingsObject)
664 def unregister():
665 del bpy.types.Object.pov
666 for cls in reversed(classes):
667 unregister_class(cls)