struct BufferView; // here due to cross-reference
struct Texture;
- struct Light;
struct Skin;
// Vec/matrix types, as raw float arrays
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.
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
{
}
}
-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)
{
}
- inline void Write(Value& obj, Technique& b, AssetWriter& w)
- {
-
- }
-
inline void Write(Value& obj, Texture& tex, AssetWriter& w)
{
if (tex.source) {
}
}
- inline void Write(Value& obj, Light& b, AssetWriter& w)
- {
-
- }
-
inline AssetWriter::AssetWriter(Asset& a)
: mDoc()
}
}
-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;
pScene->mCameras[node.camera.GetIndex()]->mName = ainode->mName;
}
- if (node.light) {
- pScene->mLights[node.light.GetIndex()]->mName = ainode->mName;
- }
-
return ainode;
}
// Copy the data out
//
+
+
ImportEmbeddedTextures(asset);
ImportMaterials(asset);
ImportMeshes(asset);
ImportCameras(asset);
- ImportLights(asset);
ImportNodes(asset);