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"""
7 from bpy
.utils
import register_class
, unregister_class
8 from bpy
.types
import PropertyGroup
9 from bpy
.props
import (
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",
36 default
=(0.001, 0.001, 0.5),
37 options
={"ANIMATABLE"},
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 "
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)",
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",
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 {}",
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",
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", "")),
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(
153 ("none", "None", ""),
154 ("bounded_by", "Bounded_by", ""),
155 ("clipped_by", "Clipped_by", ""),
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)
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)
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
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(
236 description
="The first radius of the cone",
240 update
=prop_update_cone
,
243 cone_cap_radius
: FloatProperty(
245 description
="The second radius of the cone",
249 update
=prop_update_cone
,
252 cone_segments
: IntProperty(
254 description
="Radial segmentation of proxy mesh",
258 update
=prop_update_cone
,
261 cone_height
: FloatProperty(
263 description
="Height of the cone",
267 update
=prop_update_cone
,
270 cone_base_z
: FloatProperty()
272 cone_cap_z
: FloatProperty()
273 # -------- Generic isosurface
274 isosurface_eq
: StringProperty(
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
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(
319 description
="Radial segmentation of proxy mesh",
323 update
=prop_update_torus
,
326 torus_minor_segments
: IntProperty(
328 description
="Cross-section segmentation of proxy mesh",
332 update
=prop_update_torus
,
335 torus_major_radius
: FloatProperty(
337 description
="Major radius",
341 update
=prop_update_torus
,
344 torus_minor_radius
: FloatProperty(
346 description
="Minor radius",
350 update
=prop_update_torus
,
354 arc_angle
: FloatProperty(
356 description
="The angle of the raynbow arc in degrees",
362 falloff_angle
: FloatProperty(
363 name
="Falloff angle",
364 description
="The angle after which rainbow dissolves into background",
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)
402 description
="radial segmentation",
406 update
=prop_update_superellipsoid
,
411 description
="lateral segmentation",
415 update
=prop_update_superellipsoid
,
418 se_n1
: FloatProperty(
419 name
="Ring manipulator",
420 description
="Manipulates the shape of the Ring",
424 update
=prop_update_superellipsoid
,
427 se_n2
: FloatProperty(
428 name
="Cross manipulator",
429 description
="Manipulates the shape of the cross-section",
433 update
=prop_update_superellipsoid
,
436 se_edit
: EnumProperty(
437 items
=[("NOTHING", "Nothing", ""), ("NGONS", "N-Gons", ""), ("TRIANGLES", "Triangles", "")],
438 name
="Fill up and down",
441 update
=prop_update_superellipsoid
,
444 # -------- Used for loft but also Superellipsoid, etc.
445 curveshape
: EnumProperty(
446 name
="Povray Shape Type",
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(
469 description
="Major radius",
473 update
=prop_update_supertorus
,
476 st_minor_radius
: FloatProperty(
478 description
="Minor radius",
482 update
=prop_update_supertorus
,
485 st_ring
: FloatProperty(
487 description
="Ring manipulator",
491 update
=prop_update_supertorus
,
494 st_cross
: FloatProperty(
496 description
="Cross manipulator",
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(
509 description
="Max gradient",
513 update
=prop_update_supertorus
,
518 description
="The radius inside the tube",
522 update
=prop_update_supertorus
,
527 description
="The radius of the tube",
531 update
=prop_update_supertorus
,
536 description
="radial segmentation",
540 update
=prop_update_supertorus
,
545 description
="lateral segmentation",
549 update
=prop_update_supertorus
,
552 st_n1
: FloatProperty(
553 name
="Ring manipulator",
554 description
="Manipulates the shape of the Ring",
558 update
=prop_update_supertorus
,
561 st_n2
: FloatProperty(
562 name
="Cross manipulator",
563 description
="Manipulates the shape of the cross-section",
567 update
=prop_update_supertorus
,
571 name
="Use Int.+Ext. radii",
572 description
="Use internal and external radii",
574 update
=prop_update_supertorus
,
577 st_edit
: BoolProperty(
578 name
="", description
="", default
=False, options
={"HIDDEN"}, update
=prop_update_supertorus
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(
594 description
="Manipulates the shape of the Ring",
600 loft_r
: FloatProperty(name
="Radius", description
="Radius", default
=1, min=0.01, max=10)
602 loft_height
: FloatProperty(
604 description
="Manipulates the shape of the Ring",
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(
637 description
="Choose the type of calculation for Boolean modifier",
639 ("BMESH", "Use the BMesh Boolean Solver", ""),
640 ("CARVE", "Use the Carve Boolean Solver", ""),
641 ("POV", "Use POV Constructive Solid Geometry", ""),
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
,)
661 bpy
.types
.Object
.pov
= PointerProperty(type=RenderPovSettingsObject
)
665 del bpy
.types
.Object
.pov
666 for cls
in reversed(classes
):
667 unregister_class(cls
)