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