TexData Struct Reference

#include <c4d_shader.h>

详细描述

Texture information.

注意
Has to be created with Alloc() and destroyed with Free() 。使用 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):

Bool ShdProjectPoint( VolumeData *sd, TexData *tdp, Int32 lhit, const 向量 &p, const 向量 &n, 向量 *uv) { 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 ;
switch (tdp-> proj ) { case P_VOLUMESHADER : { *uv = p * tdp-> im ; return true ; } case P_SPHERICAL : default : { 向量 d = p * tdp-> im ; Float sq = Sqrt (d. x *d. x + d. z *d. z ); if (sq==0.0) { uv-> x = 0.0; if (d. y >0.0) uv-> y = +0.5; else uv-> y = -0.5; } else { uv-> x = ACos (d. x /sq)/ PI2 ; if (d. z <0.0) uv-> x = 1.0-uv-> x ; uv-> x -= tdp-> ox ; if (tdp-> lenx >0.0 && uv-> x <0.0) uv-> x += 1.0; else if (tdp-> lenx <0.0 && uv-> x >0.0) uv-> x -= 1.0; uv-> x *= lenxinv; uv-> y = ATan (d. y /sq)/ PI ; } uv-> y = -(uv-> y +tdp-> oy )*lenyinv; break ; } case P_SHRINKWRAP : { 向量 d = p * tdp-> im ; Float sn,cs,sq = Sqrt (d. x *d. x + d. z *d. z ); if (sq==0.0) { uv-> x = 0.0; if (d. y >0.0) uv-> y = 0.0; else uv-> y = 1.0; } else { uv-> x = ACos (d. x /sq)/ PI2 ; if (d. z <0.0) uv-> x = 1.0-uv-> x ; uv-> y = 0.5- ATan (d. y /sq)/ PI ; } SinCos (uv-> x * PI2 ,sn,cs); 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 ; } case P_CYLINDRICAL : { 向量 d = p * tdp-> im ; Float sq = Sqrt (d. x *d. x + d. z *d. z ); if (sq==0.0) uv-> x = 0.0; else { uv-> x = ACos (d. x /sq)/ PI2 ; if (d. z <0.0) uv-> x = 1.0-uv-> x ; uv-> x -= tdp-> ox ; if (tdp-> lenx >0.0 && uv-> x <0.0) uv-> x += 1.0; else if (tdp-> lenx <0.0 && uv-> x >0.0) uv-> x -= 1.0; uv-> x *= lenxinv; } uv-> y = -(d. y *0.5+tdp-> oy )*lenyinv; break ; } case P_FLAT : case P_SPATIAL : { 向量 d = p * tdp-> im ; uv-> x = (d. x *0.5-tdp-> ox )*lenxinv; uv-> y = -(d. y *0.5+tdp-> oy )*lenyinv; break ; } case P_CUBIC : { 向量 d = p * tdp-> im ; 向量 v = n ^ tdp-> im ; Int32 dir; if ( Abs (v. x )> Abs (v. y )) { if ( Abs (v. x )> Abs (v. z )) dir = 0; else dir = 2; } else { if ( Abs (v. y )> Abs (v. z )) dir = 1; else dir = 2; } switch (dir) { case 0: // x axis { if (v. x <0.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: // y axis { if (v. y <0.0) 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: // z axis { if (v. z <0.0) 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 ; } case P_FRONTAL : { RayParameter *param=sd-> GetRayParameter (); Float ox =0.0, oy =0.0,ax=param-> xres ,ay=param-> yres ; Int32 curr_x,curr_y,scl; sd-> GetXY (&curr_x,&curr_y,&scl); uv-> x = (( Float (curr_x)/ Float (scl)- ox )/ax - tdp-> ox )*lenxinv; uv-> y = (( Float (curr_y)/ Float (scl)- ox )/ay - tdp-> oy )*lenyinv; break ; } case P_UVW : { RayObject *op=sd->ID_to_Obj(lhit, nullptr ); if (op && tdp-> uvwind <op-> uvwcnt && op-> uvwadr [tdp-> uvwind ]) *uv=sd-> GetPointUVW (tdp,lhit,p); else uv-> x = uv-> y = 0.0; break ; } } if (tdp-> texflag & TEX_TILE ) return true ; else return uv-> x >=0.0 && uv-> x <=1.0 && uv-> y >=0.0 && uv-> y <=1.0; }

公共成员函数

void  Init (void)

静态公共成员函数

static TexData Alloc ()
static void  Free ( TexData *&td)

Public Attributes

矩阵   m
矩阵   im
Char   texflag
Char   additive
Char   proj
Char   side
Int32   restrict
Float   ox
Float   oy
Float   lenx
Float   leny
Float   repetitionx
Float   repetitiony
GeListNode mp
Int32   uvwind
BaseView camera
Char   uvbump
BaseTag link
Float   invLenx
Float   invLeny
Bool   parallaxUVW

私有成员函数

  TexData ()
  ~TexData ()

构造函数 & 析构函数文档编制

◆  TexData()

TexData () private

◆  ~TexData()

~ TexData () private

成员函数文档编制

◆  Alloc()

static TexData * Alloc ( )
static

Allocates a texture data. Destroy the allocated texture data with Free() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

返回
The allocated texture data, or nullptr if the allocation failed.

◆  Free()

static void Free ( TexData *&  td )
static

Destructs texture data allocated with Alloc() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

参数
[in] td The texture data to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆  Init()

void Init ( void  )

Initializes the structure.

Member Data Documentation

◆  m

矩阵 m

The texture projection matrix.

注意
This actual value may differ from those specified in the dialog, these are a precalculated raytracer representation.

◆  im

矩阵 im

The inverse of the texture projection matrix.

◆  texflag

Char texflag

The texture flags: TEX .

◆  additive

Char additive

true to mix with other textures.

◆  proj

Char proj

The texture projection: TextureProjectionTypes .

◆  side

Char side

The side: SIDE .

◆  restrict

Int32 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) { if (!sd-> op || sd-> op -> type != O_POLYGON || tex->restrict>=sd-> op -> rscnt || !sd-> op -> rsadr [tex->restrict]) return false ; Int32 num; sd->ID_to_Obj( id ,&num); if (!(sd-> op -> rsadr [tex->restrict][num>>5]&(1<<(num&31)))) return false ; } return true ;

◆  ox

Float ox

The X offset of the texture.

注意
This actual value may differ from the one specified in the dialog, these are a precalculated raytracer representation.

◆  oy

Float oy

The Y offset of the texture.

注意
This actual value may differ from the one specified in the dialog, these are a precalculated raytracer representation.

◆  lenx

Float lenx

The X length of the texture.

◆  leny

Float leny

The Y length of the texture.

◆  repetitionx

Float repetitionx

The repetition of U tiling.

◆  repetitiony

Float repetitiony

The repetition of V tiling.

◆  mp

GeListNode * mp

The material.

注意
Make sure to cast this to the right material type before using it.

◆  uvwind

Int32 uvwind

The uvw index, access is through VolumeData::GetUVW() .

◆  camera

BaseView * camera

The current view.

◆  uvbump

Char uvbump

The direct boolean representation of TEXTURETAG_UVBUMP .

◆  link

BaseTag * link

The originating texture tag.

◆  invLenx

Float invLenx

The inverted X length of the texture.

由于
R19.SP2

◆  invLeny

Float invLeny

The inverted Y length of the texture.

由于
R19.SP2

◆  parallaxUVW

Bool parallaxUVW

true if the UVW coordinates are changed by Parallax Mapping, otherwise false .

由于
R19.SP2
VolumeData::GetXY
void GetXY(Int32 *x, Int32 *y, Int32 *scale) const
定义: c4d_tools.h:1781
ATan
Float32 ATan(Float32 val)
定义: apibasemath.h:141
TexData::leny
Float leny
The Y length of the texture.
定义: c4d_shader.h:547
VolumeData::GetRayParameter
const RayParameter * GetRayParameter() const
定义: c4d_tools.h:1655
RayParameter
定义: c4d_raytrace.h:538
TexData::ox
Float ox
定义: c4d_shader.h:543
RayObject::rscnt
Int32 rscnt
Number of object's restriction.
定义: c4d_raytrace.h:287
RayObject
定义: c4d_raytrace.h:242
P_SPATIAL
#define P_SPATIAL
Spatial.
定义: c4d_raytrace.h:27
RayObject::uvwcnt
Int32 uvwcnt
Number of UVW coordinate sets.
定义: c4d_raytrace.h:282
VolumeData::GetPointUVW
Vector GetPointUVW(const TexData *tdp, const RayHitID &hit, const Vector64 &p) const
定义: c4d_tools.h:1734
P_SPHERICAL
#define P_SPHERICAL
Spherical.
定义: c4d_raytrace.h:22
Float
maxon::Float Float
定义: ge_sys_math.h:64
ACos
Float32 ACos(Float32 val)
Calculates arccosine. The input value is clipped for safety to avoid exceptions.
定义: apibasemath.h:240
TexData::im
Matrix im
The inverse of the texture projection matrix.
定义: c4d_shader.h:521
P_VOLUMESHADER
#define P_VOLUMESHADER
Volume.
定义: c4d_raytrace.h:31
SinCos
void SinCos(Float32 r, Float32 &sn, Float32 &cs)
定义: apibasemath.h:261
RayParameter::yres
Int32 yres
Image vertical resolution.
定义: c4d_raytrace.h:545
P_CYLINDRICAL
#define P_CYLINDRICAL
Cylindrical.
定义: c4d_raytrace.h:23
TexData::oy
Float oy
定义: c4d_shader.h:545
RayObject::rsadr
UInt32 ** rsadr
定义: c4d_raytrace.h:284
TexData::texflag
Char texflag
The texture flags: TEX.
定义: c4d_shader.h:522
maxon::Vec3::z
T z
定义: vec.h:34
P_CUBIC
#define P_CUBIC
Cubic.
定义: c4d_raytrace.h:25
maxon::Vec3< maxon::Float64, 1 >
RayObject::uvwadr
const void ** uvwadr
定义: c4d_raytrace.h:279
RayObject::type
Char type
定义: c4d_raytrace.h:248
maxon::Vec3::x
T x
定义: vec.h:32
RayParameter::xres
Int32 xres
Image horizontal resolution.
定义: c4d_raytrace.h:544
PI
PI
定义: unicodeutils.h:18
TexData::lenx
Float lenx
The X length of the texture.
定义: c4d_shader.h:546
maxon::Vec3::y
T y
定义: vec.h:33
P_FLAT
#define P_FLAT
Flat.
定义: c4d_raytrace.h:24
VolumeData
定义: c4d_tools.h:1299
BaseVolumeData::op
const RayObject * op
The object. Can be nullptr, always check.
定义: c4d_shader.h:920
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
O_POLYGON
#define O_POLYGON
Polygon object. The points and polygons are stored in RayObject::padr and RayObject::vadr....
定义: c4d_raytrace.h:41
TEX_TILE
#define TEX_TILE
Texture tile enabled.
定义: c4d_shader.h:22
P_FRONTAL
#define P_FRONTAL
Frontal.
定义: c4d_raytrace.h:26
Abs
Float32 Abs(Float32 val)
定义: apibasemath.h:186
Sqrt
Float32 Sqrt(Float32 val)
定义: apibasemath.h:159
TexData
定义: c4d_shader.h:512
P_UVW
#define P_UVW
UVW.
定义: c4d_raytrace.h:28
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
TexData::uvwind
Int32 uvwind
The uvw index, access is through VolumeData::GetUVW().
定义: c4d_shader.h:552
P_SHRINKWRAP
#define P_SHRINKWRAP
Shrinkwrap.
定义: c4d_raytrace.h:29
PI2
static constexpr Float64 PI2
floating point constant: 2.0 * PI
定义: apibasemath.h:118
TexData::proj
Char proj
The texture projection: TextureProjectionTypes.
定义: c4d_shader.h:524