Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

lapougnou

What do you think of my future ninja lib?

This topic is 5734 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m beginning to write a little scenegraph library. I just write the header and I decided to give it an OpenGL-like interface.
  
typedef char NINJAbyte;
typedef short NINJAshort;
typedef int NINJAint;
typedef unsigned char NINJAubyte;
typedef unsigned short NINJAushort;
typedef unsigned int NINJAuint;

typedef float NINJAfloat;
typedef double NINJAdouble;

typedef NINJAint NINJAscene;
#define NINJA_SCENE_BADHANDLE (-1)

typedef NINJAint NINJAentity;
#define NINJA_ENTITY_BADHANDLE (-1)

typedef enum
	{
	NINJA_TRUE=1,
		NINJA_FALSE=0

	}NINJAbool;

///Create a Ninja3D scene

/**
\return scene handle
**/
extern NINJAscene ninjaCreateScene();

///Load a Ninja3D scene
/**
\param filename file from which the scene must be loaded
\return scene handle
**/
extern NINJAscene ninjaLoadScene(char *filename);

///Free the memory used by a scene and all of his entities
/**
\param scene scene handle
**/
extern void ninjaFreeScene(NINJAscene scene);

///Set the current scene
/**
The last created scene is automatically binded.
\param scene scene handle
**/
extern void ninjaBindScene(NINJAscene scene);

///return the number of entities in a scene
/**
\return number of entities in a scene
**/
extern NINJAint ninjaGetNumEntity();

///retrieve an entity
/**
\param num identity the entity (from 0 to ninjaGetNumEntity-1)
\return entity handle
**/
extern NINJAentity ninjaGetEntity(NINJAint num);

///update scene animations and states
/**
\param scene scene handle
**/
extern void ninjaUpdateScene();

///draw scene on screen
extern void ninjaDrawScene();

///Create an entity
/**
The entity is added to the current scene.
\return entity handle
**/
extern NINJAentity ninjaCreateEntity();

///call freeing callback and destroy the entity
/**
\param entity entity handle
**/
extern void ninjaFreeEntity(NINJAentity entity);

///Select the current entity
/**
The last created entity is automatically binded.
\param entity entity handle
**/
extern void ninjaBindEntity(NINJAentity entity);

///Create a copy of an entity
/**
\param entity entity handle to be cloned
\return the clone of the entity
**/
extern NINJAentity ninjaCloneEntity(NINJAentity entity);

///Set a clonable value for an entity
/**
A clonable value is copied when ninjaCloneEntity is called.
\param key a key to identity the value, negative key are reserved by ninja3D
\param value pointer to the value associated to key
**/
extern void ninjaEntitySetClonableValue(NINJAint key, void *value);

///Return a clonable value for an entity
/**
A clonable value is copied when ninjaCloneEntity is called.
\param key a key to identity the value, negative key are reserved by ninja3D
\return the value associated to key
**/
extern void *ninjaEntityGetClonableValue(NINJAint key);

///Set a non clonable value for an entity
/**
This values are not copied when ninjaCloneEntity is called.
\param key a key to identity the value, negative key are reserved by ninja3D
\param value the value associated to key
**/
extern void ninjaEntitySetValue(NINJAint key, void *value);

///Return a non clonable value for an entity
/**
A non clonable value is not copied when ninjaCloneEntity is called.
\param key a key to identity the value, negative key are reserved by ninja3D
\return the value associated to key
**/
extern void *ninjaEntityGetValue(NINJAint key);

typedef enum
	{
	NINJA_ENTITY_TRANSPARENT=0,
		NINJA_ENTITY_STATIC
	} NINJAentityenum;

///enable an entity feature
/**
\param param feature
**/
extern void ninjaEntityEnable(NINJAentityenum param);

///disable an entity feature
/**
\param param feature
**/
extern void ninjaEntityDisable(NINJAentityenum param);

///retrieve the state of an entity feature
/**
\param param feature
\return state of the feature
**/
extern NINJAbool ninjaEntityGet(NINJAentityenum param);
  
For the communication between ninja lib and entity code, I hesitate between
  
typedef enum
	{
	NINJA_ENTITY_EVENT_DRAW=0,
		NINJA_ENTITY_EVENT_UPDATE,
		NINJA_ENTITY_EVENT_GET_POS,
		NINJA_ENTITY_EVENT_GET_UP,
		NINJA_ENTITY_EVENT_GET_SIDE,
		NINJA_ENTITY_EVENT_GET_LOOK
	}NINJAentityEvent;

typedef void (* NINJAentityEventFunc)(NINJAentityEvent event, ...);

extern void ninjaSetEntityEventFunc(NINJAentityEventFunc func);

  
and
  
///retrieve an orientation vector of an entity

/**
\param v vector selector
\param pos must be an array of 3 NINJAfloat, the function write the vector in it
**/
extern void ninjaEntityGetVector(NINJAentityvector v, NINJAfloat *pos);

///set an orientation vector of an entity
/**
\param v vector selector
\param pos must be an array of 3 NINJAfloat
**/
extern void ninjaEntitySetVector(NINJAentityvector v, NINJAfloat *pos);

///Result of collision detection functions
typedef enum
	{
	NINJA_COLLISION_OUTSIDE=0,//<the object is entiterely outside the bounding volume
		NINJA_COLLISION_INSIDE,//<the object is entiterely inside the bounding volume
		NINJA_COLLISION_INTERSECT//<the object is a bit inside and a bit outside the bounding volume
	}NINJAcollision;

///function prototype for drawing an entity
/**
\param scene scene handle
\param entity entity handle
**/
typedef void (*NINJAentityDrawFunc)();

///callback called before NINJAentityDrawFunc
/**
\param scene scene handle
\param entity entity handle
**/
typedef void (*NINJAentityPreDrawFunc)();

///callback called after NINJAentityDrawFunc
/**
\param scene scene handle
\param entity entity handle
**/
typedef void (*NINJAentityPostDrawFunc)();

///callback called to update states of an entity
/**
\param scene scene handle
\param entity entity handle
**/
typedef void (*NINJAentityUpdateFunc)();

///callback called to update animations of an entity
typedef void (*NINJAentityAnimateFunc)();

///function prototype for collision detection between a sphere and an entity
/**
\param sphere the 3 first NINJAfloat are the center of the sphere and the last one is his radius
\return result of the collision detection
**/
typedef NINJAcollision (*NINJAentityCollisionWithSphereFunc)(NINJAfloat (*sphere)[4]);

///function prototype for collision detection between an axis aligned bounding box (aabb) and an entity
/**
\param aabb 8 points defining the aabb
\return result of the collision detection
**/
typedef NINJAcollision (*NINJAentityCollisionWithAABBFunc)(NINJAfloat (*aabb)[8][3]);

///callback to free the non clonable memory of an entity
/**
\param entity entity handle
**/
typedef void (*NINJAentityFreeNonClonableFunc)();

///callback to free the clonable memory of an entity
/**
This function is called when all the entity clones are destroyed
\param entity entity handle
**/
typedef void (*NINJAentityFreeClonableFunc)();

extern void ninjaEntitySetPreDrawFunc(NINJAentityPreDrawFunc func);
extern void ninjaEntitySetDrawFunc(NINJAentityDrawFunc func);
extern void ninjaEntitySetPostDrawFunc(NINJAentityPostDrawFunc func);

extern void ninjaEntitySetUpdateFunc(NINJAentityUpdateFunc func);
extern void ninjaEntitySetAnimateFunc(NINJAentityAnimateFunc func);

extern void ninjaEntitySetCollisionWithSphereFunc(NINJAentityCollisionWithSphereFunc func);
extern void ninjaEntitySetCollisionAABBFunc(NINJAentityCollisionWithAABBFunc func);
extern void ninjaEntitySetFreeNonClonableFunc(NINJAentityFreeNonClonableFunc func);
extern void ninjaEntitySetFreeClonableFunc(NINJAentityFreeClonableFunc func);

  

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!