What if... Pt3

Published March 09, 2005
Advertisement
struct sVertex{    float x, y, z;};class Vertex : public ClassDefinition{public:    Vertex() : ClassDefinition( "Vertex" )    {               DeclareMethod( "ToString", new ClassMethodFunctor(this, &Vertex::ToString ) );    }            int Constructor( MethodCallInfo *p_info )    {        ClassInstance *inst = p_info->ClassInst();        assert( inst != 0 );                sVertex *p = new sVertex;        inst->SetUser( p );        return 0;    }        int ToString( MethodCallInfo *p_info )    {        ClassInstance *inst = p_info->ClassInst();        assert( inst != 0 );        sVertex *v = (sVertex*)inst->GetUser();        std::cout << "Vertex{" << v->x << ", " << v->y << ", " << v->z << "}" << std::endl;        return 0;    }};int main(){    Environment env;    env.RegisterClass( &v );           Vertex defVertex;    env.RegisterClass( &defVertex );        ClassInstance *i = env.CreateInstance( "Vertex" );        sVertex *p = (sVertex *)i->GetUser();    p->x = 150.0f; p->y = 250.0f; p->z = 350.0f;        MethodCallInfo *call = env.BeginMethodCall( i, "ToString" );    // Add params if needed    call->Execute();	    return 0;}
Previous Entry What if... Pt 2
Next Entry What if... Pt4
0 likes 3 comments

Comments

superpig
Yes, but is it art?
March 09, 2005 12:41 PM
JTippetts
Of course it's art, don't be silly Superpig. [grin]
March 09, 2005 01:49 PM
evolutional
It's as much art as a cow cut in half swimming in formaldahyde :P

Moo
March 09, 2005 02:08 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement