adding my FPS Camera to IRRlicht

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

adding my FPS Camera to IRRlicht

Post by christianclavet »

Hi,

I've decided to see If I would be able to add my FPS Camera features to IRRlicht as a advanced FPS camera.

I was able to copy and create a copy of the FPS Camera animator, defined it as a new name, incorporated the new name also in the scene manager, and added the new ACTIONs in the SKEYMAP.H file.

I compiled back the code in MSCV 2008 (Express) and it compiled without any error. The new features are not there yet but the "base template" is there and working. Compiled and tried some demos, all seem ok so far.

The original modified files are theses:

include/SKeyMap.h --> Added new SKeyMap with more actions
source/CSceneManager.h --> Added the new camera animator as a defined camera
source/CSceneManager.cpp --> Added the new camera animator as a defined camera


Added files:
include/ISceneNodeAnimatorCameraFPS_Adv.h --> Current copy of the FPS camera animator
source/CSceneNodeAnimatorCameraFPS_Adv.cpp --> Current copy of the FPS camera animator
source/CSceneNodeAnimatorCameraFPS_Adv.h --> Current copy of the FPS camera animator

For the new SKeyMap. I think I have a small problem. Got some kind enum error, when I define it in the new FPS Cam animator. I'll will find out where the problem is with the code. Right now, reverted it back as the copy of the FPS Cam Animator.

Here the current code of SKeyMap.h:

Code: Select all

// Copyright (C) 2002-2008 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h

#ifndef __S_KEY_MAP_H_INCLUDED__
#define __S_KEY_MAP_H_INCLUDED__

#include "Keycodes.h"

namespace irr
{

	//! enumeration for key actions. Used for example in the FPS Camera.
	enum EKEY_ACTION
	{
		EKA_MOVE_FORWARD = 0,
		EKA_MOVE_BACKWARD,
		EKA_STRAFE_LEFT,
		EKA_STRAFE_RIGHT,
		EKA_JUMP_UP,
		EKA_COUNT,

		//! This value is not used. It only forces this enumeration to compile in 32 bit.
		EKA_FORCE_32BIT = 0x7fffffff
	};
	
	//! Struct storing which key belongs to which action.
	struct SKeyMap
	{
		EKEY_ACTION Action;
		EKEY_CODE KeyCode;
	};

	//! enumeration for key actions. Used for example in the FPS Camera, support more actions.
	enum EKEY_ACTION_ADVANCED 
	{ 
		EKAA_MOVE_FORWARD = 0, 
		EKAA_MOVE_BACKWARD, 
		EKAA_STRAFE_LEFT, 
		EKAA_STRAFE_RIGHT, 
		EKAA_JUMP_UP, 
		EKAA_TILT_LEFT, 
		EKAA_TILT_RIGHT, 
		EKAA_SPRINT, 
		EKAA_CROUCH, 
		EKAA_CRAWL, 
		EKAA_ATTACK0, 
		EKAA_ATTACK1, 
		EKAA_ATTACK2, 
		EKAA_ATTACK3, 
		EKAA_ATTACK4, 
      	EKAA_WEAPON0, 
      	EKAA_WEAPON1, 
      	EKAA_WEAPON2, 
      	EKAA_WEAPON3, 
		EKAA_WEAPON4, 
		EKAA_WEAPON5, 
		EKAA_WEAPON6, 
		EKAA_WEAPON7, 
		EKAA_WEAPON8, 
		EKAA_WEAPON9, 
		EKAA_USE, 
		EKAA_INVENTORY, 
		EKAA_DROP, 
		EKAA_OPTIONS, 
		EKAA_CONSOLE, 
		EKAA_MENU,
		EKAA_COUNT,

		//! This value is not used. It only forces this enumeration to compile in 32 bit. 
		EKAA_FORCE_32BIT = 0x7fffffff 
	}; 

	//! Struct storing which key belongs to which action. 
    struct SKeyMap_Adv 
    { 
		EKEY_ACTION_ADVANCED Action; 
		EKEY_CODE KeyCode; 
    }; 


} // end namespace irr

#endif
Is the methodology is OK? Would this be valid as a ADDON proposal?
CuteAlien
Admin
Posts: 9735
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Hm, your actions don't really seem to have to do much with the camera. The original actions are all about moving the camera - your actions seem to be mostly about animation. That doesn't mean it couldn't be used otherwise - there might be more places where actions could be used.

But it is also rather game-specific stuff - in your case obviously for a shooter. And I don't really think that belongs in the engine but it's rather something for an extension.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

yes, you're right. This could better fit into an IRRext.
Post Reply