CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2009
    Posts
    7

    Making a DLL, How??

    I have made this class

    Code:
    // --- CG_DoorHandling.h --------------------------
    
    #ifndef CG_DOORHANDLING_H
    #define CG_DOORHANDLING_H
    
    // Includes
    #include "CG_GameObject.h"
    #include "CG_ParticleManager.h"
    
    enum eDoorState {
    	DS_CLOSED,
    	DS_OPENED,
    	DS_OPENING,		
    	DS_CLOSING
    };
    
    enum eDoorType {
    	DT_PIVOT,
    	DT_SLIDING
    };
    
    
    // CG name space & "CG" stands for "Computer Games" ;-)
    namespace CG {
    
    
    
    	/**
    	*
    	*/
    	class Door: public CG::GameObject {
    
    	public:
    
    		Door();
    
    		void alignAll();
    
    		//
    		void update();
    
    		void update(eDoorState doorState, Ogre::Vector3 CharacterPosition);
    
    		void onImpact(eObjectType Object1, eObjectType Object2, NxActor* Actor1, NxActor* Actor2, NxVec3 ImpactPoint);	
    
    		void onBulletHit(NxActor *ActorHit, NxReal Distance, NxVec3 ImpactPoint, NxVec3 FaceNormal, eBulletType BulletType);
    
    		inline void setDoorClosingTime(Ogre::Real Seconds) { mDoorClosingTime = 1000 * Seconds; }
    
    		inline void setDoorNode(Ogre::SceneNode *DoorNode) { mDoorNode = DoorNode; }
    
    		inline void setDoorActor(NxActor *DoorActor) { mDoorActor = DoorActor; mDoorActor->raiseBodyFlag( NX_BF_KINEMATIC ); }
    
    		inline void setDoorTriger(NxActor *DoorTriger) { mDoorTriger = DoorTriger; }
    
    		inline void setDoorType(eDoorType DoorType) { mDoorType = DoorType; }
    
    		inline void setDoorOpeningSound(FMOD::Sound *OpeningSound) { mDoorOpeningSound = OpeningSound; }
    
    		inline void setDoorClosingSound(FMOD::Sound *ClosingSound) { mDoorClosingSound = ClosingSound; }
    
    		inline void setDoorBulletSound(FMOD::Sound *BulletSound) { mDoorBulletHitSound = BulletSound; }
    
    		ParticleManager *mDoorParticle;
    
    
    	private:
    
    
    		/**
    		*
    		*/
    		bool closeDoor();
    
    		/**
    		*
    		*/
    		bool openDoor();
    
    		//
    		Ogre::SceneNode *mDoorNode;
    
    		//
    		Ogre::Vector3 mDoorClosePosition;
    
    		//
    		NxActor *mDoorActor;
    		
    		//
    		NxActor *mDoorTriger;
    
    		//
    		eDoorState mCurrentDoorState;
    
    		//
    		eDoorType mDoorType;
    
    		//
    		FMOD::Sound *mDoorOpeningSound;
    
    		//
    		FMOD::Sound *mDoorClosingSound;
    
    		//
    		FMOD::Sound *mDoorBulletHitSound;
    
    		//
    		FMOD::Channel *mSoundChannel;
    
    		//
    		Ogre::Timer *mDoorTimer;		
    
    		//
    		Ogre::Real mDoorClosingTime;
    	};
    	
    }
    
    
    
    #endif
    
    
    
    // --- CG_DoorHandling.h --------------------------

    and implementation in cpp

    Code:
    // --- CG_DoorHandling.cpp --------------------------
    // Include header definition
    #include "CG_DoorHandling.h"
    namespace CG {
    
    // =====================================================================
    
    	Door::Door() {
    
    		mObjectType = OT_DOOR;
    
    		mCurrentDoorState = DS_CLOSED;
    
    		mDoorClosingTime = 1000 * 3.0;
    
    		mDoorTimer = new Ogre::Timer();
    
    		mDoorParticle = new ParticleManager();
    	}
    
    // =====================================================================
    
    	void Door::onImpact(eObjectType Object1, eObjectType Object2, NxActor *Actor1, NxActor *Actor2, NxVec3 ImpactPoint) {
    	}
    
    
    // =====================================================================
    
    	void Door::onBulletHit(NxActor *ActorHit, NxReal Distance, NxVec3 ImpactPoint, NxVec3 FaceNormal, eBulletType BulletType) {
    
    		FMOD::System *mSoundSys;
    		FMOD::Channel *mChannel;
    		mDoorBulletHitSound->getSystemObject(&mSoundSys);
    		mSoundSys->playSound(FMOD_CHANNEL_FREE, mDoorBulletHitSound, true, &mChannel);
    		mChannel->set3DAttributes(Conversion::Vec3NxToFMOD(ImpactPoint), 0);
    		mChannel->setPaused(false);
    
    		// emit particle
    		mDoorParticle->emitParticles(Conversion::Vec3NxToOgre(ImpactPoint), Conversion::Vec3NxToOgre(FaceNormal));
    	}
    
    // =====================================================================
    
    	void Door::update(eDoorState doorState, Ogre::Vector3 CharacterPosition) {
    		
    		mCurrentDoorState = doorState;
    
    		FMOD::System *mSoundSys;
    		mDoorOpeningSound->getSystemObject(&mSoundSys);
    
    		mSoundChannel->stop();		// stop the sound if playing
    
    		if(mCurrentDoorState == DS_OPENING) {
    
    			mDoorActor->clearBodyFlag( NX_BF_KINEMATIC );
    
    			// play door opening sound
    			mSoundSys->playSound(FMOD_CHANNEL_FREE, mDoorOpeningSound, false, &mSoundChannel);
    
    			// add force to door for opening it
    			Ogre::Vector3 Direction = mDoorNode->getPosition() - CharacterPosition;
    			Direction.normalise();
    			NxVec3 Dir = Conversion::Vec3OgreToNx(Direction);
    			Dir *= 313;
    			mDoorActor->addForce(Dir);
    
    			mDoorTimer->reset();
    		}
    
    		else if(mCurrentDoorState == DS_CLOSING) {
    			mSoundSys->playSound(FMOD_CHANNEL_FREE, mDoorClosingSound, false, &mSoundChannel);
    		}
    
    		mSoundChannel->set3DAttributes(Conversion::Vec3NxToFMOD(mDoorActor->getGlobalPosition()), 0);
    		mSoundChannel->setPaused(false);
    	}
    // =====================================================================
    
    // =====================================================================
    
    // =====================================================================
    
    	bool Door::closeDoor() {
    
    		if(mDoorClosePosition.positionEquals(mDoorNode->getPosition(), 0.7)) {
    			return (true);
    		}
    		else
    		{
    			Ogre::Vector3 Direction =  mDoorClosePosition - mDoorNode->getPosition();
    			Direction.normalise();
    			NxVec3 Dir = Conversion::Vec3OgreToNx(Direction);
    			Dir *= 10;
    			mDoorActor->addForce(Dir);//, NX_IMPULSE);
    			return (false);
    		}
    	
    	}
    
    // =====================================================================
    
    	bool Door::openDoor() {		
    
    		Ogre::Vector3 Direction = mDoorNode->getPosition() - mDoorClosePosition;
    		Direction.normalise();
    		NxVec3 Dir = Conversion::Vec3OgreToNx(Direction);
    		Dir *= 100;
    		mDoorActor->addForce(Dir);
    
    		return (true);
    		
    
    	}
    // =====================================================================
    // =====================================================================
    
    	void Door::alignAll() {
    		
    		//mDoorActor->setGlobalPosition( CG::Conversion::Vec3OgreToNx( mDoorNode->getPosition() ));
    		//mDoorActor->setGlobalOrientationQuat( CG::Conversion::QuaOgreToNx( mDoorNode->getOrientation() ));
    
    		mDoorNode->setPosition( Conversion::Vec3NxToOgre( mDoorActor->getGlobalPosition()));
    		mDoorNode->setOrientation( Conversion::QuaNxToOgre( mDoorActor->getGlobalOrientationQuat()));
    
    		mDoorClosePosition = mDoorNode->getPosition();
    	}
    
    // =====================================================================
    
    	void Door::update() {
    
    		// update particle system
    		mDoorParticle->_updateParticleSystem();
    
    		// if the door is not close and timer has incresed for 2 second
    		if(mCurrentDoorState != DS_CLOSED && (mDoorTimer->getMilliseconds() > mDoorClosingTime) )
    		{
    			mCurrentDoorState = DS_CLOSING;
    			mDoorActor->clearBodyFlag( NX_BF_KINEMATIC );
    
    			mSoundChannel->stop();		// stop the sound if playing
    
    			// play a closing sound
    			FMOD::System *mSoundSys;
    			mDoorClosingSound->getSystemObject(&mSoundSys);
    			mSoundSys->playSound(FMOD_CHANNEL_FREE, mDoorClosingSound, false, &mSoundChannel);
    			mSoundChannel->set3DAttributes(Conversion::Vec3NxToFMOD(mDoorActor->getGlobalPosition()), 0);
    			mSoundChannel->setPaused(false);
    
    		}
    
    		// check where the door is opening or closing
    		if(mCurrentDoorState == DS_OPENING)
    		{
    
    			openDoor();			// add a little bit force to open the door
    
    			if(mDoorTimer->getMilliseconds() > 1000) {		// if specific time has been elapsed means door has opend
    				mCurrentDoorState = DS_OPENED;
    				mDoorActor->raiseBodyFlag( NX_BF_KINEMATIC );
    			}
    		}
    
    		else if(mCurrentDoorState == DS_CLOSING)
    		{
    			if(closeDoor() == true) {
    				mCurrentDoorState = DS_CLOSED;
    				mDoorActor->raiseBodyFlag( NX_BF_KINEMATIC );
    				Ogre::LogManager::getSingleton().logMessage("******************************Door has been closed");
    			}
    		}
    
    		// update the door graphicla model
    		mDoorNode->setPosition(Conversion::Vec3NxToOgre(mDoorActor->getGlobalPosition()));
    		mDoorNode->setOrientation(Conversion::QuaNxToOgre(mDoorActor->getGlobalOrientationQuat()));
    
    	}
    // =====================================================================
    
    // =====================================================================
    }
    
    // --- CG_DoorHandling.cpp --------------------------
    What i want to do,

    I want to export this class into a dll,
    so other cannot view the implimentation.
    I only want to provide them header file only and that dll file so they will not be able to edit this class.

    Thanks.
    Muhammad Ahmed.

  2. #2
    Join Date
    May 2009
    Posts
    28

    Re: Making a DLL, How??


  3. #3
    Join Date
    Jun 2009
    Posts
    7

    Re: Making a DLL, How??

    Main Story why am i asking this question, I use different APIs like Ogre SDK, PhysX SDK, FMOD SDK,

    so what these SDK do,
    1. They provide header files having extension .h, I include this header file into my project.

    2. They provide a file having extension .lib, I include this file into my project like this:
    Code:
    #pragma comment( lib, "OgreMain.lib" )	// adding library file
    3. They provide a dll file, When i compile my project it produce a exe file, when i run this exe file it demands for dll then i copy that provided dll file into my exe folder then my exe file executes correctly

    they don't provide cpp files, they hide implimentation, i want to know that how they do so,
    A complete tutorial that explain it all step by step.

    What i know:
    dll stands for Dynamic Link Libraries, they are files having similar structure like exe files. The executable code for the function is located in a DLL.

    Dont Know,
    But don't know the whole process of making dll and lib files.
    Any tutorial link will be helpful.

    Thanks.
    Muhammad Ahmed

  4. #4
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    103

    Re: Making a DLL, How??

    just create a DLL project in your ide.

  5. #5
    Join Date
    Jun 2009
    Posts
    7

    Re: Making a DLL, How??

    I have already many classes, is it not possible to make a dll project,

    Any other solution plz.

    Thanks.

  6. #6
    Join Date
    May 2001
    Location
    Germany
    Posts
    1,158

    Re: Making a DLL, How??

    start over, create a new dll project, add your sources to it and you're done.
    Hey, there's tons of documentation about how to make a dll. It just needs a bit of effort to get through it. And you might happen to learn something new. Or are you afraid of it?

  7. #7
    Join Date
    Jul 2009
    Posts
    3

    Re: Making a DLL, How??

    I have added an web browser acitve x control.. And i am using its forward home etc methods but when we cal forward method at beining before any history get stored it displays a blank error message box?

    How i can change this metode as rather than the message box i want to show other message

    please help me

    thank you

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured