#include <c4d_shader.h>
Texture information.
Note Has to be created with Alloc() and destroyed with Free() . Use AutoAlloc to automate the allocation and destruction based on scope.
The ox , oy and m values may differ from the values specified in the dialog, these are a precalculated raytracer representation. To better understand the meaning of those values please print this routine (it is the projection routine in source code):
{
Float lenxinv=0.0,lenyinv=0.0;
if (tdp->
lenx !=0.0) lenxinv = 1.0/tdp->
lenx ;
if (tdp->
leny !=0.0) lenyinv = 1.0/tdp->
leny ;
{
{
return true ;
}
{
if (sq==0.0)
{
else
}
else
{
if (d.
z <0.0) uv->
x = 1.0-uv->
x ;
if (tdp->
lenx >0.0 && uv->
x <0.0)
else if (tdp->
lenx <0.0 && uv->
x >0.0)
}
uv->
y = -(uv->
y +tdp->
oy )*lenyinv;
break ;
}
{
if (sq==0.0)
{
else
}
else
{
if (d.
z <0.0) uv->
x = 1.0-uv->
x ;
}
uv->
x = (0.5 + 0.5*cs*uv->
y - tdp->
ox )*lenxinv;
uv->
y = (0.5 + 0.5*sn*uv->
y - tdp->
oy )*lenyinv;
break ;
}
{
if (sq==0.0)
else
{
if (d.
z <0.0) uv->
x = 1.0-uv->
x ;
if (tdp->
lenx >0.0 && uv->
x <0.0)
else if (tdp->
lenx <0.0 && uv->
x >0.0)
}
uv->
y = -(d.
y *0.5+tdp->
oy )*lenyinv;
break ;
}
{
uv->
x = (d.
x *0.5-tdp->
ox )*lenxinv;
uv->
y = -(d.
y *0.5+tdp->
oy )*lenyinv;
break ;
}
{
{
dir = 0;
else
dir = 2;
}
else
{
dir = 1;
else
dir = 2;
}
switch (dir)
{
case 0:
{
uv->
x = (-d.
z *0.5-tdp->
ox )*lenxinv;
else
uv->
x = ( d.
z *0.5-tdp->
ox )*lenxinv;
uv->
y = -(d.
y *0.5+tdp->
oy )*lenyinv;
break ;
}
case 1:
{
uv->
y = ( d.
z *0.5-tdp->
oy )*lenyinv;
else
uv->
y = (-d.
z *0.5-tdp->
oy )*lenyinv;
uv->
x = (d.
x *0.5-tdp->
ox )*lenxinv;
break ;
}
case 2:
{
uv->
x = ( d.
x *0.5-tdp->
ox )*lenxinv;
else
uv->
x = (-d.
x *0.5-tdp->
ox )*lenxinv;
uv->
y = -(d.
y *0.5+tdp->
oy )*lenyinv;
break ;
}
}
break ;
}
{
sd->
GetXY (&curr_x,&curr_y,&scl);
break ;
}
{
else
break ;
}
}
return true ;
else
return uv->
x >=0.0 && uv->
x <=1.0 && uv->
y >=0.0 && uv->
y <=1.0;
}
◆ TexData()
◆ ~TexData()
◆ Alloc()
Allocates a texture data. Destroy the allocated texture data with Free() . Use AutoAlloc to automate the allocation and destruction based on scope.
Returns The allocated texture data, or nullptr if the allocation failed.
◆ Free()
Destructs texture data allocated with Alloc() . Use AutoAlloc to automate the allocation and destruction based on scope.
Parameters
[in] td The texture data to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.
◆ Init()
Initializes the structure.
The texture projection matrix.
Note This actual value may differ from those specified in the dialog, these are a precalculated raytracer representation.
◆ im
The inverse of the texture projection matrix.
◆ texflag
◆ additive
true to mix with other textures.
◆ proj
◆ side
◆ restrict
This is either 0 for no restriction or the index to a restriction in a RayObject
To check if global polygon id
applies to TexData tex
using VolumeData sd
use the following:
if (tex->restrict)
{
return false ;
sd->ID_to_Obj(id ,&num);
if (!(sd->
op ->
rsadr [tex->restrict][num>>5]&(1<<(num&31))))
return false ;
}
return true ;
◆ ox
The X offset of the texture.
Note This actual value may differ from the one specified in the dialog, these are a precalculated raytracer representation.
◆ oy
The Y offset of the texture.
Note This actual value may differ from the one specified in the dialog, these are a precalculated raytracer representation.
◆ lenx
The X length of the texture.
◆ leny
The Y length of the texture.
◆ repetitionx
The repetition of U tiling.
◆ repetitiony
The repetition of V tiling.
◆ mp
The material.
Note Make sure to cast this to the right material type before using it.
◆ uvwind
◆ camera
◆ uvbump
◆ link
The originating texture tag.
◆ invLenx
The inverted X length of the texture.
Since R19.SP2
◆ invLeny
The inverted Y length of the texture.
Since R19.SP2
◆ parallaxUVW
true if the UVW coordinates are changed by Parallax Mapping, otherwise false .
Since R19.SP2
void GetXY(Int32 *x, Int32 *y, Int32 *scale) const
Definition: c4d_tools.h:1777
Float32 ATan(Float32 val)
Definition: apibasemath.h:165
Float leny
The Y length of the texture.
Definition: c4d_shader.h:540
const RayParameter * GetRayParameter() const
Definition: c4d_tools.h:1651
static const Float64 PI2
floating point constant: 2.0 * PI
Definition: apibasemath.h:142
Definition: c4d_raytrace.h:534
Float ox
Definition: c4d_shader.h:540
Int32 rscnt
Number of object's restriction.
Definition: c4d_raytrace.h:283
Definition: c4d_raytrace.h:238
#define P_SPATIAL
Spatial.
Definition: c4d_raytrace.h:23
Int32 uvwcnt
Number of UVW coordinate sets.
Definition: c4d_raytrace.h:278
Vector GetPointUVW(const TexData *tdp, const RayHitID &hit, const Vector64 &p) const
Definition: c4d_tools.h:1730
#define P_SPHERICAL
Spherical.
Definition: c4d_raytrace.h:18
maxon::Float Float
Definition: ge_sys_math.h:51
Float32 ACos(Float32 val)
Calculates arccosine. The input value is clipped for safety to avoid exceptions.
Definition: apibasemath.h:264
Matrix im
The inverse of the texture projection matrix.
Definition: c4d_shader.h:517
#define P_VOLUMESHADER
Volume.
Definition: c4d_raytrace.h:27
void SinCos(Float32 r, Float32 &sn, Float32 &cs)
Definition: apibasemath.h:285
Int32 yres
Image vertical resolution.
Definition: c4d_raytrace.h:540
#define P_CYLINDRICAL
Cylindrical.
Definition: c4d_raytrace.h:19
Float oy
Definition: c4d_shader.h:540
UInt32 ** rsadr
Definition: c4d_raytrace.h:280
Char texflag
The texture flags: TEX.
Definition: c4d_shader.h:519
#define P_CUBIC
Cubic.
Definition: c4d_raytrace.h:21
const void ** uvwadr
Definition: c4d_raytrace.h:275
Char type
Definition: c4d_raytrace.h:244
Int32 xres
Image horizontal resolution.
Definition: c4d_raytrace.h:540
Float lenx
The X length of the texture.
Definition: c4d_shader.h:540
#define P_FLAT
Flat.
Definition: c4d_raytrace.h:20
Definition: c4d_tools.h:1295
const RayObject * op
The object. Can be nullptr, always check.
Definition: c4d_shader.h:916
maxon::Int32 Int32
Definition: ge_sys_math.h:45
static const Float64 PI
floating point constant: PI
Definition: apibasemath.h:136
#define O_POLYGON
Polygon object. The points and polygons are stored in RayObject::padr and RayObject::vadr....
Definition: c4d_raytrace.h:37
#define TEX_TILE
Texture tile enabled.
Definition: c4d_shader.h:19
#define P_FRONTAL
Frontal.
Definition: c4d_raytrace.h:22
Float32 Abs(Float32 val)
Definition: apibasemath.h:210
Float32 Sqrt(Float32 val)
Definition: apibasemath.h:183
Definition: c4d_shader.h:509
#define P_UVW
UVW.
Definition: c4d_raytrace.h:24
maxon::Bool Bool
Definition: ge_sys_math.h:40
Int32 uvwind
The uvw index, access is through VolumeData::GetUVW().
Definition: c4d_shader.h:549
#define P_SHRINKWRAP
Shrinkwrap.
Definition: c4d_raytrace.h:25
Char proj
The texture projection: TextureProjectionTypes.
Definition: c4d_shader.h:520