Types¶
Functions Signatures
Deprecated
Deprecated since version R18.039: Use |
|
Deprecated since version R18.039: Use |
Uncategorized
With this function one can apply nearly all modeling commands.
|
|
Separates the mesh of the object to make each polygon/line segment independent.
|
|
Creates a spline object that has the best fit through the given points. |
|
Checks if object op would be displayed with the given filter. |
|
Checks if points in the polygon object op are visible in the view bd. |
|
Generates a UVW tag for an object. |
|
Calculates the bounding box of a hierarchy. |
|
Converts val to a string. |
|
Converts a string expressing a numeric value to a data value of type |
|
Calculates the angle of two vectors. |
|
Map the value of a range to another, optionnaly applying a spline curve. Similiar to the RangeMapper Node in XPresso. |
|
Convert a degrees value into radians. |
|
Convert a radians value into degrees. |
|
Mixes the two vectors together, such as mixing two colours. |
|
Returns a mixed value of v1 and v2 using the parameter t, as calculated by v1+(v2-v1)*t. |
|
Returns a if x is less than a and b if x is greater than b, else returns x. |
|
Returns a if x is less than a and b if x is greater than b, else returns x. |
|
Returns 1.0 if b is greater than or equal to a, else 0.0. |
|
Returns 0.0 if x is less than a and 1.0 if x is greater than b, else returns x mapped on the range [a,b] (a number between 0.0 and 1.0). The mapping is smoothed using an ease-in/ease-out curve. |
|
Returns 0.0 if x is less than a and 1.0 if x is greater than b, else returns x mapped on the range [a,b] (a number between 0.0 and 1.0). |
|
Creates a rotation matrix about the X axis. |
|
Creates a rotation matrix about the Y axis. |
|
Creates a rotation matrix about the Z axis. |
|
Spherical interpolation of the quaternions q1 and q2 with the parameter alfa. |
|
Cubic interpolates the quaternions q1 and q2 with parameter alfa using spherical quadrangle interpolation.
|
|
Linear interpolation of the quaternions q1 and q2 with parameter r. |
|
Smooth blends the quaternions qn and qn_p1 using spherical spline interpolation with parameter t.
|
|
Smooth blends the quaternions qn and qn_p1 using Cubic interpolation with parameter t.
|
|
Gets a normalized copy of quaternion q. |
|
Calculates the quaternion product of quaternions q1 and q2. |
|
Calculates the product of quaternion q with scalar s. |
|
Calculates the quaternion addition of quaternions q1 and q2. |
|
Calculates the quaternion subtraction of quaternions q1 and q2. |
|
Calculates the inverse of quaternion q. |
|
Calculates the Dot Product between q1 and q2. |
|
Calculates the derivative of quaternion q by vector w. |
|
Calculates the natural logarithm of quaternion q. |
|
Calculates the exponential of quaternion q. |
|
Calculates rotation axis and angle from matrix m: |
|
Calculate matrix from rotation axis v and angle w. |
|
Modify hpb_new so that the “distance” to the last angle hpb_old is at minimum. This helps to avoid HPB singularity effects. |
|
Calculates the distance from a point to a line. |
|
Find the ray vector after a reflection about a surface normal. |
|
Calculates the value of a spline at a point. |
|
Calculates the value of a spline at a point. |
|
Calculates a point along a spline curve from a set of points in 3D space. |
|
Calculates the tangent of a point along a spline curve from a given set of points and optional tangents. |
|
Calculates data about a point would if it were inserted into the spline at the passed offset. |
|
Creates a transformed tangent around a point and plane, allowing to directly set the position of one of the tangent handles and automatically rotating the rest of the tangent to match. |
|
Moves a point on a spline curve to a user specified new position. |
|
|
Calculates the default tangents for the passed points (spline segment) based on the spline type. |
Booleans an initial spline object with an array of other spline objects along a passed projection axis (in 2D). |
|
Converts RGB into the HSV color space and returns the converted value. |
|
Converts HSV into the RGB color space and returns the converted value. |
|
Converts RGB into the HSL color space and returns the converted value. |
|
Converts HSL into the RGB color space and returns the converted value. |
|
Check if vector v1 and v2 are within epsilon of each other. |
|
Returns the bias as the defined in the book “Texturing and Modeling” by Ebert. |
|
Limit the value of a to between b and c. |
|
Limit a color vector between 0.0 and 1.0. |
|
Limit a color vector between 0.0 and 1.0. |
|
Sum the vector components. |
|
Sum the vector components and multiply by 1/3. |
|
Calculates the angle between two vectors in radians. |
|
Find the minimum component of the vector. |
|
Find the maximum component of the vector. |
|
Create a translation matrix. |
|
Create a scaling matrix. |
|
Calculate euler angles from the vector p. The bank is always set to 0.0. |
|
Calculate euler angles from the matrix m. |
|
Construct matrix from the euler angles hpb. |
|
This is a helper function to modify a user chosen subdivision value. |
|
Compares if two floats are close to each other on a bit basis (rather than a fixed epsilon). |
|
Get sine and cosine of w: |
|
Transforms a color from one color profile to another. |
|
Calculates the scale between src and dst. |
|
|
Calculates the intersection points between a line and a sphere in 3D space. |
|
Calculates the intersection points between a line and a circle in 2D space (although Z will also be calculated on the resulting hit points). |
Calculates the distance from a point to a line segment between two points. |
|
Calculates the distance from a point to a line segment between two points in 2D ignoring the Z value. |
|
Initializes a bake operation of a single tag for |
|
Bakes the texture(s) specified by the last |
Functions Documentation
-
c4d.utils.
Deg
(r)¶ Deprecated since version R18.039: Use
RadToDeg()
instead for better understanding of code.Convert a radians value into degrees.
- Parameters
r (number) – Input value in radians.
- Return type
number
- Returns
Converted value in degrees.
-
c4d.utils.
Rad
(d)¶ Deprecated since version R18.039: Use
DegToRad()
instead for better understanding of code.Convert a degrees value into radians.
- Parameters
r (number) – Input value in degrees.
- Return type
number
- Returns
Converted value in radians.
-
c4d.utils.
SendModelingCommand
(command, list, mode=MODELINGCOMMANDMODE_ALL, bc=None, doc=None, flags=MODELINGCOMMANDFLAGS_NONE)¶ - With this function one can apply nearly all modeling commands.The function is applied to the objects in list. With the parameter mode you can decide if the current selection should be used to control what points/polygons are affected.
Note
Current State to Object(CSTO) has to be executed on a duplicate of an object because CSTO modifies the existing caches.In some cases you have to use a temporary document as wellObjectData.GetVirtualObjects()
.This is a small example how you can use this function
import c4d from c4d import utils settings = c4d.BaseContainer() # Settings settings[c4d.MDATA_EXTRUDE_OFFSET] = 50.0 # Length of the extrusion res = utils.SendModelingCommand(command=c4d.ID_MODELING_EXTRUDE_TOOL, list=[op], mode=c4d.MODELINGCOMMANDMODE_POLYGONSELECTION, bc=settings, doc=doc) c4d.EventAdd() if res is False: print "Something went wrong." elif res is True: print "Command successful." elif isinstance(res, list): print "Here you get the newly created object(s)."
- Parameters
command (int) – The modeling command. See MCOMMAND.
list (List[c4d.BaseObject]) – A list with objects which you want to apply the modeling command.
bc (Optional[c4d.BaseContainer]) – This is a settings container which contains all the values of the tool you want to apply.
mode (int) –
Modeling mode:
MODELINGCOMMANDMODE_ALL
All points/polygons.
MODELINGCOMMANDMODE_POINTSELECTION
Only the current point selection.
MODELINGCOMMANDMODE_POLYGONSELECTION
Only the current polygon selection.
MODELINGCOMMANDMODE_EDGESELECTION
Only the current edge selection.
doc (Optional[c4d.documents.BaseDocument]) –
The document for the operation. Should be set if possible. Must be set for MCOMMAND_JOIN, MCOMMAND_MAKEEDITABLE, MCOMMAND_CURRENTSTATETOOBJECT and MCOMMAND_SPLINE_PROJECT.If you set the document, the objects which you pass to this function have to be in the same document. So pay attention that you use one send_modeling_command per document for objects.flags (int) –
The flags:
MODELINGCOMMANDFLAGS_NONE
None.
MODELINGCOMMANDFLAGS_CREATEUNDO
Creates undo and inserts newly created objects into the passed document, instead of returning result.
- Returns
True if the command succeeded, otherwise False if something went wrong. Some commands do not apply their task to the passed objects, they return a cloned object so just check it.
- Return type
Union[bool, List[c4d.BaseObject]]
-
c4d.utils.
DisjointMesh
(op)¶ - Separates the mesh of the object to make each polygon/line segment independent.Each polygon/line will be given its own points thereby separating them so they can be moved independently, such as the Explosion object.
- Parameters
op (c4d.PointObject) – The point object to disjoint.
- Return type
bool
- Param
True if the mesh was disjointed successfully, otherwise False.
-
c4d.utils.
FitCurve
(padr, error, bt=None)¶ Creates a spline object that has the best fit through the given points.
- Parameters
padr (List[c4d.Vector]) – The points to fit a curve to.
error (float) – Sets how closely the curve must match the passed points. The lower the value then the closer the curve will match.
bt (Optional[c4d.threading.BaseThread]) –
New in version R18.057: An optional thread.
- Return type
- Returns
A Spline object that fits the given points, or AllocationFailed error if a spline object cannot be obtained.
-
c4d.utils.
CheckDisplayFilter
(op, filter)¶ Checks if object op would be displayed with the given filter.
Example:
import c4d activeView = doc.GetActiveBaseDraw() displayFilter = activeView.GetDisplayFilter() if c4d.utils.CheckDisplayFilter(op, displayFilter): print "Object Displayed!" else: print "Object Not Displayed!"
- Parameters
op (c4d.BaseObject) – The object to check.
filter (int) –
The filter bitmask:
DISPLAYFILTER_NONE
None.
DISPLAYFILTER_NULLOBJECT
Null.
DISPLAYFILTER_POLYGON
Polygon.
DISPLAYFILTER_SPLINE
Spline.
DISPLAYFILTER_GENERATOR
Generator.
DISPLAYFILTER_HYPERNURBS
Subdivision Surface.
DISPLAYFILTER_UNUSED1
Unused.
DISPLAYFILTER_DEFORMER
Deformer.
DISPLAYFILTER_CAMERA
Camera.
DISPLAYFILTER_LIGHT
Light.
DISPLAYFILTER_SCENE
Scene.
DISPLAYFILTER_PARTICLE
Particle.
DISPLAYFILTER_OTHER
Other.
DISPLAYFILTER_UNUSED2
New in version S22: Unused.
DISPLAYFILTER_GRID
Grid.
DISPLAYFILTER_HORIZON
Horizon.
DISPLAYFILTER_WORLDAXIS
World axis.
DISPLAYFILTER_BOUNDS
Bounding-box.
DISPLAYFILTER_HUD
HUD.
DISPLAYFILTER_SDS
HN mesh.
DISPLAYFILTER_HIGHLIGHTING
Highlighting.
DISPLAYFILTER_MULTIAXIS
Multi-select axis.
DISPLAYFILTER_OBJECTHANDLES
Highlight handles.
DISPLAYFILTER_HANDLEBANDS
Axis bands.
DISPLAYFILTER_SDSCAGE
HN cage.
DISPLAYFILTER_NGONLINES
N-gon lines.
DISPLAYFILTER_JOINT
Joint objects.
DISPLAYFILTER_OBJECTHIGHLIGHTING
Private.
DISPLAYFILTER_GUIDELINES
Axis Guidelines.
DISPLAYFILTER_POI
Navigation cross.
DISPLAYFILTER_GRADIENT
Gradient.
DISPLAYFILTER_BASEGRID
Base grid.
DISPLAYFILTER_HANDLES
Handles.
DISPLAYFILTER_HAIR
New in version S22: Hair.
DISPLAYFILTER_FIELD
New in version S22: Field.
- Return type
bool
- Returns
True if the object would be displayed, otherwise False.
-
c4d.utils.
CalculateVisiblePoints
(bd, op, visible=False)¶ Checks if points in the polygon object op are visible in the view bd.
- Parameters
bd (c4d.BaseDraw) – The base draw to check.
op (c4d.PolygonObject) – The object to check.
visible (Optional[bool]) –
New in version R19.068: True to include only visible points, otherwise False (default) to also include hidden points like for example those from the back of an object.
- Return type
Optional[List[int]]
- Returns
- A list of integers with the visibility status for each point: 1 if the point is visible otherwise 0.None if the function fails.
-
c4d.utils.
GenerateUVW
(op, opmg, tp, texopmg, view=None)¶ Generates a UVW tag for an object.
- Parameters
op (c4d.BaseObject) – The object to generate the UVW coordinates for.
opmg (c4d.Matrix) – The object’s global matrix.
tp (c4d.TextureTag) – The texture tag to generate the UVW coordinates from.
texopmg (c4d.Matrix) – The global matrix of the object that carries the texture tag.
view (Optional[c4d.BaseView]) – The optional current view.
- Return type
Optional[c4d.UVWTag]
- Returns
- The created UVW tag, or None if the texture type is already UV or if the function failed.If None is returned the UVW tag must be retrieved from the object itself.
-
c4d.utils.
GetBBox
(pObj, mg)¶ Calculates the bounding box of a hierarchy.
- Parameters
pObj (c4d.BaseObject) – The root object of a hierarchy.
mg (c4d.Matrix) – The transformation matrix for the bounding box.
- Return type
Tuple[c4d.Vector, c4d.Vector]
- Returns
The center and the radius of the bounding box.
-
c4d.utils.
FormatNumber
(val, format, fps, bUnit=True)¶ Converts val to a string.
- Parameters
val (any) – The value to convert to a string. Must be of type float, int or
c4d.BaseTime
.format (int) –
The format:
FORMAT_FLOAT
Floating point without unit.
FORMAT_INT
Integer without unit.
FORMAT_PERCENT
Floating point with % sign, 1.0 = 100%.
FORMAT_DEGREE
Floating point with ° sign. Measured in radians, displayed in degrees.
FORMAT_METER
Floating point in the current working unit.
FORMAT_FRAMES
Time formatted as frames. (Overrided by user preference.)
FORMAT_SECONDS
Time formatted as seconds. (Overrided by user preference.)
FORMAT_SMPTE
Time formatted as SMPTE. (Overrided by user preference.)
fps (int) – The frames per second, for time values.
bUnit (bool) – If True the unit is included in the formatted string.
- Return type
str
- Returns
The formatted string.
-
c4d.utils.
StringToNumber
(text, format, fps, lengthunit)¶ Converts a string expressing a numeric value to a data value of type
float
orint
.- Parameters
text (str) – The string to convert to a value.
format (int) –
The format:
FORMAT_FLOAT
Floating point without unit.
FORMAT_INT
Integer without unit.
FORMAT_PERCENT
Floating point with % sign, 1.0 = 100%.
FORMAT_DEGREE
Floating point with ° sign. Measured in radians, displayed in degrees.
FORMAT_METER
Floating point in the current working unit.
FORMAT_FRAMES
Time formatted as frames. (Overrided by user preference.)
FORMAT_SECONDS
Time formatted as seconds. (Overrided by user preference.)
FORMAT_SMPTE
Time formatted as SMPTE. (Overrided by user preference.)
fps (int) – The frames per second, for time values.
lengthunit (int) –
New in version R18.057.
Can be used to override the units conversion. By default the function uses the document’s units.For example a string of “50” results in 0.5 if the document’s units are Meters and the unit display setting is centimeters.If lengthunit is specified its value will be used instead of the document’s units setting.
- Return type
Union[int, float]
- Returns
The converted value.
-
c4d.utils.
GetAngle
(v1, v2)¶ Calculates the angle of two vectors.
- Parameters
v1 (c4d.Vector) – First position.
v2 (c4d.Vector) – Second position.
- Return type
float
- Returns
The angle in radians.
-
c4d.utils.
RangeMap
(value, mininput, maxinput, minoutput, maxoutput, clampval, curve)¶ Map the value of a range to another, optionnaly applying a spline curve. Similiar to the RangeMapper Node in XPresso.
Here are several examples:
import c4d c4d.utils.RangeMap(value=0.5, mininput=0, maxinput=1, minoutput=5, maxoutput=10, clampval=False) # Output: 7.5 c4d.utils.RangeMap(value=1.5, mininput=0, maxinput=1, minoutput=5, maxoutput=10, clampval=False) # Output: 12.5 c4d.utils.RangeMap(value=1.5, mininput=0, maxinput=1, minoutput=5, maxoutput=10, clampval=True) # Output: 10.0
- Parameters
value (float) – The value to map.
mininput (float) – The minimum input.
maxinput (float) – The maximum input.
minoutput (float) – The minimum output.
maxoutput (float) – The maximum output.
clampval (bool) – Pass True to clamp the value in the range [minoutput, maxoutput].
curve (Optional[c4d.SplineData]) – The optional curve to use.
- Returns
The mapped valued.
- Return type
float
-
c4d.utils.
DegToRad
(d)¶ Convert a degrees value into radians.
New in version R18.039.
- Parameters
r (number) – Input value in degrees.
- Return type
number
- Returns
Converted value in radians.
-
c4d.utils.
RadToDeg
(r)¶ Convert a radians value into degrees.
New in version R18.039.
- Parameters
r (number) – Input value in radians.
- Return type
number
- Returns
Converted value in degrees.
-
c4d.utils.
MixVec
(v1, v2, t)¶ Mixes the two vectors together, such as mixing two colours.
- Parameters
v1 (c4d.Vector) – Vector to mix.
v2 (c4d.Vector) – Vector to mix.
t (number) – Mix amount: 0 < t < 1.0.
- Return type
- Returns
The mixed vector.
-
c4d.utils.
MixNum
(v1, v2, t)¶ Returns a mixed value of v1 and v2 using the parameter t, as calculated by v1+(v2-v1)*t.
- Parameters
v1 (float) – Value to mix.
v2 (float) – Value to mix.
t (number) – Mix amount: 0 < t < 1.0.
- Return type
float
- Returns
Mix amount, with 0 <= t <= 1.0.
-
c4d.utils.
Clamp
(a, b, x)¶ Returns a if x is less than a and b if x is greater than b, else returns x.
Note
The order of parameters are different to Peachey’s definition.
- Parameters
a (number) – The float value.
b (number) – The float value.
x (number) – The float value.
- Return type
float
- Returns
The clamped value.
-
c4d.utils.
ClampValue
(x, a, b)¶ Returns a if x is less than a and b if x is greater than b, else returns x.
New in version R15.037.
Note
The order of parameters are the same to Peachey’s definition.
- Parameters
x (number) – The float value.
a (number) – The float value.
b (number) – The float value.
- Return type
float
- Returns
The clamped value.
-
c4d.utils.
Step
(a, b)¶ Returns 1.0 if b is greater than or equal to a, else 0.0.
- Parameters
a (number) – The float value.
b (number) – The float value.
- Return type
float
- Returns
The step value (1.0 or 0.0).
-
c4d.utils.
Smoothstep
(a, b, x)¶ Returns 0.0 if x is less than a and 1.0 if x is greater than b, else returns x mapped on the range [a,b] (a number between 0.0 and 1.0). The mapping is smoothed using an ease-in/ease-out curve.
- Parameters
a (float) – The float value.
b (float) – The float value.
x (float) – The float value.
- Return type
float
- Returns
The smoothed value.
-
c4d.utils.
Boxstep
(a, b, x)¶ Returns 0.0 if x is less than a and 1.0 if x is greater than b, else returns x mapped on the range [a,b] (a number between 0.0 and 1.0).
- Parameters
a (number) – The float value.
b (number) – The float value.
x (number) – The float value.
- Return type
float
- Returns
The stepped value.
-
c4d.utils.
MatrixRotX
(w)¶ Creates a rotation matrix about the X axis.
- Parameters
w (float) – The angle around X.
- Return type
- Returns
The rotation matrix.
-
c4d.utils.
MatrixRotY
(w)¶ Creates a rotation matrix about the Y axis.
- Parameters
w (float) – The angle around Y.
- Return type
- Returns
The rotation matrix.
-
c4d.utils.
MatrixRotZ
(w)¶ Creates a rotation matrix about the Z axis.
- Parameters
w (float) – The angle around Z.
- Return type
- Returns
The rotation matrix.
-
c4d.utils.
QSlerp
(q1, q2, alfa)¶ Spherical interpolation of the quaternions q1 and q2 with the parameter alfa.
New in version R17.048.
- Parameters
q1 (c4d.Quaternion) – The first quaternion.
q2 (c4d.Quaternion) – The second quaternion.
alfa (float) – The interpolation parameter. Between 0.0 (q1) and 1.0 (q2).
- Return type
- Returns
The interpolated quaternion.
-
c4d.utils.
QSquad
(q0, q1, q2, q3, alfa)¶ - Cubic interpolates the quaternions q1 and q2 with parameter alfa using spherical quadrangle interpolation.q0 and q3 are used to provide C1-continuity at the borders (tangents): q0 = i-1, q1 = i, q2 = i+1, q3 = i+2
New in version R17.048.
- Parameters
q0 (c4d.Quaternion) – The first quaternion to provide continuity.
q1 (c4d.Quaternion) – The first quaternion to interpolate from.
q2 (c4d.Quaternion) – The second quaternion to interpolate from.
q3 (c4d.Quaternion) – The second quaternion to provide continuity.
alfa (float) – The interpolation parameter. Between 0.0 (q1) and 1.0 (q2).
- Return type
- Returns
The interpolated quaternion.
-
c4d.utils.
QBlend
(q1, q2, r)¶ Linear interpolation of the quaternions q1 and q2 with parameter r.
New in version R17.048.
- Parameters
q1 (c4d.Quaternion) – The first quaternion.
q2 (c4d.Quaternion) – The second quaternion.
alfa (float) – The blending parameter. Between 0.0 (q1) and 1.0 (q2).
- Return type
- Returns
The interpolated quaternion.
-
c4d.utils.
QSpline
(qn_m1, qn, qn_p1, qn_p2, t)¶ - Smooth blends the quaternions qn and qn_p1 using spherical spline interpolation with parameter t.qn_m1 (-1) and qn_p2 (-1+2) are used to provide C1-continuity at the borders (tangents).
New in version R17.048.
- Parameters
qn_m1 (c4d.Quaternion) – The first quaternion (-1) to provide continuity.
qn (c4d.Quaternion) – The first quaternion to interpolate from.
qn_p1 (c4d.Quaternion) – The second quaternion to interpolate from.
qn_p2 (c4d.Quaternion) – The second quaternion (+2) to provide continuity.
t (float) – The blending parameter. Between 0.0 (qn) and 1.0 (qn_p1).
- Return type
- Returns
The interpolated quaternion.
-
c4d.utils.
QSmoothCubic
(qn_m1, qn, qn_p1, t)¶ - Smooth blends the quaternions qn and qn_p1 using Cubic interpolation with parameter t.qn_m1 (-1) and qn_p2 (-1+2) are used to provide C1-continuity at the borders (tangents).
New in version R18.020.
- Parameters
qn_m1 (c4d.Quaternion) – The first quaternion (-1) to provide continuity.
qn (c4d.Quaternion) – The first quaternion to interpolate from.
qn_p1 (c4d.Quaternion) – The second quaternion to interpolate from.
t (float) – The blending parameter. Between 0.0 (qn) and 1.0 (qn_p1).
- Return type
- Returns
The interpolated quaternion.
-
c4d.utils.
QNorm
(q)¶ Gets a normalized copy of quaternion q.
New in version R17.048.
- Parameters
q (c4d.Quaternion) – The quaternion to normalize.
- Return type
- Returns
A normalized copy of q.
-
c4d.utils.
QMul
(q1, q2)¶ Calculates the quaternion product of quaternions q1 and q2.
New in version R17.048.
- Parameters
q1 (c4d.Quaternion) – The first quaternion.
q2 (c4d.Quaternion) – The second quaternion.
- Return type
- Returns
The quaternion product of q1 and q2.
-
c4d.utils.
QMulS
(q, s)¶ Calculates the product of quaternion q with scalar s.
New in version R17.048.
- Parameters
q (c4d.Quaternion) – The quaternion.
s (float) – The scalar.
- Return type
- Returns
The product of q with s.
-
c4d.utils.
QAdd
(q1, q2)¶ Calculates the quaternion addition of quaternions q1 and q2.
New in version R17.048.
- Parameters
q1 (c4d.Quaternion) – The first quaternion.
q2 (c4d.Quaternion) – The second quaternion.
- Return type
- Returns
The quaternion addition of q1 and q2.
-
c4d.utils.
QSub
(q1, q2)¶ Calculates the quaternion subtraction of quaternions q1 and q2.
New in version R17.048.
- Parameters
q1 (c4d.Quaternion) – The first quaternion.
q2 (c4d.Quaternion) – The second quaternion.
- Return type
- Returns
The quaternion subtraction of q1 and q2.
-
c4d.utils.
QInvert
(q)¶ Calculates the inverse of quaternion q.
New in version R17.048.
- Parameters
q (c4d.Quaternion) – The quaternion to invert.
- Return type
- Returns
The quaternion inverse of q.
-
c4d.utils.
QDot
(q1, q2)¶ Calculates the Dot Product between q1 and q2.
New in version R18.020.
- Parameters
q1 (c4d.Quaternion) – The first quaternion.
q2 (c4d.Quaternion) – The second quaternion.
- Return type
float
- Returns
The Dot Product of q1 and q2.
-
c4d.utils.
QDeriv
(q, w)¶ Calculates the derivative of quaternion q by vector w.
New in version R17.048.
- Parameters
q (c4d.Quaternion) – The quaternion.
w (c4d.Vector) – The vector.
- Return type
- Returns
The quaternion derivative of q by w.
-
c4d.utils.
QLogN
(q)¶ Calculates the natural logarithm of quaternion q.
New in version R17.048.
- Parameters
q (c4d.Quaternion) – The quaternion.
- Return type
- Returns
The natural logarithm of q.
-
c4d.utils.
QExpQ
(q)¶ Calculates the exponential of quaternion q.
New in version R17.048.
- Parameters
q (c4d.Quaternion) – The quaternion.
- Return type
- Returns
The exponential of q.
-
c4d.utils.
MatrixToRotAxis
(m)¶ Calculates rotation axis and angle from matrix m:
import c4d import math # 90 degree angle = math.pi * .5 m = c4d.utils.MatrixRotX(angle) v, w = c4d.utils.MatrixToRotAxis(m) # v is the rotation axis, c4d.Vector # w is the rotation angle, float
- Parameters
m (c4d.Matrix) – Rotation matrix.
- Return type
list
- Returns
The rotation axis, and the angle.
-
c4d.utils.
RotAxisToMatrix
(v, w)¶ Calculate matrix from rotation axis v and angle w.
- Parameters
v (c4d.Vector) – The axis.
w (float) – The angle of rotation.
- Return type
- Returns
The rotation matrix.
-
c4d.utils.
GetOptimalAngle
(hpb_old, hpb_new, rotation_order)¶ Modify hpb_new so that the “distance” to the last angle hpb_old is at minimum. This helps to avoid HPB singularity effects.
- Parameters
hpb_old (c4d.Vector) – The old HPB.
hpb_new (c4d.Vector) – The new HPB.
rotation_order (int) –
The order of rotation:
ROTATIONORDER_YXZGLOBAL
Global YXZ order.
ROTATIONORDER_YZXGLOBAL
Global YZX order.
ROTATIONORDER_ZYXGLOBAL
Global ZYX order.
ROTATIONORDER_ZXYGLOBAL
Global ZXY order.
ROTATIONORDER_XZYGLOBAL
Global XZY order.
ROTATIONORDER_XYZGLOBAL
Global XYZ order.
ROTATIONORDER_YXZLOCAL
Local YXZ order.
ROTATIONORDER_YZXLOCAL
Local YZX order.
ROTATIONORDER_ZYXLOCAL
Local ZYX order.
ROTATIONORDER_ZXYLOCAL
Local ZXY order.
ROTATIONORDER_XZYLOCAL
Local XZY order.
ROTATIONORDER_XYZLOCAL
Local XYZ order.
ROTATIONORDER_HPB
HPB order.
ROTATIONORDER_DEFAULT
Default order. ROTATIONORDER_HPB.
- Return type
- Returns
The optimal angle.
-
c4d.utils.
PointLineDistance
(p0, v, p)¶ Calculates the distance from a point to a line.
- Parameters
p0 (c4d.Vector) – The starting point of the line.
v (c4d.Vector) – The line vector.
p (c4d.Vector) – The point.
- Return type
- Returns
Point-line vector.
-
c4d.utils.
ReflectRay
(v, n)¶ Find the ray vector after a reflection about a surface normal.
- Parameters
v (c4d.Vector) – The incoming ray.
n (c4d.Vector) – The surface normal.
- Return type
- Returns
The reflected ray.
-
c4d.utils.
CalcSpline
(x, knots)¶ Calculates the value of a spline at a point.
- Parameters
x (float) – The position on the spline.
knots (List[float]) – The knots list.
- Return type
float
- Returns
The spline value.
-
c4d.utils.
CalcSplineV
(x, knots)¶ Calculates the value of a spline at a point.
- Parameters
x (float) – The position on the spline.
knots (List[c4d.Vector]) – The knots list.
- Return type
- Returns
The spline value.
-
c4d.utils.
CalcSplinePoint
(offset, type, closed, pcnt, padr, tadr=None)¶ Calculates a point along a spline curve from a set of points in 3D space.
New in version R17.048.
- Parameters
offset (float) – The offset along the spline from 0.0 to 1.0.
type (int) –
The type of spline. Check out Spline Types.
SPLINETYPE_LINEAR
Linear.
SPLINETYPE_CUBIC
Cubic.
SPLINETYPE_AKIMA
Akima.
SPLINETYPE_BSPLINE
B-Spline.
SPLINETYPE_BEZIER
Bezier.
closed (bool) – Whether the spline is closed or not.
pcnt (int) – The number of points in the spline.
padr (List[c4d.Vector]) – The points array.
tadr (Optional[List[Dict[str: c4d.Vector]]]) –
- Return type
- Returns
The resulting point calculated from the offset.
-
c4d.utils.
CalcSplineTangent
(offset, type, closed, pcnt, padr, tadr=None)¶ Calculates the tangent of a point along a spline curve from a given set of points and optional tangents.
New in version R17.048.
- Parameters
offset (float) – The offset along the spline from 0.0 to 1.0.
type (int) –
The type of spline. Check out Spline Types.
SPLINETYPE_LINEAR
Linear.
SPLINETYPE_CUBIC
Cubic.
SPLINETYPE_AKIMA
Akima.
SPLINETYPE_BSPLINE
B-Spline.
SPLINETYPE_BEZIER
Bezier.
closed (bool) – Whether the spline is closed or not.
pcnt (int) – The number of points in the spline.
padr (List[c4d.Vector]) – The points array.
tadr (Optional[List[Dict[str: c4d.Vector]]]) –
- Return type
- Returns
The resulting tangent (normalized) for the given offset.
-
c4d.utils.
CalcSplineInsert
(offset, type, closed, pcnt, padr, tadr=None)¶ Calculates data about a point would if it were inserted into the spline at the passed offset.
New in version R17.048.
- Parameters
offset (float) – The offset along the spline from 0.0 to 1.0.
type (int) –
The type of spline. Check out Spline Types.
SPLINETYPE_LINEAR
Linear.
SPLINETYPE_CUBIC
Cubic.
SPLINETYPE_AKIMA
Akima.
SPLINETYPE_BSPLINE
B-Spline.
SPLINETYPE_BEZIER
Bezier.
closed (bool) – Whether the spline is closed or not.
pcnt (int) – The number of points in the spline.
padr (List[c4d.Vector]) – The points array.
tadr (Optional[List[Dict[str: c4d.Vector]]]) –
- Return type
- Returns
A dictionary with the following information:
”pointIndex”: The index that the resulting point would be if it were inserted into the spline.
”resultPoint”: The position of the resulting point.
”resultTangent”: The spline tangent information of the resulting point. Dict[‘vl’:
Vector
,’vr’:Vector
]”leftTangent”: The correct new left tangent (tadr[pointIndex - 1].vr).
”rightTangent”: The correct new right tangent (tadr[pointIndex].vl).
-
c4d.utils.
TransformTangent
(newPos, planeNormal, position, tangent, tangentSide, flags=TANGENTTRANSFORMFLAG_BREAK_SCALE)¶ Creates a transformed tangent around a point and plane, allowing to directly set the position of one of the tangent handles and automatically rotating the rest of the tangent to match.
New in version R17.048.
- Parameters
newPos (c4d.Vector) – The new position for the tangent handle.
planeNormal (c4d.Vector) – The normal of the plane for rotation of the handles.
position (c4d.Vector) – The position of the center of the tangent being modified.
tangent (dict) –
tangentSide (int) –
The handle to modify of the tangent, left, right, or none:
TANGENTSIDE_NONE
No tangent handles being modified.
TANGENTSIDE_LEFT
Modify the left tangent handle.
TANGENTSIDE_RIGHT
Modify the right tangent handle.
flags (int) –
The flags for controlling tangent breaking, rotation and scale locking etc.
TANGENTTRANSFORMFLAG_NONE
None.
TANGENTTRANSFORMFLAG_LOCK_LENGTH
Fix the length of the tangents, only change the rotation.
TANGENTTRANSFORMFLAG_LOCK_ANGLE
Fix the angle of the tangents, only change the length.
TANGENTTRANSFORMFLAG_BREAK_SCALE
Only scale one handle (but rotate both).
TANGENTTRANSFORMFLAG_BREAK
Only modify one handle.
- Return type
- Returns
The resulting transformed tangent.
-
c4d.utils.
CalcSplineMovement
(newPos, offset, type, splineMg, bd, planeNormal, closed, lockTangentAngle, lockTangentLength, breakTangents, pcnt, padr, tadr)¶ Moves a point on a spline curve to a user specified new position.
New in version R17.048.
- Parameters
newPos (c4d.Vector) – The new position for the point of the curve at offset.
offset (float) – The offset to move to the position newPos.
type (int) –
The type of spline to move. Check out Spline Types.
SPLINETYPE_LINEAR
Linear.
SPLINETYPE_CUBIC
Cubic.
SPLINETYPE_AKIMA
Akima.
SPLINETYPE_BSPLINE
B-Spline.
SPLINETYPE_BEZIER
Bezier.
splineMg (c4d.Matrix) – The matrix of the spline.
bd (Optional[c4d.BaseDraw]) – The optional basedraw. Can be None.
planeNormal (c4d.Vector) – The normal for tangent rotation, typically Vector(0,0,1).
closed (bool) – The closed state of the spline.
lockTangentAngle (bool) – True if tangents angle may not be changed by this routine.
lockTangentLength (bool) – True if the tangents length may not be changed by this routine.
breakTangents (int) –
Set to break the tangents while manipulating the curve if tangents exist:
Symbol ID
Description
BREAKTANGENTS_V_FALSE
Do not break any tangents.
BREAKTANGENTS_V_TRUE
Break the tangents.
BREAKTANGENTS_V_AUTO
Only break the tangents if they are already broken.
pcnt (int) – The number of points in the spline.
padr (List[c4d.Vector]) – The points that describe the spline.
tadr (Optional[List[Dict[str: c4d.Vector]]]) –
- Return type
Tuple[List[c4d.Vector], List[Dict[str: c4d.Vector]]]
- Returns
The resulting lists of points and tangents.
-
c4d.utils.
CalcSplineDefaultTangents
(type, closed, pcnt, padr)¶ Calculates the default tangents for the passed points (spline segment) based on the spline type.
New in version R17.048.
- Parameters
type (int) –
The type of spline to move. Check out Spline Types.
SPLINETYPE_LINEAR
Linear.
SPLINETYPE_CUBIC
Cubic.
SPLINETYPE_AKIMA
Akima.
SPLINETYPE_BSPLINE
B-Spline.
SPLINETYPE_BEZIER
Bezier.
closed (bool) – The closed state of the spline.
pcnt (int) – The number of points in the spline.
padr (List[c4d.Vector]) – The points that describe the spline.
- Return type
List[Dict[str: c4d.Vector]]
- Returns
The resulting tangents. A tangent dictionary is defined as: Dict[‘vl’:
Vector
, ‘vr’:Vector
]
-
c4d.utils.
BooleanSplines
(initialSpline, booleanObjects, doc, bd, projectionAxis, booleanMode)¶ Booleans an initial spline object with an array of other spline objects along a passed projection axis (in 2D).
New in version R17.048.
- Parameters
initialSpline (c4d.BaseObject) – The original spline object that will have the operations applied to it.
booleanObjects (List[c4d.SplineObject]) – The array of spline objects to boolean with initialSpline.
doc (c4d.documents.BaseDocument) – The active document that the objects belong to.
bd (c4d.BaseDraw) – The active basebraw.
projectionAxis (int) –
The projection axis to use:
SPLINEBOOL_AXIS_NONE
No axis.
SPLINEBOOL_AXIS_SCREEN
Project into the current screen.
SPLINEBOOL_AXIS_ZY
Project on the ZY (X axis) plane.
SPLINEBOOL_AXIS_XZ
Project on the XZ (Y axis) plane.
SPLINEBOOL_AXIS_XY
Project on the XY (Z axis) plane.
booleanMode (int) –
The type of boolean to apply:
SPLINEBOOL_MODE_AMINUSB
Subtract B from A.
SPLINEBOOL_MODE_BMINUSA
Subtract A from B.
SPLINEBOOL_MODE_UNION
Union of both A and B.
SPLINEBOOL_MODE_AND
And intersection (overlap) of region of A and B.
SPLINEBOOL_MODE_OR
Or intersection (outside of overlap) of region of A and B.
SPLINEBOOL_MODE_INTERSECTION
Intersection (all segments inside and out) of region of A and B.
- Return type
Optional[c4d.BaseList2D]
- Returns
The spline object result of the Boolean operation, None if there was an error.
-
c4d.utils.
RGBToHSV
(col)¶ Converts RGB into the HSV color space and returns the converted value.
- Parameters
col (c4d.Vector) – RGB color.
- Return type
- Returns
HSV color.
-
c4d.utils.
HSVToRGB
(col)¶ Converts HSV into the RGB color space and returns the converted value.
- Parameters
col (c4d.Vector) – HSV color.
- Return type
- Returns
RGB color.
-
c4d.utils.
RGBToHSL
(col)¶ Converts RGB into the HSL color space and returns the converted value.
New in version R14.014.
- Parameters
col (c4d.Vector) – RGB color.
- Return type
- Returns
HSL color.
Note
If you want the Hue value to be in degree, you have to multiply it yourself.
-
c4d.utils.
HSLtoRGB
(col)¶ Converts HSL into the RGB color space and returns the converted value.
New in version R14.014.
- Parameters
col (c4d.Vector) – HSL color.
- Return type
- Returns
RGB color.
-
c4d.utils.
VectorEqual
(v1, v2, epsilon=0.01)¶ Check if vector v1 and v2 are within epsilon of each other.
- Parameters
v1 (c4d.Vector) – The first vector.
v2 (c4d.Vector) – The second vector.
epsilon (float) – The epsilon value.
- Return type
bool
- Returns
True if the vectors are equal.
-
c4d.utils.
Bias
(b, x)¶ Returns the bias as the defined in the book “Texturing and Modeling” by Ebert.
The internal code:
import math def Bias(b, x): return math.pow(x, -math.log(b) / 0.693147180559945)
- Parameters
b (number) – Bias value.
x (number) – The real value.
- Return type
float
- Returns
The bias.
-
c4d.utils.
FCut
(a, b, c)¶ Limit the value of a to between b and c.
- Parameters
a (float) – Value
b (float) – Lower bound
c (float) – Upper bound
-
c4d.utils.
CutColor
(vec)¶ Limit a color vector between 0.0 and 1.0.
- Parameters
vec (c4d.Vector) – Bias value.
- Return type
- Returns
The limited color vector.
-
c4d.utils.
Truncate
(x)¶ Limit a color vector between 0.0 and 1.0.
The internal code:
import c4d import math # Internal code of c4d.utils.Truncate def Truncate(x): if x >= 0.0: return math.floor(x) else: return math.fceil(x) print c4d.utils.Truncate(1.5) == Truncate(1.5)
- Parameters
x (number) – The value to truncate.
- Return type
float
- Returns
The truncated value.
-
c4d.utils.
VectorSum
(vec)¶ Sum the vector components.
- Parameters
x (c4d.Vector) – A color
- Return type
float
- Returns
The sum of the components.
-
c4d.utils.
VectorGray
(vec)¶ Sum the vector components and multiply by 1/3.
- Parameters
vec (c4d.Vector) – A color
- Return type
float
- Returns
The gray value.
-
c4d.utils.
VectorAngle
(vec1, vec2)¶ Calculates the angle between two vectors in radians.
- Parameters
vec1 (c4d.Vector) – The first vector.
vec2 (c4d.Vector) – The second vector.
- Return type
float
- Returns
The angle in radians.
-
c4d.utils.
VectorMin
(vec)¶ Find the minimum component of the vector.
- Parameters
vec (c4d.Vector) – The vector to find the minimum component of.
- Return type
float
- Returns
The minimum component of the vector.
-
c4d.utils.
VectorMax
(vec)¶ Find the maximum component of the vector.
- Parameters
vec (c4d.Vector) – The vector to find the maximum component of.
- Return type
float
- Returns
The maximum component of the vector.
-
c4d.utils.
MatrixMove
(vec)¶ Create a translation matrix.
- Parameters
vec (c4d.Vector) – The translation vector.
- Return type
- Returns
The translation matrix.
-
c4d.utils.
MatrixScale
(s)¶ Create a scaling matrix.
- Parameters
s (c4d.Vector) – The scaling vector for the axes.
- Return type
- Returns
The scaling matrix.
-
c4d.utils.
VectorToHPB
(p)¶ Calculate euler angles from the vector p. The bank is always set to 0.0.
- Parameters
p (c4d.Vector) – The vector to find the HPB for.
- Return type
- Returns
The rotation HPB.
-
c4d.utils.
MatrixToHPB
(m, order=ROTATIONORDER_DEFAULT)¶ Calculate euler angles from the matrix m.
- Parameters
m (c4d.Matrix) – The rotation matrix.
order (int) –
The order of rotation:
ROTATIONORDER_YXZGLOBAL
Global YXZ order.
ROTATIONORDER_YZXGLOBAL
Global YZX order.
ROTATIONORDER_ZYXGLOBAL
Global ZYX order.
ROTATIONORDER_ZXYGLOBAL
Global ZXY order.
ROTATIONORDER_XZYGLOBAL
Global XZY order.
ROTATIONORDER_XYZGLOBAL
Global XYZ order.
ROTATIONORDER_YXZLOCAL
Local YXZ order.
ROTATIONORDER_YZXLOCAL
Local YZX order.
ROTATIONORDER_ZYXLOCAL
Local ZYX order.
ROTATIONORDER_ZXYLOCAL
Local ZXY order.
ROTATIONORDER_XZYLOCAL
Local XZY order.
ROTATIONORDER_XYZLOCAL
Local XYZ order.
ROTATIONORDER_HPB
HPB order.
ROTATIONORDER_DEFAULT
Default order. ROTATIONORDER_HPB.
- Return type
- Returns
The HPB.
-
c4d.utils.
HPBToMatrix
(hpb, order=ROTATIONORDER_DEFAULT)¶ Construct matrix from the euler angles hpb.
- Parameters
hpb (c4d.Vector) – The input HPB.
order (int) –
The order of rotation:
ROTATIONORDER_YXZGLOBAL
Global YXZ order.
ROTATIONORDER_YZXGLOBAL
Global YZX order.
ROTATIONORDER_ZYXGLOBAL
Global ZYX order.
ROTATIONORDER_ZXYGLOBAL
Global ZXY order.
ROTATIONORDER_XZYGLOBAL
Global XZY order.
ROTATIONORDER_XYZGLOBAL
Global XYZ order.
ROTATIONORDER_YXZLOCAL
Local YXZ order.
ROTATIONORDER_YZXLOCAL
Local YZX order.
ROTATIONORDER_ZYXLOCAL
Local ZYX order.
ROTATIONORDER_ZXYLOCAL
Local ZXY order.
ROTATIONORDER_XZYLOCAL
Local XZY order.
ROTATIONORDER_XYZLOCAL
Local XYZ order.
ROTATIONORDER_HPB
HPB order.
ROTATIONORDER_DEFAULT
Default order. ROTATIONORDER_HPB.
- Return type
- Returns
The rotation matrix.
-
c4d.utils.
CalcLOD
(val, lod, min, max)¶ This is a helper function to modify a user chosen subdivision value.
For example:
sub = c4d.utils.CalcLOD(op[TUBEOBJECT_SUB, 1], hh["lod"], 1, 1000)
- Parameters
val (int) – The user chosen lod value.
lod (float) – The LOD value.
min (int) – The minimum lod.
max (int) – The maximum lod.
-
c4d.utils.
CompareFloatTolerant
(a, b)¶ Compares if two floats are close to each other on a bit basis (rather than a fixed epsilon).
- Parameters
a (float) – The first parameter.
b (float) – The second parameter.
- Return type
bool
- Returns
True if a and b are sufficiently close to each other, otherwise False.
-
c4d.utils.
SinCos
(w)¶ Get sine and cosine of w:
import c4d sn, cs = c4d.utils.SinCos(80)
- Parameters
w (float) – Value.
- Return type
list
- Returns
Sine and Cosine.
-
c4d.utils.
TransformColor
(input, colortransformation)¶ Transforms a color from one color profile to another.
- Parameters
input (c4d.Vector) – The color to transform.
colortransformation (int) –
Transformation mode:
COLORSPACETRANSFORMATION_NONE
None.
COLORSPACETRANSFORMATION_LINEAR_TO_SRGB
Linear to sRGB color space transformation.
COLORSPACETRANSFORMATION_SRGB_TO_LINEAR
sRGB to linear color space transformation.
COLORSPACETRANSFORMATION_LINEAR_TO_VIEW
Linear to display color space transformation.
COLORSPACETRANSFORMATION_SRGB_TO_VIEW
sRGB to display color space transformation.
- Return type
- Returns
The transformed color.
-
c4d.utils.
CalculateTranslationScale
(src, dst)¶ Calculates the scale between src and dst.
Note
Both src and dst have to be of the same type: either
c4d.documents.BaseDocument
orc4d.UnitScaleData
.- Parameters
src (Union[c4d.documents.BaseDocument, c4d.UnitScaleData]) – The source document or unit scale data.
dst (Union[c4d.documents.BaseDocument, c4d.UnitScaleData]) – The destination document or unit scale data.
- Return type
float
- Returns
The scale.
-
c4d.utils.
SphereLineIntersection
(linePoint1, linePoint2, sphereCenter, sphereRadius)¶ Calculates the intersection points between a line and a sphere in 3D space.
New in version R16.021.
- Parameters
linePoint1 (c4d.Vector) – The first point of the line.
linePoint2 (c4d.Vector) – The second point of the line.
sphereCenter (c4d.Vector) – The center of the sphere.
sphereRadius (float) – The radius of the sphere.
- Return type
Tuple[bool, float, float, c4d.Vector, c4d.Vector]
- Returns
A tuple with the following information:
bool: True if the line segment intersected the sphere, otherwise False.
float: The first intersection point (lowest) as an offset between linePoint1 and linePoint2.
float: The second intersection point (highest) as an offset between linePoint1 and linePoint2.
Vector
: The actual 3D point where the line first intersects (enters) the sphere.Vector
: The actual 3D point where the line subsequently intersects (exits) the sphere.
-
c4d.utils.
CircleLineIntersection
(linePoint1, linePoint2, circleCenter, circleRadius)¶ Calculates the intersection points between a line and a circle in 2D space (although Z will also be calculated on the resulting hit points).
New in version R16.021.
- Parameters
linePoint1 (c4d.Vector) – The first point of the line.
linePoint2 (c4d.Vector) – The second point of the line.
circleCenter (c4d.Vector) – The center of the circle.
circleRadius (float) – The radius of the circle.
- Return type
Tuple[bool, float, float, c4d.Vector, c4d.Vector]
- Returns
A tuple with the following information:
bool: True if the line segment intersected the circle, otherwise False.
float: The first intersection point (lowest) as an offset between linePoint1 and linePoint2.
float: The second intersection point (highest) as an offset between linePoint1 and linePoint2.
Vector
: The actual 3D point where the line first intersects (enters) the circle, Z may also be calculated.Vector
: The actual 3D point where the line subsequently intersects (exits) the circle, Z may also be calculated.
-
c4d.utils.
PointLineSegmentDistance
(segmentPoint1, segmentPoint2, pos)¶ Calculates the distance from a point to a line segment between two points.
New in version R17.048.
- Parameters
segmentPoint1 (c4d.Vector) – The line segment first point.
segmentPoint2 (c4d.Vector) – The line segment second point.
pos (c4d.Vector) – The point to test against the line segment.
- Return type
Tuple[float,c4d.Vector, float]
- Returns
A tuple with the following information:
The distance between the point and the line segment.
The intersection point on the segment.
The offset along the segment of the intersection point.
-
c4d.utils.
PointLineSegmentDistance2D
(segmentPoint1, segmentPoint2, pos)¶ Calculates the distance from a point to a line segment between two points in 2D ignoring the Z value.
New in version R17.048.
- Parameters
segmentPoint1 (c4d.Vector) – The line segment first point.
segmentPoint2 (c4d.Vector) – The line segment second point.
pos (c4d.Vector) – The point to test against the line segment.
- Return type
Tuple[float, c4d.Vector, float]
- Returns
A tuple with the following information:
The distance between the point and the line segment.
The intersection point on the segment.
The offset along the segment of the intersection point.
-
c4d.utils.
InitBakeTexture
(doc, textags, texuvws, destuvws, bc, th=None)¶ Initializes a bake operation of a single tag for
BakeTexture()
.New in version R18.011.
- Parameters
doc (c4d.documents.BaseDocument) – The document.
textags (c4d.TextureTag) – The texture tag(s) to bake. Must be assigned to an object.
texuvws (c4d.UVWTag) – The UVW tag(s) to bake. Must be valid if UVW projection is selected in the texture tag(s), ignored otherwise.
destuvws (Optional[c4d.UVWTag]) – The destination UVW tag for the bake. If not None, the current projection is transformed into the UVW tag.
bc (c4d.BaseContainer) –
The bake settings:
BAKE_TEX_USE_CAMERA_VECTOR
bool
Use camera vector.
BAKE_TEX_USE_POLYSELECTION
bool
Use polygon selection.
BAKE_TEX_AMBIENT_OCCLUSION
bool
Bake ambient occlusion.
BAKE_TEX_NORMAL
bool
Bake normal channel.
BAKE_TEX_SURFACECOLOR
bool
Bake surface color.
BAKE_TEX_COLOR
bool
Bake color.
BAKE_TEX_DIFFUSION
bool
Bake diffusion channel.
BAKE_TEX_LUMINANCE
bool
Bake luminance.
BAKE_TEX_ALPHA
bool
Bake alpha channel.
BAKE_TEX_ILLUMINATION
bool
Bake illumination.
BAKE_TEX_SHADOWS
bool
Bake shadows.
BAKE_TEX_BUMP
bool
Bake bump.
BAKE_TEX_TRANSPARENCY
bool
Bake transparency.
BAKE_TEX_UVMAP
bool
Bake UV map.
BAKE_TEX_REFLECTION
bool
Bake reflection.
BAKE_TEX_DISPLACEMENT
bool
Bake displacement.
BAKE_TEX_WIDTH
int
Width.
BAKE_TEX_HEIGHT
int
Height.
BAKE_TEX_PIXELBORDER
int
Pixel border.
BAKE_TEX_FILL_COLOR
Fill color.
BAKE_TEX_UV_LEFT
float
Left UV coordinate.
BAKE_TEX_UV_RIGHT
float
Right UV coordinate.
BAKE_TEX_UV_TOP
float
Top UV coordinate.
BAKE_TEX_UV_BOTTOM
float
Bottom UV coordinate.
BAKE_TEX_SUPERSAMPLING
int
Supersampling.
BAKE_TEX_USE_BUMP
bool
Use bump.
BAKE_TEX_NO_GI
bool
No GI.
BAKE_TEX_CONTINUE_UV
bool
Continue UV.
BAKE_TEX_USE_PHONG_TAG
bool
The pixel will be clamped to the current polygon if set to True and if the angle between polygons is bigger than their phong angle. Only needed if BAKE_TEX_CONTINUE_UV is set to True.
BAKE_TEX_COLORPROFILE
Color profile of the baked texture.
BAKE_TEX_SHOW_STATUS
bool
Show status.
BAKE_TEX_PROGRESS_BITMAP
bool
Show the bitmap in a preview during baking.
BAKE_TEX_GENERATE_UNDO
bool
Generate undo for UVW tags and Vertex tags created by the baker.
BAKE_TEX_PREVIEW
bool
Bake texture preview.
BAKE_TEX_COLOR_ILLUM
bool
Illumination in color.
BAKE_TEX_COLOR_SHADOWS
bool
Shadows in color.
BAKE_TEX_COLOR_LUMINANCE
bool
Luminance in color.
BAKE_TEX_COLOR_DIFFUSION
bool
Diffusion in color.
BAKE_TEX_LUMINANCE_DIFFUSION
bool
Diffusion in luminance.
BAKE_TEX_ILLUMINATION_SHADOWS
bool
Shadows in luminance.
BAKE_TEX_NORMAL_METHOD
int
Normal method:
BAKE_TEX_NORMAL_METHOD_OBJECT
Object.
BAKE_TEX_NORMAL_METHOD_TANGENT
Tangent.
BAKE_TEX_NORMAL_METHOD_WORLD
World.
BAKE_TEX_NORMAL_FLIP_X
bool
Flip X.
BAKE_TEX_NORMAL_FLIP_Y
bool
Flip Y.
BAKE_TEX_NORMAL_FLIP_Z
bool
Flip Z.
BAKE_TEX_NORMAL_SWAP_YZ
bool
Swap Y/Z.
BAKE_TEX_NORMAL_SOURCE
link
Normal source.
BAKE_TEX_NORMAL_USE_RAYCAST
bool
New in version R18: Whether the normal map will be generated using ray casting. True when baking the normal map only.
BAKE_TEX_SURFACE_ILLUMINATION
bool
Surface illumination.
BAKE_TEX_AO_VERTEX_MAP
bool
Ambient occlusion in vertex map.
BAKE_TEX_AO_SELFINTERSECTION
bool
Ambient occlusion self-intersection.
BAKE_TEX_AO_VERTEXMAPS
A container that stores all new generated vertex maps.
BAKE_TEX_DISPLACEMENT_SOURCE
link
The high-res source object.
BAKE_TEX_DISPLACEMENT_HEIGHT
float
A float that will receive the displacement height.
BAKE_TEX_DISPLACEMENT_METHOD
int
Displacement method:
BAKE_TEX_DISPLACEMENT_METHOD_OBJECT
Object.
BAKE_TEX_DISPLACEMENT_METHOD_WORLD
World.
BAKE_TEX_DISPLACEMENT_METHOD_TANGENT
Tangent.
BAKE_TEX_DISPLACEMENT_METHOD_INTENSITY
Intensity.
BAKE_TEX_DISPLACEMENT_METHOD_CENTEREDINTENSITY
Centered intensity.
BAKE_TEX_DISPLACEMENT_METHOD_REDGREEN
Red <-> Green.
BAKE_TEX_DISPLACEMENT_SUBPOLY
bool
Displacement subpoly.
BAKE_TEX_DISPLACEMENT_SUBPOLY_SUBDIVISION
int
Displacement subpoly subdivision.
BAKE_TEX_DISPLACEMENT_SUBPOLY_ROUND
bool
Displacement subpoly round.
BAKE_TEX_DISPLACEMENT_SUBPOLY_ROUNDCONTOUR
bool
Displacement subpoly round contour.
BAKE_TEX_DISPLACEMENT_SUBPOLY_HQREMAPPING
bool
Displacement subpoly HQ remapping.
BAKE_TEX_DISPLACEMENT_SUBPOLY_MAPRESULT
bool
Displacement subpoly map result.
BAKE_TEX_DISPLACEMENT_SUBPOLY_KEEPEDGES
bool
Displacement subpoly keep edges.
BAKE_TEX_DISPLACEMENT_SUBPOLY_DISTRIBUTION
bool
Displacement subpoly distribution.
BAKE_TEX_RAYCAST_USE_MAX_DISTANCE
bool
New in version R18: Use maximum ray casting distance.
BAKE_TEX_RAYCAST_CUSTOM_MAX_DISTANCE
float
New in version R18: Custom maximum ray casting distance.
BAKE_TEX_RAYCAST_USE_AUTO_SPIKE_FILTER_THRESHOLD
bool
New in version R18: Use automatic spike filter threshold.
BAKE_TEX_RAYCAST_CUSTOM_SPIKE_FILTER_THRESHOLD
float
New in version R18: Custom spike filter threshold.
BAKE_TEX_OPTIMAL_MAPPING
int
Optimal mapping:
BAKE_TEX_OPTIMAL_MAPPING_OFF
Off.
BAKE_TEX_OPTIMAL_MAPPING_CUBIC
Cubic.
BAKE_TEX_OPTIMAL_MAPPING_ANGLE
Angle.
BAKE_TEX_OPTIMAL_MAPPING_PACKED
Packed.
BAKE_TEX_OPTIMAL_MAPPING_RELAXCOUNT
int
Optimal mapping relax count.
BAKE_TEX_OPTIMAL_MAPPING_PREVIEW
int
Optimal mapping preview.
BAKE_TEX_NO_INIT_BITMAP
bool
Set to True if the passed
MultipassBitmap
is already initialized.BAKE_TEX_AUTO_SIZE
bool
Auto size.
BAKE_TEX_AUTO_SIZE_MIN
int
Minimum auto size.
BAKE_TEX_AUTO_SIZE_MAX
int
Maximum auto size.
BAKE_TEX_AUTO_PIXEL_SIZE
float
Automatic pixel size.
BAKE_TEX_STATUSBAR
str
Status bar text.
th (Optional[c4d.threading.BaseThread]) – The optional thread. Can be None. New in version R18.039.
- Return type
Tuple[c4d.documents.BaseDocument, int]
- Returns
A tuple with the following information:
c4d.documents.BaseDocument
: The document for the bake to use for the call toBakeTexture()
.int: The error result. BAKE_TEX_ERR_NONE if successful, otherwise one of these errors:BAKE_TEX_ERR_NONE
None.
BAKE_TEX_ERR_NO_DOC
No document.
BAKE_TEX_ERR_NO_MEM
No more memory available.
BAKE_TEX_ERR_NO_RENDER_DOC
No render document.
BAKE_TEX_ERR_NO_TEXTURE_TAG
textag is None or not in doc.
BAKE_TEX_ERR_NO_OBJECT
One of the tags is not assigned to an object or to another object.
BAKE_TEX_ERR_NO_UVW_TAG
UVW tag is missing.
BAKE_TEX_ERR_TEXTURE_MISSING
No texture.
BAKE_TEX_ERR_WRONG_BITMAP
MultipassBitmap
was used, but it has the wrong type or wrong resolution.BAKE_TEX_ERR_USERBREAK
User break.
BAKE_TEX_ERR_NO_OPTIMAL_MAPPING
Optimal mapping failed.
BAKE_TEX_ERR_NO_SOURCE_UVW_TAG
UVW tag for the source object is missing.
-
c4d.utils.
BakeTexture
(doc, data, bmp, th, hook)¶ Bakes the texture(s) specified by the last
InitBakeTexture()
call into bmp.New in version R18.011.
- Parameters
doc (c4d.documents.BaseDocument) – The document.
data (c4d.BaseContainer) –
The bake settings:
BAKE_TEX_USE_CAMERA_VECTOR
bool
Use camera vector.
BAKE_TEX_USE_POLYSELECTION
bool
Use polygon selection.
BAKE_TEX_AMBIENT_OCCLUSION
bool
Bake ambient occlusion.
BAKE_TEX_NORMAL
bool
Bake normal channel.
BAKE_TEX_SURFACECOLOR
bool
Bake surface color.
BAKE_TEX_COLOR
bool
Bake color.
BAKE_TEX_DIFFUSION
bool
Bake diffusion channel.
BAKE_TEX_LUMINANCE
bool
Bake luminance.
BAKE_TEX_ALPHA
bool
Bake alpha channel.
BAKE_TEX_ILLUMINATION
bool
Bake illumination.
BAKE_TEX_SHADOWS
bool
Bake shadows.
BAKE_TEX_BUMP
bool
Bake bump.
BAKE_TEX_TRANSPARENCY
bool
Bake transparency.
BAKE_TEX_UVMAP
bool
Bake UV map.
BAKE_TEX_REFLECTION
bool
Bake reflection.
BAKE_TEX_DISPLACEMENT
bool
Bake displacement.
BAKE_TEX_WIDTH
int
Width.
BAKE_TEX_HEIGHT
int
Height.
BAKE_TEX_PIXELBORDER
int
Pixel border.
BAKE_TEX_FILL_COLOR
Fill color.
BAKE_TEX_UV_LEFT
float
Left UV coordinate.
BAKE_TEX_UV_RIGHT
float
Right UV coordinate.
BAKE_TEX_UV_TOP
float
Top UV coordinate.
BAKE_TEX_UV_BOTTOM
float
Bottom UV coordinate.
BAKE_TEX_SUPERSAMPLING
int
Supersampling.
BAKE_TEX_USE_BUMP
bool
Use bump.
BAKE_TEX_NO_GI
bool
No GI.
BAKE_TEX_CONTINUE_UV
bool
Continue UV.
BAKE_TEX_USE_PHONG_TAG
bool
The pixel will be clamped to the current polygon if set to True and if the angle between polygons is bigger than their phong angle. Only needed if BAKE_TEX_CONTINUE_UV is set to True.
BAKE_TEX_COLORPROFILE
Color profile of the baked texture.
BAKE_TEX_SHOW_STATUS
bool
Show status.
BAKE_TEX_PROGRESS_BITMAP
bool
Show the bitmap in a preview during baking.
BAKE_TEX_GENERATE_UNDO
bool
Generate undo for UVW tags and Vertex tags created by the baker.
BAKE_TEX_PREVIEW
bool
Bake texture preview.
BAKE_TEX_COLOR_ILLUM
bool
Illumination in color.
BAKE_TEX_COLOR_SHADOWS
bool
Shadows in color.
BAKE_TEX_COLOR_LUMINANCE
bool
Luminance in color.
BAKE_TEX_COLOR_DIFFUSION
bool
Diffusion in color.
BAKE_TEX_LUMINANCE_DIFFUSION
bool
Diffusion in luminance.
BAKE_TEX_ILLUMINATION_SHADOWS
bool
Shadows in luminance.
BAKE_TEX_NORMAL_METHOD
int
Normal method:
BAKE_TEX_NORMAL_METHOD_OBJECT
Object.
BAKE_TEX_NORMAL_METHOD_TANGENT
Tangent.
BAKE_TEX_NORMAL_METHOD_WORLD
World.
BAKE_TEX_NORMAL_FLIP_X
bool
Flip X.
BAKE_TEX_NORMAL_FLIP_Y
bool
Flip Y.
BAKE_TEX_NORMAL_FLIP_Z
bool
Flip Z.
BAKE_TEX_NORMAL_SWAP_YZ
bool
Swap Y/Z.
BAKE_TEX_NORMAL_SOURCE
link
Normal source.
BAKE_TEX_NORMAL_USE_RAYCAST
bool
New in version R18: Whether the normal map will be generated using ray casting. True when baking the normal map only.
BAKE_TEX_SURFACE_ILLUMINATION
bool
Surface illumination.
BAKE_TEX_AO_VERTEX_MAP
bool
Ambient occlusion in vertex map.
BAKE_TEX_AO_SELFINTERSECTION
bool
Ambient occlusion self-intersection.
BAKE_TEX_AO_VERTEXMAPS
A container that stores all new generated vertex maps.
BAKE_TEX_DISPLACEMENT_SOURCE
link
The high-res source object.
BAKE_TEX_DISPLACEMENT_HEIGHT
float
A float that will receive the displacement height.
BAKE_TEX_DISPLACEMENT_METHOD
int
Displacement method:
BAKE_TEX_DISPLACEMENT_METHOD_OBJECT
Object.
BAKE_TEX_DISPLACEMENT_METHOD_WORLD
World.
BAKE_TEX_DISPLACEMENT_METHOD_TANGENT
Tangent.
BAKE_TEX_DISPLACEMENT_METHOD_INTENSITY
Intensity.
BAKE_TEX_DISPLACEMENT_METHOD_CENTEREDINTENSITY
Centered intensity.
BAKE_TEX_DISPLACEMENT_METHOD_REDGREEN
Red <-> Green.
BAKE_TEX_DISPLACEMENT_SUBPOLY
bool
Displacement subpoly.
BAKE_TEX_DISPLACEMENT_SUBPOLY_SUBDIVISION
int
Displacement subpoly subdivision.
BAKE_TEX_DISPLACEMENT_SUBPOLY_ROUND
bool
Displacement subpoly round.
BAKE_TEX_DISPLACEMENT_SUBPOLY_ROUNDCONTOUR
bool
Displacement subpoly round contour.
BAKE_TEX_DISPLACEMENT_SUBPOLY_HQREMAPPING
bool
Displacement subpoly HQ remapping.
BAKE_TEX_DISPLACEMENT_SUBPOLY_MAPRESULT
bool
Displacement subpoly map result.
BAKE_TEX_DISPLACEMENT_SUBPOLY_KEEPEDGES
bool
Displacement subpoly keep edges.
BAKE_TEX_DISPLACEMENT_SUBPOLY_DISTRIBUTION
bool
Displacement subpoly distribution.
BAKE_TEX_RAYCAST_USE_MAX_DISTANCE
bool
New in version R18: Use maximum ray casting distance.
BAKE_TEX_RAYCAST_CUSTOM_MAX_DISTANCE
float
New in version R18: Custom maximum ray casting distance.
BAKE_TEX_RAYCAST_USE_AUTO_SPIKE_FILTER_THRESHOLD
bool
New in version R18: Use automatic spike filter threshold.
BAKE_TEX_RAYCAST_CUSTOM_SPIKE_FILTER_THRESHOLD
float
New in version R18: Custom spike filter threshold.
BAKE_TEX_OPTIMAL_MAPPING
int
Optimal mapping:
BAKE_TEX_OPTIMAL_MAPPING_OFF
Off.
BAKE_TEX_OPTIMAL_MAPPING_CUBIC
Cubic.
BAKE_TEX_OPTIMAL_MAPPING_ANGLE
Angle.
BAKE_TEX_OPTIMAL_MAPPING_PACKED
Packed.
BAKE_TEX_OPTIMAL_MAPPING_RELAXCOUNT
int
Optimal mapping relax count.
BAKE_TEX_OPTIMAL_MAPPING_PREVIEW
int
Optimal mapping preview.
BAKE_TEX_NO_INIT_BITMAP
bool
Set to True if the passed
MultipassBitmap
is already initialized.BAKE_TEX_AUTO_SIZE
bool
Auto size.
BAKE_TEX_AUTO_SIZE_MIN
int
Minimum auto size.
BAKE_TEX_AUTO_SIZE_MAX
int
Maximum auto size.
BAKE_TEX_AUTO_PIXEL_SIZE
float
Automatic pixel size.
BAKE_TEX_STATUSBAR
str
Status bar text.
bmp (c4d.bitmaps.BaseBitmap) – The bitmap to bake to.
th (Optional[c4d.threading.BaseThread]) – The current thread. Can be None.
hook (Optional[Callable[[Dict[]], Optional[bool]]]) –
The bake progress hook callback function. This function gets passed a dictionary with the following information:
’version’
int
Bake version.
’state’
int
Bake state:
BAKE_STATE_NONE
None.
BAKE_STATE_PREPARE
Prepare.
BAKE_STATE_GI_PREPASS
GI prepass.
BAKE_STATE_FILL_IMAGE
Fill image.
BAKE_STATE_COMPLETE
Complete.
BAKE_STATE_INITIALIZE
Initialize.
BAKE_STATE_RESIZENOTIFY
Resize notify.
’data’
tuple(int, int,
BaseBitmap
)Only used in case of BAKE_STATE_RESIZENOTIFY state. Tuple data is resize width, resize height and cake bitmap.
’timedelta’
int
Time.
’r’
float
Progress, between 0 and 1.
’starttime’
int
Start time in milliseconds.
If the state is BAKE_STATE_RESIZENOTIFY, the return value has to be a bool to set the result of the resize operation. Otherwise the hook must return None.
- Return type
int
- Returns
BAKE_TEX_ERR_NONE if successful, otherwise one of these errors:
BAKE_TEX_ERR_NONE
None.
BAKE_TEX_ERR_NO_DOC
No document.
BAKE_TEX_ERR_NO_MEM
No more memory available.
BAKE_TEX_ERR_NO_RENDER_DOC
No render document.
BAKE_TEX_ERR_NO_TEXTURE_TAG
textag is None or not in doc.
BAKE_TEX_ERR_NO_OBJECT
One of the tags is not assigned to an object or to another object.
BAKE_TEX_ERR_NO_UVW_TAG
UVW tag is missing.
BAKE_TEX_ERR_TEXTURE_MISSING
No texture.
BAKE_TEX_ERR_WRONG_BITMAP
MultipassBitmap
was used, but it has the wrong type or wrong resolution.BAKE_TEX_ERR_USERBREAK
User break.
BAKE_TEX_ERR_NO_OPTIMAL_MAPPING
Optimal mapping failed.
BAKE_TEX_ERR_NO_SOURCE_UVW_TAG
UVW tag for the source object is missing.