How to make a new physical engine
All the descriptions of the class, need parentheses for
namespace Spr{; }
.(#include doesn't care)。」
The macro to register the name is necessary in the place of the declaration of
the class.
SGOBJECTDEF(PHTestEngine);
This can specify like the above. This is needed #include because this is declared by <FileIO/FIDocScene.h>.
SGOBJECTIMP(PHTestEngine, SGBehaviorEngine);
class PHTestEngineLoader:public FIObjectLoader<PHTestEngine>{ public: PHTestEngineLoader(){} virtual bool LoadData(FILoadScene* ctx, PHTestEngine* test){} }; class PHTestEngineSaver:public FIObjectSaver<PHTestEngine>{ virtual UTString GetType() const{ return "PHTestEngine"; } virtual void SaveData(FISaveScene* ctx, FIDocNodeBase* doc, PHTestEngine* test){} };
DEF_REGISTER_BOTH(PHTestEngine);In order to using the argument here, the name must adjust to declaration.
The definition is different the method in the next two cases.
DEF_RECORD(XTestEngine,{ //In the code area; specify codes generated by ~\Microsoft Visual Studio\Common\Tools\GUIDGEN.EXE GUID Guid(){ return WBGuid("CODE"); } Data declaration; });Because data declaration should be a data type matched to X file,
typedef Vec3f Vector;
it is necessary to match the type like that.
UTRef<FITypeDescDb> db = new FITypeDescDb; db->SetPrefix("X"); db->REG_FIELD(Vector); //Matched Declare type db->REG_RECORD_PROTO(XTestEngine); //adjust it to the first argument of DEF_RECORD
XTestEngine tes;the member variable is described like above.
virtual bool LoadData(FILoadScene* ctx, PHMTestEngine* test){ ctx->docs.Top()->GetWholeData(test->tes); return true; }When you substitute it for data inversely,
virtual void SaveData(FISaveScene* ctx, FIDocNodeBase* doc, PHTestEngine* test){ doc->SetWholeData(test->tes); }In the case ュ「,
virtual bool LoadData(FILoadScene* ctx, PHMTestEngine* test){ XTestEngine tes; ctx->docs.Top()->GetWholeData(test->tes); substitute it for the member variable in your original type return true; }When you substitute it for data inversely,
virtual void SaveData(FISaveScene* ctx, FIDocNodeBase* doc, PHTestEngine* test){ XTestEngine tes; substitute it for the above structure in your original type doc->SetWholeData(test->tes); }
if (DCAST([Class name of data], o)){ [Member Var. of this Class].push_back((PHSolid*)o); return true; } return false;