1 # SPDX-License-Identifier: GPL-2.0-or-later
3 """Declare object level properties controllable in UI and translated to POV"""
5 from bpy
.utils
import register_class
, unregister_class
6 from bpy
.types
import PropertyGroup
7 from bpy
.props
import (
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",
34 default
=(0.001, 0.001, 0.5),
35 options
={"ANIMATABLE"},
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 "
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)",
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",
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 {}",
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",
96 ("birail", "Birail", ""),
97 ("cairo", "Cairo", ""),
98 ("lathe", "Lathe", ""),
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", "")),
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(
151 ("none", "None", ""),
152 ("bounded_by", "Bounded_by", ""),
153 ("clipped_by", "Clipped_by", ""),
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)
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)
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
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(
234 description
="The first radius of the cone",
238 update
=prop_update_cone
,
241 cone_cap_radius
: FloatProperty(
243 description
="The second radius of the cone",
247 update
=prop_update_cone
,
250 cone_segments
: IntProperty(
252 description
="Radial segmentation of proxy mesh",
256 update
=prop_update_cone
,
259 cone_height
: FloatProperty(
261 description
="Height of the cone",
265 update
=prop_update_cone
,
268 cone_base_z
: FloatProperty()
270 cone_cap_z
: FloatProperty()
271 # -------- Generic isosurface
272 isosurface_eq
: StringProperty(
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
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(
317 description
="Radial segmentation of proxy mesh",
321 update
=prop_update_torus
,
324 torus_minor_segments
: IntProperty(
326 description
="Cross-section segmentation of proxy mesh",
330 update
=prop_update_torus
,
333 torus_major_radius
: FloatProperty(
335 description
="Major radius",
339 update
=prop_update_torus
,
342 torus_minor_radius
: FloatProperty(
344 description
="Minor radius",
348 update
=prop_update_torus
,
352 arc_angle
: FloatProperty(
354 description
="The angle of the raynbow arc in degrees",
360 falloff_angle
: FloatProperty(
361 name
="Falloff angle",
362 description
="The angle after which rainbow dissolves into background",
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)
400 description
="radial segmentation",
404 update
=prop_update_superellipsoid
,
409 description
="lateral segmentation",
413 update
=prop_update_superellipsoid
,
416 se_n1
: FloatProperty(
417 name
="Ring manipulator",
418 description
="Manipulates the shape of the Ring",
422 update
=prop_update_superellipsoid
,
425 se_n2
: FloatProperty(
426 name
="Cross manipulator",
427 description
="Manipulates the shape of the cross-section",
431 update
=prop_update_superellipsoid
,
434 se_edit
: EnumProperty(
435 items
=[("NOTHING", "Nothing", ""), ("NGONS", "N-Gons", ""), ("TRIANGLES", "Triangles", "")],
436 name
="Fill up and down",
439 update
=prop_update_superellipsoid
,
442 # -------- Used for loft but also Superellipsoid, etc.
443 curveshape
: EnumProperty(
444 name
="Povray Shape Type",
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(
467 description
="Major radius",
471 update
=prop_update_supertorus
,
474 st_minor_radius
: FloatProperty(
476 description
="Minor radius",
480 update
=prop_update_supertorus
,
483 st_ring
: FloatProperty(
485 description
="Ring manipulator",
489 update
=prop_update_supertorus
,
492 st_cross
: FloatProperty(
494 description
="Cross manipulator",
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(
507 description
="Max gradient",
511 update
=prop_update_supertorus
,
516 description
="The radius inside the tube",
520 update
=prop_update_supertorus
,
525 description
="The radius of the tube",
529 update
=prop_update_supertorus
,
534 description
="radial segmentation",
538 update
=prop_update_supertorus
,
543 description
="lateral segmentation",
547 update
=prop_update_supertorus
,
550 st_n1
: FloatProperty(
551 name
="Ring manipulator",
552 description
="Manipulates the shape of the Ring",
556 update
=prop_update_supertorus
,
559 st_n2
: FloatProperty(
560 name
="Cross manipulator",
561 description
="Manipulates the shape of the cross-section",
565 update
=prop_update_supertorus
,
569 name
="Use Int.+Ext. radii",
570 description
="Use internal and external radii",
572 update
=prop_update_supertorus
,
575 st_edit
: BoolProperty(
576 name
="", description
="", default
=False, options
={"HIDDEN"}, update
=prop_update_supertorus
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(
592 description
="Manipulates the shape of the Ring",
598 loft_r
: FloatProperty(name
="Radius", description
="Radius", default
=1, min=0.01, max=10)
600 loft_height
: FloatProperty(
602 description
="Manipulates the shape of the Ring",
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(
635 description
="Choose the type of calculation for Boolean modifier",
637 ("BMESH", "Use the BMesh Boolean Solver", ""),
638 ("CARVE", "Use the Carve Boolean Solver", ""),
639 ("POV", "Use POV Constructive Solid Geometry", ""),
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
,)
659 bpy
.types
.Object
.pov
= PointerProperty(type=RenderPovSettingsObject
)
663 del bpy
.types
.Object
.pov
664 for cls
in reversed(classes
):
665 unregister_class(cls
)