feature/test #9
@ -1,34 +1,64 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "xgfxlight.h"
|
||||
|
||||
#include "qcolor.h"
|
||||
#include "xgfxlightdef.h"
|
||||
|
||||
XGfxLight::XGfxLight()
|
||||
: XAsset() {
|
||||
: XAsset()
|
||||
, mType(0)
|
||||
, mCanUseShadowMap(0)
|
||||
, mUnused({0, 0})
|
||||
, mColor({0.0f, 0.0f, 0.0f})
|
||||
, mDir({0.0f, 0.0f, 0.0f})
|
||||
, mOrigin({0.0f, 0.0f, 0.0f})
|
||||
, mRadius(0.0f)
|
||||
, mCosHalfFovOuter(0.0f)
|
||||
, mCosHalfFovInner(0.0f)
|
||||
, mExponent(0)
|
||||
, mSpotShadowIndex(0)
|
||||
, mDefPtr(0)
|
||||
, mDef(new XGfxLightDef())
|
||||
{
|
||||
}
|
||||
|
||||
XGfxLight::~XGfxLight()
|
||||
{
|
||||
delete mDef;
|
||||
}
|
||||
|
||||
void XGfxLight::ParseData(QDataStream *aStream) {
|
||||
if (GetPtr() == -1) {
|
||||
aStream->read((char*)&mType, sizeof(unsigned char));
|
||||
aStream->read((char*)&mCanUseShadowMap, sizeof(unsigned char));
|
||||
aStream->ignore(sizeof(unsigned char) * 2); // Skip unused bytes
|
||||
aStream->read((char*)mColor, 3 * sizeof(float));
|
||||
aStream->read((char*)mDir, 3 * sizeof(float));
|
||||
aStream->read((char*)mOrigin, 3 * sizeof(float));
|
||||
aStream->read((char*)&mRadius, sizeof(float));
|
||||
aStream->read((char*)&mCosHalfFovOuter, sizeof(float));
|
||||
aStream->read((char*)&mCosHalfFovInner, sizeof(float));
|
||||
aStream->read((char*)&mExponent, sizeof(int));
|
||||
*aStream
|
||||
>> mType
|
||||
>> mCanUseShadowMap;
|
||||
|
||||
// Skip spotShadowIndex - we'll handle this appropriately later
|
||||
aStream->ignore(sizeof(unsigned int));
|
||||
aStream->skipRawData(2);
|
||||
|
||||
// Skip def pointer - we'll handle this appropriately later
|
||||
aStream->ignore(sizeof(int));
|
||||
float r, g, b;
|
||||
|
||||
*aStream
|
||||
>> r
|
||||
>> g
|
||||
>> b
|
||||
>> mDir[0]
|
||||
>> mDir[1]
|
||||
>> mDir[2]
|
||||
>> mOrigin[0]
|
||||
>> mOrigin[1]
|
||||
>> mOrigin[2]
|
||||
>> mRadius
|
||||
>> mCosHalfFovOuter
|
||||
>> mCosHalfFovInner
|
||||
>> mExponent
|
||||
>> mSpotShadowIndex
|
||||
>> mDefPtr;
|
||||
|
||||
mColor = QColor(r, g, b);
|
||||
|
||||
if (mDefPtr == -1)
|
||||
{
|
||||
mDef->ParseData(aStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,86 +66,80 @@ unsigned char XGfxLight::GetType() const {
|
||||
return mType;
|
||||
}
|
||||
|
||||
void XGfxLight::SetType(unsigned char type) {
|
||||
mType = type;
|
||||
void XGfxLight::SetType(unsigned char aType) {
|
||||
mType = aType;
|
||||
}
|
||||
|
||||
unsigned char XGfxLight::CanUseShadowMap() const {
|
||||
return mCanUseShadowMap;
|
||||
}
|
||||
|
||||
void XGfxLight::SetCanUseShadowMap(bool canUse) {
|
||||
mCanUseShadowMap = canUse ? 1 : 0;
|
||||
void XGfxLight::SetCanUseShadowMap(bool aCanUse) {
|
||||
mCanUseShadowMap = aCanUse ? 1 : 0;
|
||||
}
|
||||
|
||||
const float* XGfxLight::GetColor() const {
|
||||
QColor XGfxLight::GetColor() const {
|
||||
return mColor;
|
||||
}
|
||||
|
||||
void XGfxLight::SetColor(const float* color, size_t count) {
|
||||
if (count <= 3) {
|
||||
memcpy(mColor, color, count * sizeof(float));
|
||||
}
|
||||
void XGfxLight::SetColor(const QColor &aColor) {
|
||||
mColor = aColor;
|
||||
}
|
||||
|
||||
const float* XGfxLight::GetDir() const {
|
||||
QVector<float> XGfxLight::GetDir() const {
|
||||
return mDir;
|
||||
}
|
||||
|
||||
void XGfxLight::SetDir(const float* dir, size_t count) {
|
||||
if (count <= 3) {
|
||||
memcpy(mDir, dir, count * sizeof(float));
|
||||
}
|
||||
void XGfxLight::SetDir(const QVector<float> &aDir) {
|
||||
mDir = aDir;
|
||||
}
|
||||
|
||||
const float* XGfxLight::GetOrigin() const {
|
||||
QVector<float> XGfxLight::GetOrigin() const {
|
||||
return mOrigin;
|
||||
}
|
||||
|
||||
void XGfxLight::SetOrigin(const float* origin, size_t count) {
|
||||
if (count <= 3) {
|
||||
memcpy(mOrigin, origin, count * sizeof(float));
|
||||
}
|
||||
void XGfxLight::SetOrigin(const QVector<float> &aOrigin) {
|
||||
mOrigin = aOrigin;
|
||||
}
|
||||
|
||||
float XGfxLight::GetRadius() const {
|
||||
return mRadius;
|
||||
}
|
||||
|
||||
void XGfxLight::SetRadius(float radius) {
|
||||
mRadius = radius;
|
||||
void XGfxLight::SetRadius(float aRadius) {
|
||||
mRadius = aRadius;
|
||||
}
|
||||
|
||||
float XGfxLight::GetCosHalfFovOuter() const {
|
||||
return mCosHalfFovOuter;
|
||||
}
|
||||
|
||||
void XGfxLight::SetCosHalfFovOuter(float cosHalfFov) {
|
||||
mCosHalfFovOuter = cosHalfFov;
|
||||
void XGfxLight::SetCosHalfFovOuter(float aCosHalfFov) {
|
||||
mCosHalfFovOuter = aCosHalfFov;
|
||||
}
|
||||
|
||||
float XGfxLight::GetCosHalfFovInner() const {
|
||||
return mCosHalfFovInner;
|
||||
}
|
||||
|
||||
void XGfxLight::SetCosHalfFovInner(float cosHalfFov) {
|
||||
mCosHalfFovInner = cosHalfFov;
|
||||
void XGfxLight::SetCosHalfFovInner(float aCosHalfFov) {
|
||||
mCosHalfFovInner = aCosHalfFov;
|
||||
}
|
||||
|
||||
int XGfxLight::GetExponent() const {
|
||||
return mExponent;
|
||||
}
|
||||
|
||||
void XGfxLight::SetExponent(int exponent) {
|
||||
mExponent = exponent;
|
||||
void XGfxLight::SetExponent(int aExponent) {
|
||||
mExponent = aExponent;
|
||||
}
|
||||
|
||||
unsigned int XGfxLight::GetSpotShadowIndex() const {
|
||||
return mSpotShadowIndex;
|
||||
}
|
||||
|
||||
void XGfxLight::SetSpotShadowIndex(unsigned int index) {
|
||||
mSpotShadowIndex = index;
|
||||
void XGfxLight::SetSpotShadowIndex(unsigned int aIndex) {
|
||||
mSpotShadowIndex = aIndex;
|
||||
}
|
||||
|
||||
int XGfxLight::GetDefPtr() const {
|
||||
|
||||
@ -1,71 +1,66 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef XGFXLIGHT_H
|
||||
#define XGFXLIGHT_H
|
||||
|
||||
#include "qcolor.h"
|
||||
#include "xasset.h"
|
||||
|
||||
class XGfxLightDef;
|
||||
|
||||
class XGfxLight : public XAsset
|
||||
{
|
||||
public:
|
||||
explicit XGfxLight();
|
||||
~XGfxLight();
|
||||
|
||||
void ParseData(QDataStream *aStream) override;
|
||||
|
||||
unsigned char GetType() const;
|
||||
void SetType(unsigned char type);
|
||||
void SetType(unsigned char aType);
|
||||
|
||||
unsigned char CanUseShadowMap() const;
|
||||
void SetCanUseShadowMap(bool canUse);
|
||||
void SetCanUseShadowMap(bool aCanUse);
|
||||
|
||||
const float* GetColor() const;
|
||||
void SetColor(const float* color, size_t count = 3);
|
||||
QColor GetColor() const;
|
||||
void SetColor(const QColor& aColor);
|
||||
|
||||
const float* GetDir() const;
|
||||
void SetDir(const float* dir, size_t count = 3);
|
||||
QVector<float> GetDir() const;
|
||||
void SetDir(const QVector<float> &aDir);
|
||||
|
||||
const float* GetOrigin() const;
|
||||
void SetOrigin(const float* origin, size_t count = 3);
|
||||
QVector<float> GetOrigin() const;
|
||||
void SetOrigin(const QVector<float> &aOrigin);
|
||||
|
||||
float GetRadius() const;
|
||||
void SetRadius(float radius);
|
||||
void SetRadius(float aRadius);
|
||||
|
||||
float GetCosHalfFovOuter() const;
|
||||
void SetCosHalfFovOuter(float cosHalfFov);
|
||||
void SetCosHalfFovOuter(float aCosHalfFov);
|
||||
|
||||
float GetCosHalfFovInner() const;
|
||||
void SetCosHalfFovInner(float cosHalfFov);
|
||||
void SetCosHalfFovInner(float aCosHalfFov);
|
||||
|
||||
int GetExponent() const;
|
||||
void SetExponent(int exponent);
|
||||
void SetExponent(int aExponent);
|
||||
|
||||
unsigned int GetSpotShadowIndex() const;
|
||||
void SetSpotShadowIndex(unsigned int index);
|
||||
void SetSpotShadowIndex(unsigned int aIndex);
|
||||
|
||||
// Note: XGfxLightDef is a placeholder - we need to handle this appropriately
|
||||
int GetDefPtr() const;
|
||||
void SetDefPtr(int ptr);
|
||||
|
||||
private:
|
||||
unsigned char mType = 0;
|
||||
unsigned char mCanUseShadowMap = 0;
|
||||
unsigned char mUnused[2] = {0, 0};
|
||||
float mColor[3] = {0.0f, 0.0f, 0.0f};
|
||||
float mDir[3] = {0.0f, 0.0f, 0.0f};
|
||||
float mOrigin[3] = {0.0f, 0.0f, 0.0f};
|
||||
float mRadius = 0.0f;
|
||||
float mCosHalfFovOuter = 0.0f;
|
||||
float mCosHalfFovInner = 0.0f;
|
||||
int mExponent = 0;
|
||||
unsigned int mSpotShadowIndex = 0;
|
||||
int mDefPtr = 0; // Placeholder for XGfxLightDef pointer
|
||||
unsigned char mType;
|
||||
unsigned char mCanUseShadowMap;
|
||||
QVector<unsigned char> mUnused;
|
||||
QColor mColor;
|
||||
QVector<float> mDir;
|
||||
QVector<float> mOrigin;
|
||||
float mRadius;
|
||||
float mCosHalfFovOuter;
|
||||
float mCosHalfFovInner;
|
||||
qint32 mExponent;
|
||||
quint32 mSpotShadowIndex;
|
||||
qint32 mDefPtr;
|
||||
XGfxLightDef *mDef;
|
||||
};
|
||||
|
||||
#endif // XGFXLIGHT_H
|
||||
|
||||
@ -1,10 +1,3 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef XGFXSTREAMINGAABBTREE_H
|
||||
#define XGFXSTREAMINGAABBTREE_H
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user