As most of you know this has been done for the C# version. Not sure if any one has attempted this on the c++ version or not, but my team has...
GDK has a great syntax but its lacking the class like feel. example..
void dbLoadMesh ( char* szFilename, int iMesh )
or
dbLoadMesh (( "media\\Warehouse\\basic_room.X");
could also be done like.
Object ship;
ship.load( "media\\Warehouse\\basic_room.X");
if the object was a class including the dbLoadMesh
Well we have created the H file and the CPP file.. to do just that.
H file.
#ifndef _OBJECT_H_
#define _OBJECT_H_
class Object {
public:
Object( void );
virtual ~Object( void );
void load( const char *szPath );
// Colors an object using the specified color
void color( int iRGB );
void enableGhosting( void );
void disableGhosting( void );
void show( void );
void hide( void );
void position( float , float , float );
void rotateX( float fDegrees );
void rotateY( float fDegrees );
void rotateZ( float fDegrees );
void rotate( float fX, float fY, float fZ );
void turnLeft( float fAmount );
void turnRight( float fAmount );
void loopAnimation( void );
void playAnimation( int iStartFrame = 0, int iEndFrame = 0 );
void stopAnimation( void );
// Scales the object using percentage values from 0 - 100
void scale( float fXScale, float fYScale, float fZScale );
void showBounds( bool bBoxOnly = false );
void hideBounds( void );
void moveUp( float fSpeed );
void moveDown( float fSpeed );
void moveLeft( float fSpeed );
void moveRight( float fSpeed );
void move( float fSpeed );
float getCurrentFrame( void );
bool inScreen( void );
bool isLoopingAnimation( void );
bool isPlayingAnimation( void );
float getRadius( void );
bool isVisible( void );
float getX( void );
float getY( void );
float getZ( void );
float getSizeX( bool bActualSize = false );
float getSizeY( bool bActualSize = false );
float getSizeZ( bool bActualSize = false );
bool collidesWith( Object &collider );
float getAngleX( void );
float getAngleY( void );
float getAngleZ( void );
void setPosition( float fX, float fY, float fZ );
void setFrame( float fFrame, bool bRecalculateBounds );
void setSpeed( int iSpeed );
void fixPivot( void );
void setLightMappingOn( int );
void setLight( bool );
void setSpecular( int );
void setTexture( int , int );
int getID( void );
private:
int m_iID;
};
#endif
CPP file.
#include "Object.h"
#include "ObjectFactory.h"
#include "DarkGDK.h"
Object::Object( void ) {
m_iID = ObjectFactory::getInstance( )->getNextID( );
}
Object::~Object( void ) {
dbDeleteObject( m_iID );
}
void Object::load( const char *szPath ) {
dbLoadObject( (char *)szPath, m_iID);
}
int Object::getID( void ) {
return m_iID;
}
void Object::color( int iRGB ) {
dbColorObject( m_iID, iRGB );
}
void Object::enableGhosting( void ) {
dbGhostObjectOn( m_iID );
}
void Object::disableGhosting( void ) {
dbGhostObjectOff( m_iID );
}
void Object::show( void ) {
}
void Object::hide( void ) {
dbHideObject( m_iID );
}
void Object::position( float fX, float fY, float fZ) {
dbPositionObject( m_iID , fX , fY , fZ);
}
void Object::rotateX( float fDegrees ) {
dbXRotateObject( m_iID, fDegrees );
}
void Object::rotateY( float fDegrees ) {
dbYRotateObject( m_iID, fDegrees );
}
void Object::rotateZ( float fDegrees ) {
dbZRotateObject( m_iID, fDegrees );
}
void Object::rotate( float fX, float fY, float fZ ) {
dbRotateObject( m_iID, fX, fY, fZ );
}
void Object::turnLeft( float fAmount ) {
dbTurnObjectLeft( m_iID, fAmount );
}
void Object::turnRight( float fAmount ) {
dbTurnObjectRight( m_iID, fAmount );
}
void Object::loopAnimation( void ) {
dbLoopObject( m_iID );
}
void Object::playAnimation( int iStartFrame, int iEndFrame ) {
dbPlayObject( m_iID, iStartFrame, iEndFrame );
}
void Object::stopAnimation( void ) {
dbStopObject( m_iID );
}
void Object::scale( float fXScale, float fYScale, float fZScale ) {
dbScaleObject( m_iID, fXScale, fYScale, fZScale );
}
void Object::showBounds( bool bBoxOnly ) {
dbShowObjectBounds( m_iID, ( bBoxOnly ) ? 1 : 0 );
}
void Object::hideBounds( void ) {
dbHideObjectBounds( m_iID );
}
void Object::moveUp( float fSpeed ) {
dbMoveObjectUp( m_iID, fSpeed );
}
void Object::moveDown( float fSpeed ) {
dbMoveObjectDown( m_iID, fSpeed );
}
void Object::moveLeft( float fSpeed ) {
dbMoveObjectLeft( m_iID, fSpeed );
}
void Object::moveRight( float fSpeed ) {
dbMoveObjectRight( m_iID, fSpeed );
}
void Object::move( float fSpeed ) {
dbMoveObject( m_iID, fSpeed );
}
bool Object::collidesWith( Object &collider ) {
if( dbObjectCollision( m_iID, collider.getID( ) ) > 0 )
return true;
return false;
}
float Object::getCurrentFrame( void ) {
return dbObjectFrame( m_iID );
}
bool Object::inScreen( void ) {
if( dbObjectInScreen( m_iID ) > 0 )
return true;
return false;
}
bool Object::isLoopingAnimation( void ) {
if( dbObjectLooping( m_iID ) )
return true;
return false;
}
bool Object::isPlayingAnimation( void ) {
if( dbObjectPlaying( m_iID ) )
return true;
return false;
}
float Object::getRadius( void ) {
return dbObjectSize( m_iID );
}
bool Object::isVisible( void ) {
if( dbObjectVisible( m_iID ) )
return true;
return false;
}
float Object::getX( void ) {
return dbObjectPositionX( m_iID );
}
float Object::getY( void ) {
return dbObjectPositionY( m_iID );
}
float Object::getZ( void ) {
return dbObjectPositionZ( m_iID );
}
float Object::getSizeX( bool bActualSize ) {
return dbObjectSizeX( m_iID, ( bActualSize ) ? 1 : 0 );
}
float Object::getSizeY( bool bActualSize ) {
return dbObjectSizeY( m_iID, ( bActualSize ) ? 1 : 0 );
}
float Object::getSizeZ( bool bActualSize ) {
return dbObjectSizeZ( m_iID, ( bActualSize ) ? 1 : 0 );
}
float Object::getAngleX( void ) {
return dbObjectAngleX( m_iID );
}
float Object::getAngleY( void ) {
return dbObjectAngleY( m_iID );
}
float Object::getAngleZ( void ) {
return dbObjectAngleZ( m_iID );
}
void Object::setPosition( float fX, float fY, float fZ ) {
dbPositionObject( m_iID, fX, fY, fZ );
}
void Object::setFrame( float fFrame, bool bRecalculateBounds ) {
dbSetObjectFrame( m_iID, fFrame, ( bRecalculateBounds ) ? 1 : 0 );
}
void Object::setSpeed( int iSpeed ) {
dbSetObjectSpeed( m_iID, iSpeed );
}
void Object::fixPivot( void ) {
dbFixObjectPivot( m_iID);
}
void Object::setLight( bool bLight) {
dbSetObjectLight( m_iID, bLight );
}
void Object::setTexture( int iMode , int iMipMaps) {
dbSetObjectTexture ( m_iID, iMode , iMipMaps );
}
void Object::setLightMappingOn( int iImage ) {
dbSetLightMappingOn( m_iID, iImage );
}
void Object::setSpecular( int iColor ) {
dbSetObjectSpecular ( m_iID, iColor );
}
This is not complete but very usable. To work with the old style there is a getID function.
We have also made a camera object.. IF there is enough interest here Ill continue to post updates. If there is a enough interest we can create a SVN and make it a group project.
ENJOY!