mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementações em default Writers
This commit is contained in:
parent
4730c6fcb2
commit
c36352ce3b
@ -1,6 +1,7 @@
|
|||||||
#include "xna/pipeline/writer.hpp"
|
#include "xna/pipeline/writer.hpp"
|
||||||
#include "xna/pipeline/compiler.hpp"
|
#include "xna/pipeline/compiler.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -18,6 +18,8 @@ namespace xna {
|
|||||||
virtual Int TypeVersion() const { return 0; }
|
virtual Int TypeVersion() const { return 0; }
|
||||||
//Compiles an object into binary format.
|
//Compiles an object into binary format.
|
||||||
virtual void Write(ContentWriter& output, Object& value){}
|
virtual void Write(ContentWriter& output, Object& value){}
|
||||||
|
//Determines if deserialization into an existing object is possible.
|
||||||
|
virtual bool CanDeserializeIntoExistingObject() const { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ContentTypeWriter(P_Type const& targetType) : targetType(targetType) {}
|
ContentTypeWriter(P_Type const& targetType) : targetType(targetType) {}
|
||||||
|
85
inc/xna/pipeline/writers/default.hpp
Normal file
85
inc/xna/pipeline/writers/default.hpp
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#ifndef XNA_PIPELINE_WRITERS_DEFAULT_HPP
|
||||||
|
#define XNA_PIPELINE_WRITERS_DEFAULT_HPP
|
||||||
|
|
||||||
|
#include "../writer.hpp"
|
||||||
|
#include "../../common/collision.hpp"
|
||||||
|
#include "../../common/curve.hpp"
|
||||||
|
|
||||||
|
namespace xna {
|
||||||
|
class BooleanWriter : public BuiltinTypeWriter<bool> {
|
||||||
|
public:
|
||||||
|
void Write(ContentWriter& output, bool& value) override {
|
||||||
|
output.Write(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class BoundingBoxWriter : public BuiltinTypeWriter<BoundingBox> {
|
||||||
|
public:
|
||||||
|
void Write(ContentWriter& output, BoundingBox& value) override {
|
||||||
|
output.Write(value.Min);
|
||||||
|
output.Write(value.Max);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class BoundingFrustumWriter : public BuiltinTypeWriter<BoundingFrustum> {
|
||||||
|
public:
|
||||||
|
void Write(ContentWriter& output, BoundingFrustum& value) override {
|
||||||
|
output.Write(value.GetMatrix());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class BoundingSphereWriter : public BuiltinTypeWriter<BoundingSphere> {
|
||||||
|
public:
|
||||||
|
void Write(ContentWriter& output, BoundingSphere& value) override {
|
||||||
|
output.Write(value.Center);
|
||||||
|
output.Write(value.Radius);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ByteWriter : public BuiltinTypeWriter<Byte> {
|
||||||
|
public:
|
||||||
|
void Write(ContentWriter& output, Byte& value) override {
|
||||||
|
output.Write(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class CharWriter : public BuiltinTypeWriter<Char> {
|
||||||
|
public:
|
||||||
|
void Write(ContentWriter& output, Char& value) override {
|
||||||
|
output.Write(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ColorWriter : public BuiltinTypeWriter<Color> {
|
||||||
|
public:
|
||||||
|
void Write(ContentWriter& output, Color& value) override {
|
||||||
|
output.Write(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class CurveWriter : public BuiltinTypeWriter<Curve> {
|
||||||
|
public:
|
||||||
|
void Write(ContentWriter& output, Curve& value) override {
|
||||||
|
output.Write(static_cast<Int>(value.PreLoop));
|
||||||
|
output.Write(static_cast<Int>(value.PostLoop));
|
||||||
|
output.Write(static_cast<Int>(value.Keys.Count()));
|
||||||
|
|
||||||
|
for (size_t i = 0; i < value.Keys.Count(); ++i) {
|
||||||
|
const auto& key = value.Keys[i];
|
||||||
|
|
||||||
|
output.Write(key.Position);
|
||||||
|
output.Write(key.Value);
|
||||||
|
output.Write(key.TangentIn);
|
||||||
|
output.Write(key.TangentOut);
|
||||||
|
output.Write(static_cast<Int>(key.Continuity));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CanDeserializeIntoExistingObject() const override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -55,6 +55,7 @@
|
|||||||
#include "input/mouse.hpp"
|
#include "input/mouse.hpp"
|
||||||
#include "pipeline/writer.hpp"
|
#include "pipeline/writer.hpp"
|
||||||
#include "pipeline/compiler.hpp"
|
#include "pipeline/compiler.hpp"
|
||||||
|
#include "pipeline/writers/default.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
//Exposes functions that must be implemented by the platform
|
//Exposes functions that must be implemented by the platform
|
||||||
|
Loading…
x
Reference in New Issue
Block a user