Remove Light, Technique references

pull/1423/head
Daniel Hritzkiv 2017-08-31 18:26:50 -04:00
parent 863458cd4a
commit 7532d6aac1
No known key found for this signature in database
GPG Key ID: D1D19875679D5CBF
4 changed files with 2 additions and 124 deletions

View File

@ -129,7 +129,6 @@ namespace glTF2
struct BufferView; // here due to cross-reference
struct Texture;
struct Light;
struct Skin;
// Vec/matrix types, as raw float arrays
@ -835,7 +834,6 @@ namespace glTF2
Nullable<vec3> scale;
Ref<Camera> camera;
Ref<Light> light;
std::vector< Ref<Node> > skeletons; //!< The ID of skeleton nodes. Each of which is the root of a node hierarchy.
Ref<Skin> skin; //!< The ID of the skin referenced by this node.
@ -891,27 +889,6 @@ namespace glTF2
void Read(Value& obj, Asset& r);
};
struct Technique : public Object
{
struct Parameters
{
};
struct States
{
};
struct Functions
{
};
Technique() {}
void Read(Value& obj, Asset& r);
};
//! A texture and its sampler.
struct Texture : public Object
{

View File

@ -984,52 +984,6 @@ inline void Camera::Read(Value& obj, Asset& r)
}
}
inline void Light::Read(Value& obj, Asset& r)
{
SetDefaults();
if (Value* type = FindString(obj, "type")) {
const char* t = type->GetString();
if (strcmp(t, "ambient") == 0) this->type = Type_ambient;
else if (strcmp(t, "directional") == 0) this->type = Type_directional;
else if (strcmp(t, "point") == 0) this->type = Type_point;
else if (strcmp(t, "spot") == 0) this->type = Type_spot;
if (this->type != Type_undefined) {
if (Value* vals = FindString(obj, t)) {
ReadMember(*vals, "color", color);
ReadMember(*vals, "constantAttenuation", constantAttenuation);
ReadMember(*vals, "linearAttenuation", linearAttenuation);
ReadMember(*vals, "quadraticAttenuation", quadraticAttenuation);
ReadMember(*vals, "distance", distance);
ReadMember(*vals, "falloffAngle", falloffAngle);
ReadMember(*vals, "falloffExponent", falloffExponent);
}
}
}
}
inline void Light::SetDefaults()
{
#ifndef M_PI
const float M_PI = 3.14159265358979323846f;
#endif
type = Type_undefined;
SetVector(color, 0.f, 0.f, 0.f, 1.f);
constantAttenuation = 0.f;
linearAttenuation = 1.f;
quadraticAttenuation = 1.f;
distance = 0.f;
falloffAngle = static_cast<float>(M_PI / 2.f);
falloffExponent = 0.f;
}
inline void Node::Read(Value& obj, Asset& r)
{

View File

@ -557,11 +557,6 @@ namespace glTF2 {
}
inline void Write(Value& obj, Technique& b, AssetWriter& w)
{
}
inline void Write(Value& obj, Texture& tex, AssetWriter& w)
{
if (tex.source) {
@ -572,11 +567,6 @@ namespace glTF2 {
}
}
inline void Write(Value& obj, Light& b, AssetWriter& w)
{
}
inline AssetWriter::AssetWriter(Asset& a)
: mDoc()

View File

@ -493,46 +493,6 @@ void glTF2Importer::ImportCameras(glTF2::Asset& r)
}
}
void glTF2Importer::ImportLights(glTF2::Asset& r)
{
if (!r.lights.Size()) return;
mScene->mNumLights = r.lights.Size();
mScene->mLights = new aiLight*[r.lights.Size()];
for (size_t i = 0; i < r.lights.Size(); ++i) {
Light& l = r.lights[i];
aiLight* ail = mScene->mLights[i] = new aiLight();
switch (l.type) {
case Light::Type_directional:
ail->mType = aiLightSource_DIRECTIONAL; break;
case Light::Type_spot:
ail->mType = aiLightSource_SPOT; break;
case Light::Type_ambient:
ail->mType = aiLightSource_AMBIENT; break;
default: // Light::Type_point
ail->mType = aiLightSource_POINT; break;
}
CopyValue(l.color, ail->mColorAmbient);
CopyValue(l.color, ail->mColorDiffuse);
CopyValue(l.color, ail->mColorSpecular);
ail->mAngleOuterCone = l.falloffAngle;
ail->mAngleInnerCone = l.falloffExponent; // TODO fix this, it does not look right at all
ail->mAttenuationConstant = l.constantAttenuation;
ail->mAttenuationLinear = l.linearAttenuation;
ail->mAttenuationQuadratic = l.quadraticAttenuation;
}
}
aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>& meshOffsets, glTF2::Ref<glTF2::Node>& ptr)
{
Node& node = *ptr;
@ -602,10 +562,6 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
pScene->mCameras[node.camera.GetIndex()]->mName = ainode->mName;
}
if (node.light) {
pScene->mLights[node.light.GetIndex()]->mName = ainode->mName;
}
return ainode;
}
@ -695,13 +651,14 @@ void glTF2Importer::InternReadFile(const std::string& pFile, aiScene* pScene, IO
// Copy the data out
//
ImportEmbeddedTextures(asset);
ImportMaterials(asset);
ImportMeshes(asset);
ImportCameras(asset);
ImportLights(asset);
ImportNodes(asset);