Jad - 2007-04-27

I've FxGen working now with Jad. I've added a new .cpp for it into the library, that let the .Net talk with fxGen. It's very very simple, so i give you the code if you want to include a new project for .Net users. You have to change the CodeGeneration ( at Properties/General) to Compatible con Common Language Runtime (/clr), and the magic is done.

Now i have some doubts:
1. How to free the resources generated by the engine?
2. Is there a text file format available instead of the binary one?
3. How could i Load a project and change the final Width and Height?

Many thanks for your work!!!

#include "pch.h"
#include "EngineOp.h"

#using <mscorlib.dll>
#using <System.dll>
using namespace System;
using namespace System::Runtime::InteropServices;

namespace FxGen
{
    public ref struct FxGenResult
    {
        int width,height;
    };

    public ref class FxGen
    {
    private:
        NEngineOp* pgen;
        NBitmap* pbmp;
    public:
        FxGen()
        {
            //Create engine instance
            pgen = gNFxGen_GetEngine();
        }

        ~FxGen()
        {
        }

        void Load(String ^ fullpath)
        {
            char* str2 = (char*)(void*)Marshal::StringToHGlobalAnsi(fullpath);
            pgen->LoadProject(str2);
            //Marshal::FreeHGlobal(str2);
        }

        void Process(FxGenResult ^r)
        {
            //Get finals operators from root tree node
            NObjectArray finalsOp;
            finalsOp.SetManageDelete(false);
            pgen->GetFinalOps(pgen->GetRootGroup(), finalsOp, true);

            //Execute first processing
            for (int i=0; i<finalsOp.Count(); i++)
            {
                pgen->Execute(0.0f, (NOperator*)finalsOp[i]);
            }

            //Get First Result
            NOperator* pop = (NOperator*)finalsOp[0];
            pbmp = (NBitmap*)pop->m_pObj;

            r->width=pbmp->GetWidth();
            r->height=pbmp->GetHeight();
        }

        void GetData(array<UInt32> ^data)
        {
            unsigned int *src=(unsigned int *)pbmp->GetPixels();
            int t=pbmp->GetWidth()*pbmp->GetHeight();

            for(int i=0;i<t;i++) data[i]=*src++;

        }
    };

}