Fix #104512: Sun Position: North Offset has no effect
[blender-addons.git] / render_povray / model_properties.py
blobf3bd3f228bf39cc5f960ea177c9ef910d3c55dcd
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 """Declare object level properties controllable in UI and translated to POV"""
4 import bpy
5 from bpy.utils import register_class, unregister_class
6 from bpy.types import PropertyGroup
7 from bpy.props import (
8 BoolProperty,
9 IntProperty,
10 FloatProperty,
11 FloatVectorProperty,
12 StringProperty,
13 EnumProperty,
14 PointerProperty,
18 # ---------------------------------------------------------------- #
19 # Object POV properties.
20 # ---------------------------------------------------------------- #
23 class RenderPovSettingsObject(PropertyGroup):
24 """Declare object and primitives level properties controllable in UI and translated to POV."""
26 # Pov inside_vector used for CSG
27 inside_vector: FloatVectorProperty(
28 name="CSG Inside Vector",
29 description="Direction to shoot CSG inside test rays at",
30 precision=4,
31 step=0.01,
32 min=0,
33 soft_max=1,
34 default=(0.001, 0.001, 0.5),
35 options={"ANIMATABLE"},
36 subtype="XYZ",
39 # Importance sampling
40 importance_value: FloatProperty(
41 name="Radiosity Importance",
42 description="Priority value relative to other objects for sampling radiosity rays. "
43 "Increase to get more radiosity rays at comparatively small yet "
44 "bright objects",
45 min=0.01,
46 max=1.00,
47 default=0.50,
50 # Collect photons
51 collect_photons: BoolProperty(
52 name="Receive Photon Caustics",
53 description="Enable object to collect photons from other objects caustics. Turn "
54 "off for objects that don't really need to receive caustics (e.g. objects"
55 " that generate caustics often don't need to show any on themselves)",
56 default=True,
59 # Photons spacing_multiplier
60 spacing_multiplier: FloatProperty(
61 name="Photons Spacing Multiplier",
62 description="Multiplier value relative to global spacing of photons. "
63 "Decrease by half to get 4x more photons at surface of "
64 "this object (or 8x media photons than specified in the globals",
65 min=0.01,
66 max=1.00,
67 default=1.00,
70 # ----------------------------------- CustomPOV Code ----------------------------------- #
71 # Only DUMMIES below for now:
72 replacement_text: StringProperty(
73 name="Declared name:",
74 description="Type the declared name in custom POV code or an external .inc "
75 "it points at. Any POV shape expected e.g: isosurface {}",
76 default="",
79 # -------- POV specific object properties. -------- #
80 object_as: StringProperty(maxlen=1024)
82 imported_loc: FloatVectorProperty(
83 name="Imported Pov location", precision=6, default=(0.0, 0.0, 0.0)
86 imported_loc_cap: FloatVectorProperty(
87 name="Imported Pov location", precision=6, default=(0.0, 0.0, 2.0)
90 unlock_parameters: BoolProperty(name="Lock", default=False)
92 # not in UI yet but used for sor (lathe) / prism... pov primitives
93 curveshape: EnumProperty(
94 name="Povray Shape Type",
95 items=(
96 ("birail", "Birail", ""),
97 ("cairo", "Cairo", ""),
98 ("lathe", "Lathe", ""),
99 ("loft", "Loft", ""),
100 ("prism", "Prism", ""),
101 ("sphere_sweep", "Sphere Sweep", ""),
103 default="sphere_sweep",
106 mesh_write_as: EnumProperty(
107 name="Mesh Write As",
108 items=(("blobgrid", "Blob Grid", ""), ("grid", "Grid", ""), ("mesh", "Mesh", "")),
109 default="mesh",
112 object_ior: FloatProperty(name="IOR", description="IOR", min=1.0, max=10.0, default=1.0)
114 # shape_as_light = StringProperty(name="Light",maxlen=1024)
115 # fake_caustics_power = FloatProperty(
116 # name="Power", description="Fake caustics power",
117 # min=0.0, max=10.0,default=0.0)
118 # target = BoolProperty(name="Target",description="",default=False)
119 # target_value = FloatProperty(
120 # name="Value", description="",
121 # min=0.0, max=1.0,default=1.0)
122 # refraction = BoolProperty(name="Refraction",description="",default=False)
123 # dispersion = BoolProperty(name="Dispersion",description="",default=False)
124 # dispersion_value = FloatProperty(
125 # name="Dispersion", description="Good values are 1.01 to 1.1. ",
126 # min=1.0, max=1.2,default=1.01)
127 # dispersion_samples = IntProperty(name="Samples",min=2, max=100,default=7)
128 # reflection = BoolProperty(name="Reflection",description="",default=False)
129 # pass_through = BoolProperty(name="Pass through",description="",default=False)
130 no_shadow: BoolProperty(name="No Shadow", default=False)
132 no_image: BoolProperty(name="No Image", default=False)
134 no_reflection: BoolProperty(name="No Reflection", default=False)
136 no_radiosity: BoolProperty(name="No Radiosity", default=False)
138 inverse: BoolProperty(name="Inverse", default=False)
140 sturm: BoolProperty(name="Sturm", default=False)
142 double_illuminate: BoolProperty(name="Double Illuminate", default=False)
144 hierarchy: BoolProperty(name="Hierarchy", default=False)
146 hollow: BoolProperty(name="Hollow", default=False)
148 boundorclip: EnumProperty(
149 name="Boundorclip",
150 items=(
151 ("none", "None", ""),
152 ("bounded_by", "Bounded_by", ""),
153 ("clipped_by", "Clipped_by", ""),
155 default="none",
158 boundorclipob: StringProperty(maxlen=1024)
160 addboundorclip: BoolProperty(description="", default=False)
162 blob_threshold: FloatProperty(name="Threshold", min=0.00, max=10.0, default=0.6)
164 blob_strength: FloatProperty(name="Strength", min=-10.00, max=10.0, default=1.00)
166 res_u: IntProperty(name="U", min=100, max=1000, default=500)
168 res_v: IntProperty(name="V", min=100, max=1000, default=500)
170 contained_by: EnumProperty(
171 name="Contained by", items=(("box", "Box", ""), ("sphere", "Sphere", "")), default="box"
174 container_scale: FloatProperty(name="Container Scale", min=0.0, max=10.0, default=1.00)
176 threshold: FloatProperty(name="Threshold", min=0.0, max=10.0, default=0.00)
178 accuracy: FloatProperty(name="Accuracy", min=0.0001, max=0.1, default=0.001)
180 max_gradient: FloatProperty(name="Max Gradient", min=0.0, max=100.0, default=5.0)
182 all_intersections: BoolProperty(name="All Intersections", default=False)
184 max_trace: IntProperty(name="Max Trace", min=1, max=100, default=1)
186 # -------- Cylinder
187 def prop_update_cylinder(self, context):
188 """Update POV cylinder primitive parameters at creation and anytime they change in UI."""
189 if bpy.ops.pov.cylinder_update.poll():
190 bpy.ops.pov.cylinder_update()
192 cylinder_radius: FloatProperty(
193 name="Cylinder R", min=0.00, max=10.0, default=0.04, update=prop_update_cylinder
196 cylinder_location_cap: FloatVectorProperty(
197 name="Cylinder Cap Location",
198 subtype="TRANSLATION",
199 description="Position of the 'other' end of the cylinder (relative to object location)",
200 default=(0.0, 0.0, 2.0),
201 update=prop_update_cylinder,
204 imported_cyl_loc: FloatVectorProperty(
205 name="Imported Pov location", precision=6, default=(0.0, 0.0, 0.0)
208 imported_cyl_loc_cap: FloatVectorProperty(
209 name="Imported Pov location", precision=6, default=(0.0, 0.0, 2.0)
212 # -------- Sphere
213 def prop_update_sphere(self, context):
215 """Update POV sphere primitive parameters at creation and anytime they change in UI."""
217 if bpy.ops.pov.sphere_update.poll():
218 bpy.ops.pov.sphere_update()
220 sphere_radius: FloatProperty(
221 name="Sphere radius", min=0.00, max=10.0, default=0.5, update=prop_update_sphere
224 # -------- Cone
225 def prop_update_cone(self, context):
227 """Update POV cone primitive parameters at creation and anytime they change in UI."""
229 if bpy.ops.pov.cone_update.poll():
230 bpy.ops.pov.cone_update()
232 cone_base_radius: FloatProperty(
233 name="Base radius",
234 description="The first radius of the cone",
235 default=1.0,
236 min=0.01,
237 max=100.0,
238 update=prop_update_cone,
241 cone_cap_radius: FloatProperty(
242 name="Cap radius",
243 description="The second radius of the cone",
244 default=0.3,
245 min=0.0,
246 max=100.0,
247 update=prop_update_cone,
250 cone_segments: IntProperty(
251 name="Segments",
252 description="Radial segmentation of proxy mesh",
253 default=16,
254 min=3,
255 max=265,
256 update=prop_update_cone,
259 cone_height: FloatProperty(
260 name="Height",
261 description="Height of the cone",
262 default=2.0,
263 min=0.01,
264 max=100.0,
265 update=prop_update_cone,
268 cone_base_z: FloatProperty()
270 cone_cap_z: FloatProperty()
271 # -------- Generic isosurface
272 isosurface_eq: StringProperty(
273 name="f (x,y,z)=",
274 description="Type the POV Isosurface function syntax for equation, "
275 "pattern,etc. ruling an implicit surface to be rendered",
276 default="sqrt(pow(x,2) + pow(y,2) + pow(z,2)) - 1.5",
278 # -------- Parametric
279 def prop_update_parametric(self, context):
281 """Update POV parametric surface primitive settings at creation and on any UI change."""
283 if bpy.ops.pov.parametric_update.poll():
284 bpy.ops.pov.parametric_update()
286 u_min: FloatProperty(name="U Min", description="", default=0.0, update=prop_update_parametric)
288 v_min: FloatProperty(name="V Min", description="", default=0.0, update=prop_update_parametric)
290 u_max: FloatProperty(name="U Max", description="", default=6.28, update=prop_update_parametric)
292 v_max: FloatProperty(name="V Max", description="", default=12.57, update=prop_update_parametric)
294 x_eq: StringProperty(
295 maxlen=1024, default="cos(v)*(1+cos(u))*sin(v/8)", update=prop_update_parametric
298 y_eq: StringProperty(
299 maxlen=1024, default="sin(u)*sin(v/8)+cos(v/8)*1.5", update=prop_update_parametric
302 z_eq: StringProperty(
303 maxlen=1024, default="sin(v)*(1+cos(u))*sin(v/8)", update=prop_update_parametric
306 # -------- Torus
308 def prop_update_torus(self, context):
310 """Update POV torus primitive parameters at creation and anytime they change in UI."""
312 if bpy.ops.pov.torus_update.poll():
313 bpy.ops.pov.torus_update()
315 torus_major_segments: IntProperty(
316 name="Segments",
317 description="Radial segmentation of proxy mesh",
318 default=48,
319 min=3,
320 max=720,
321 update=prop_update_torus,
324 torus_minor_segments: IntProperty(
325 name="Segments",
326 description="Cross-section segmentation of proxy mesh",
327 default=12,
328 min=3,
329 max=720,
330 update=prop_update_torus,
333 torus_major_radius: FloatProperty(
334 name="Major radius",
335 description="Major radius",
336 min=0.00,
337 max=100.00,
338 default=1.0,
339 update=prop_update_torus,
342 torus_minor_radius: FloatProperty(
343 name="Minor radius",
344 description="Minor radius",
345 min=0.00,
346 max=100.00,
347 default=0.25,
348 update=prop_update_torus,
351 # -------- Rainbow
352 arc_angle: FloatProperty(
353 name="Arc angle",
354 description="The angle of the raynbow arc in degrees",
355 default=360,
356 min=0.01,
357 max=360.0,
360 falloff_angle: FloatProperty(
361 name="Falloff angle",
362 description="The angle after which rainbow dissolves into background",
363 default=360,
364 min=0.0,
365 max=360,
368 # -------- HeightFields
370 quality: IntProperty(name="Quality", description="", default=100, min=1, max=100)
372 hf_filename: StringProperty(maxlen=1024)
374 hf_gamma: FloatProperty(name="Gamma", description="Gamma", min=0.0001, max=20.0, default=1.0)
376 hf_premultiplied: BoolProperty(name="Premultiplied", description="Premultiplied", default=True)
378 hf_smooth: BoolProperty(name="Smooth", description="Smooth", default=False)
380 hf_water: FloatProperty(
381 name="Water Level", description="Wather Level", min=0.00, max=1.00, default=0.0
384 hf_hierarchy: BoolProperty(name="Hierarchy", description="Height field hierarchy", default=True)
386 # -------- Superellipsoid
387 def prop_update_superellipsoid(self, context):
389 """Update POV superellipsoid primitive settings at creation and on any UI change."""
391 if bpy.ops.pov.superellipsoid_update.poll():
392 bpy.ops.pov.superellipsoid_update()
394 se_param1: FloatProperty(name="Parameter 1", description="", min=0.00, max=10.0, default=0.04)
396 se_param2: FloatProperty(name="Parameter 2", description="", min=0.00, max=10.0, default=0.04)
398 se_u: IntProperty(
399 name="U-segments",
400 description="radial segmentation",
401 default=20,
402 min=4,
403 max=265,
404 update=prop_update_superellipsoid,
407 se_v: IntProperty(
408 name="V-segments",
409 description="lateral segmentation",
410 default=20,
411 min=4,
412 max=265,
413 update=prop_update_superellipsoid,
416 se_n1: FloatProperty(
417 name="Ring manipulator",
418 description="Manipulates the shape of the Ring",
419 default=1.0,
420 min=0.01,
421 max=100.0,
422 update=prop_update_superellipsoid,
425 se_n2: FloatProperty(
426 name="Cross manipulator",
427 description="Manipulates the shape of the cross-section",
428 default=1.0,
429 min=0.01,
430 max=100.0,
431 update=prop_update_superellipsoid,
434 se_edit: EnumProperty(
435 items=[("NOTHING", "Nothing", ""), ("NGONS", "N-Gons", ""), ("TRIANGLES", "Triangles", "")],
436 name="Fill up and down",
437 description="",
438 default="TRIANGLES",
439 update=prop_update_superellipsoid,
442 # -------- Used for loft but also Superellipsoid, etc.
443 curveshape: EnumProperty(
444 name="Povray Shape Type",
445 items=(
446 ("birail", "Birail", ""),
447 ("cairo", "Cairo", ""),
448 ("lathe", "Lathe", ""),
449 ("loft", "Loft", ""),
450 ("prism", "Prism", ""),
451 ("sphere_sweep", "Sphere Sweep", ""),
452 ("sor", "Surface of Revolution", ""),
454 default="sphere_sweep",
457 # -------- Supertorus
458 def prop_update_supertorus(self, context):
460 """Update POV supertorus primitive parameters not only at creation and on any UI change."""
462 if bpy.ops.pov.supertorus_update.poll():
463 bpy.ops.pov.supertorus_update()
465 st_major_radius: FloatProperty(
466 name="Major radius",
467 description="Major radius",
468 min=0.00,
469 max=100.00,
470 default=1.0,
471 update=prop_update_supertorus,
474 st_minor_radius: FloatProperty(
475 name="Minor radius",
476 description="Minor radius",
477 min=0.00,
478 max=100.00,
479 default=0.25,
480 update=prop_update_supertorus,
483 st_ring: FloatProperty(
484 name="Ring",
485 description="Ring manipulator",
486 min=0.0001,
487 max=100.00,
488 default=1.00,
489 update=prop_update_supertorus,
492 st_cross: FloatProperty(
493 name="Cross",
494 description="Cross manipulator",
495 min=0.0001,
496 max=100.00,
497 default=1.00,
498 update=prop_update_supertorus,
501 st_accuracy: FloatProperty(
502 name="Accuracy", description="Supertorus accuracy", min=0.00001, max=1.00, default=0.001
505 st_max_gradient: FloatProperty(
506 name="Gradient",
507 description="Max gradient",
508 min=0.0001,
509 max=100.00,
510 default=10.00,
511 update=prop_update_supertorus,
514 st_R: FloatProperty(
515 name="big radius",
516 description="The radius inside the tube",
517 default=1.0,
518 min=0.01,
519 max=100.0,
520 update=prop_update_supertorus,
523 st_r: FloatProperty(
524 name="small radius",
525 description="The radius of the tube",
526 default=0.3,
527 min=0.01,
528 max=100.0,
529 update=prop_update_supertorus,
532 st_u: IntProperty(
533 name="U-segments",
534 description="radial segmentation",
535 default=16,
536 min=3,
537 max=265,
538 update=prop_update_supertorus,
541 st_v: IntProperty(
542 name="V-segments",
543 description="lateral segmentation",
544 default=8,
545 min=3,
546 max=265,
547 update=prop_update_supertorus,
550 st_n1: FloatProperty(
551 name="Ring manipulator",
552 description="Manipulates the shape of the Ring",
553 default=1.0,
554 min=0.01,
555 max=100.0,
556 update=prop_update_supertorus,
559 st_n2: FloatProperty(
560 name="Cross manipulator",
561 description="Manipulates the shape of the cross-section",
562 default=1.0,
563 min=0.01,
564 max=100.0,
565 update=prop_update_supertorus,
568 st_ie: BoolProperty(
569 name="Use Int.+Ext. radii",
570 description="Use internal and external radii",
571 default=False,
572 update=prop_update_supertorus,
575 st_edit: BoolProperty(
576 name="", description="", default=False, options={"HIDDEN"}, update=prop_update_supertorus
579 # -------- Loft
580 loft_n: IntProperty(
581 name="Segments", description="Vertical segments", default=16, min=3, max=720
584 loft_rings_bottom: IntProperty(
585 name="Bottom", description="Bottom rings", default=5, min=2, max=100
588 loft_rings_side: IntProperty(name="Side", description="Side rings", default=10, min=2, max=100)
590 loft_thick: FloatProperty(
591 name="Thickness",
592 description="Manipulates the shape of the Ring",
593 default=0.3,
594 min=0.01,
595 max=1.0,
598 loft_r: FloatProperty(name="Radius", description="Radius", default=1, min=0.01, max=10)
600 loft_height: FloatProperty(
601 name="Height",
602 description="Manipulates the shape of the Ring",
603 default=2,
604 min=0.01,
605 max=10.0,
608 # -------- Prism
609 prism_n: IntProperty(name="Sides", description="Number of sides", default=5, min=3, max=720)
611 prism_r: FloatProperty(name="Radius", description="Radius", default=1.0)
613 # -------- Isosurface
614 iso_function_text: StringProperty(
615 name="Function Text", maxlen=1024
616 ) # ,update=iso_props_update_callback)
618 # -------- PolygonToCircle
619 polytocircle_resolution: IntProperty(
620 name="Resolution", description="", default=3, min=0, max=256
623 polytocircle_ngon: IntProperty(name="NGon", description="", min=3, max=64, default=5)
625 polytocircle_ngonR: FloatProperty(name="NGon Radius", description="", default=0.3)
627 polytocircle_circleR: FloatProperty(name="Circle Radius", description="", default=1.0)
629 # ---------------------------------------------------------------- #
630 # Modifiers POV properties.
631 # ---------------------------------------------------------------- #
632 # class RenderPovSettingsModifier(PropertyGroup):
633 boolean_mod: EnumProperty(
634 name="Operation",
635 description="Choose the type of calculation for Boolean modifier",
636 items=(
637 ("BMESH", "Use the BMesh Boolean Solver", ""),
638 ("CARVE", "Use the Carve Boolean Solver", ""),
639 ("POV", "Use POV Constructive Solid Geometry", ""),
641 default="BMESH",
644 # -------- Avogadro
645 # filename_ext = ".png"
647 # filter_glob = StringProperty(
648 # 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",
649 # options={'HIDDEN'},
653 classes = (RenderPovSettingsObject,)
656 def register():
657 for cls in classes:
658 register_class(cls)
659 bpy.types.Object.pov = PointerProperty(type=RenderPovSettingsObject)
662 def unregister():
663 del bpy.types.Object.pov
664 for cls in reversed(classes):
665 unregister_class(cls)