osg.Vec4b
class Vec4b
osg.Vec4b是OpenSceneGraph库中用于表示4维字节向量的类。Vec4b代表了一个由4个带符号字节组成的向量。
构造函数
Vec4b();
Vec4b(signed char _v);
Vec4b(signed char _x, signed char _y, signed char _z, signed char _w);
Vec4b(const signed char *_v);
Vec4b(const Vec4b ©, const CopyOp ©op = CopyOp::SHALLOW_COPY);
- Vec4b():构造一个初始值为[0, 0, 0, 0]的Vec4b。
- Vec4b(signed char _v):构造一个初始值为[_v, _v, _v, _v]的Vec4b。
- Vec4b(signed char _x, signed char _y, signed char _z, signed char _w):构造一个初始值为[_x, _y, _z, _w]的Vec4b。
- Vec4b(const signed char *_v):构造一个初始值为传入数组的Vec4b。输入数组需要至少包含4个带符号字节。
- Vec4b(const Vec4b ©, const CopyOp ©op = CopyOp::SHALLOW_COPY):构造一个与给定Vec4b相同的Vec4b。
成员函数
void set(signed char _x, signed char _y, signed char _z, signed char _w);
signed char& operator[](const int i);
const signed char operator[](const int i) const;
signed char* ptr();
const signed char* ptr() const;
void zero();
bool isNaN() const;
- set(signed char _x, signed char _y, signed char _z, signed char _w):设置Vec4b的值为[_x, _y, _z, _w]。
- signed char& operator[](const int i):重载[]运算符,返回Vec4b的第i个元素(0<= i <= 3)。可以通过该函数直接修改Vec4b的元素。
- const signed char operator[](const int i) const:重载[]运算符,返回Vec4b的第i个元素(0 <= i <= 3),并且不可以通过该函数修改Vec4b的元素。
- signed char* ptr():返回Vec4b的指针。
- const signed char* ptr() const:返回Vec4b的指针,不可修改。
- zero():将Vec4b的所有元素置为0。
- bool isNaN() const:判断Vec4b是否包含NaN值(Not-A-Number)。
友元函数
Vec4b operator+(const Vec4b& lhs, const Vec4b& rhs);
Vec4b operator-(const Vec4b& lhs, const Vec4b& rhs);
Vec4b operator*(const Vec4b& lhs, const signed char& rhs);
Vec4b operator*(const signed char& lhs, const Vec4b& rhs);
Vec4b operator*(const Vec4b& lhs, const Vec4b& rhs);
Vec4b operator/(const Vec4b& lhs, const signed char& rhs);
Vec4b operator/(const Vec4b& lhs, const Vec4b& rhs);
bool operator==(const Vec4b& lhs, const Vec4b& rhs);
bool operator!=(const Vec4b& lhs, const Vec4b& rhs);
- operator+:重载+运算符,返回两个Vec4b元素对应位置的和。
- operator-:重载-运算符,返回两个Vec4b元素对应位置的差。
- operator*:重载*运算符,返回对应元素的乘积。当一个Vec4b和一个带符号字节相乘时,返回一个新的Vec4b,元素值为原Vec4b的元素值乘以该带符号字节;当两个Vec4b相乘时,返回一个新的Vec4b,元素值为原Vec4b的元素值逐个相乘。
- operator/:重载/运算符,返回两个Vec4b元素对应位置上的商,或者返回Vec4b与带符号字节相除的结果。
- operator==:重载==运算符,判断两个Vec4b是否相等。
- operator!=:重载!=运算符,判断两个Vec4b是否不相等。