Show SKE.h syntax highlighted
/*
Copyright (C) 2003, 2004, 2005 by Luca Cappa
Written by Luca Cappa groton@users.sourceforge.net
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SKE_H__
#define __SKE_H__
//????????????????????????????????????????
/*
// We expect to use Crystal Space everywhere.
#include <cssysdef.h>
// MSVC users do not run configure, so use special MSVC configuration file.
#if defined(CS_WIN32_CSCONFIG)
#include "config-msvc.h"
#else
#include "config.h"
#endif
*/
#include "movement3d.h"
#include "csgfx/rgbpixel.h"
#include "kposition.h"
#include "kappstate.h"
#include "kblockid.h"
#include "keventhandlermanager.h"
struct iVFS;
struct iEngine;
struct iLoader;
struct iImageIO;
struct iGraphics2D;
struct iGraphics3D;
struct iKeyboardDriver;
struct iMouseDriver;
struct iView;
struct iVirtualClock;
struct iObjectRegistry;
struct iEvent;
struct iSector;
struct iConsoleInput;
struct iConsoleOutput;
struct iFont;
struct iString;
struct iMeshWrapper;
struct iMeshFactoryWrapper;
struct iPolygon3D;
struct iMaterialWrapper;
struct iCollideSystem;
struct iTerrFuncState;
struct iDocumentNode;
class csVector3;
struct iDynamics;
struct iDynamicSystem;
struct iRigidBody;
class csColliderWrapper;
class csSimplePixmap;
class csSchedule;
struct iJoystickDriver;
struct iObjectModel;
struct iAws;
struct iAwsCanvas;
struct iAwsPrefManager;
struct iAwsSource;
struct iAwsComponent;
struct KSprite3D;
class KObject3D;
class KSprite3DList;
class KLandmark;
class KLandmarkList;
class KAppState;
class SkyBox;
class KCamera;
class KWireframe;
class KDataList;
class KLightList;
class KMission;
class KPath;
class KTerrain;
class KMap;
class Movement3D;
class KSign;
class KLight;
class KPlayer;
class KPosition;
struct iIntertrax2;
class KSavedDataManager;
struct KDragManager;
struct KMouseManager;
struct KCursor3D;
struct iKJoystick;
struct iKMission;
class KSegment3;
class KMode;
class SKE
{
public:
csRef<iVFS> m_vfs;
csRef<iEngine> m_engine;
csRef<iLoader> m_loader;
csRef<iGraphics2D> m_g2d;
csRef<iGraphics3D> m_g3d;
csRef<iKeyboardDriver> m_kbd;
csRef<iVirtualClock> m_vc;
csRef<iConsoleInput> m_consoleInput;
csRef<iConsoleOutput> m_consoleOutput;
csRef<iFont> m_font;
csRef<iImageIO> m_imageIO;
///collision detection system
csRef<iCollideSystem> m_collisionDet;
csRef<KSavedDataManager> m_savedDataMan;
csRef<iEventHandler> m_installedEventHandler;
///The event handler manager.
csRef<KEventHandlerManager> m_evHndlrMan;
///Used to push events in the queue.
csRef<iEventOutlet> m_eventOutlet;
//
//for the player!!
KPosition m_initPos;
csRef<KPlayer> m_player;
void HandlePlayerHeadMovement (float p_speedRadians);//????UGLY!
/**
* Add additional debug infos?
*/
bool mDebugMode;
///Is the main window minimized?
bool m_backgrounded;
KAppState const m_appState;
csRef<KMouseManager> m_mouseManager;
csRef<KCursor3D> m_cursor;
///the camera!
KCamera* m_kcam;
///The tracker.
csRef<iIntertrax2> m_intertrax2;
//
//For the joystick!
bool m_useJoy;
csRef<iJoystickDriver> m_joyDriver;
csRef<iKJoystick> m_joy;
bool HandleEvent (iEvent&);
void EatKeyPress (iEvent* Event);
bool CommandHandler (const char *cmd, const char *arg);
static bool SKE::CommandHandlerBridge (const char *cmd, const char *arg);
csRef<KDragManager> m_dragManager;
void SetupFrame ();
void FinishFrame ();
void Gfx2DWrite (iFont*, int, int, int, int, char*,...);
void DoGravity (const csVector3& pos, csVector3& vel,const csMatrix3&);
/* //@@@@
csRef<iMeshFactoryWrapper> imeshfact_snow;
csRef<iMeshWrapper> snow;*/
public:
///SUI
iAwsPrefManager* m_awsPrefMan;
csRef<iAwsCanvas> m_awsCanvas;
csRef<iAws> m_aws;
///Ctor.
SKE ();
///Dtor.
~SKE ();
bool Initialize();
void Start ();
csRef<iAwsWindow> m_plConfWnd; //general dialog win.
csRef<iAwsWindow> m_replayWnd; //replay dialog win.
//////////////////////////////////////
//datas below is for collecting the replay
float m_replaySpeed;
int m_replayMsecs;
KPath* m_walkedPath;
//////////////////////////////////////
//datas below is for collecting data of a mission.
csRef<KMission> m_mission;
void SaveMissionInsideImage (iKMission* p_mission);
void Blit (iImage*, iImage*, int, int, int, int);
void CreateImageArray (csRefArray<iImage>& p_array, char* p_fileName);
iTextureWrapper* mViewFinderMaterial;
////////////////////////////////////////////
//data below is for editing!
csRef<KMap> m_map;//the map of the world.
csRef<KPath> m_path;//the path.
KBlockId m_blockIdSelected;
const KBlockId GetSelectedBlockId();
////////////////////////////////////////////
//datas below is for the graphics app K.
bool m_drawSkybox;
//?????Disabled until some1 will fix the terrain related code! bool m_drawTerrain;
bool m_putLightOntoHead;
SkyBox* m_skyBox;
//?????Disabled until some1 will fix the terrain related code! KTerrain* m_terrain;
csRef<iSector> m_world;
csRef<iSector> m_hiddenWorld;
csRef<iLight> m_light;//this light is put on the head of the player.
bool m_useDynaVis;
////////////////////////////////////////////
//datas below is for MISSION.
int m_timePassed;//msecs
KSign* m_sign;
float mPathTolerance;
////////////////////////////////////////////
//datas below is for LANDMARKS.
csRef<KLandmarkList> m_listLM;
KMode* mMode;
//
//Utility functions.
//
int FindRGBColor (csColor const& pColor);
/**
*/
void AddDateHour (iString* p_string);
//
// Calculate the intersection between a plane and a segment. if not
//specified the default plane is Y=0.
bool SKE::CalculateIntersection (int p_x, int p_y, csPlane3 p_plane,
csVector3& pIntersection, float& pDistanceAlongSegment);
static iMaterialWrapper* CreateMaterial(char* p_name, float p_r, float p_g, float p_b);
static iMaterialWrapper* LoadMaterial (char const* p_matName, char const* p_path);
void LoadLevel (iDocumentNode* p_levelNode);
void LoadLandmarks (iDocumentNode* p_lmNode);
csPtr<iTextureHandle> MyLoadImage (char* file, bool p_keyColor =false,
const csRGBcolor& p_color = csRGBcolor());
/**
Hit a mesh.
*/
iMeshWrapper* HitMeshWrapper (const csVector3& l_fromW,
const csVector3& l_directionW, csVector3& p_hitPoint);
bool MountDirectory (const char* p_vpath, const char* p_path);
iMaterialWrapper* CreateMaterial (iTextureHandle* p_tH, char* p_name =NULL);
//Geometrical function.
static float PointSegmentDistance (const csVector3& p_point,
const KSegment3& p_seg, csVector3& p_nearestPoint);
//output
static void Report (int severity, const char* msg, ...);
bool SaveImage (iImage* p_i, char* p_fileName);
///
///
///Load a texture from file.
iTextureWrapper* SKE::LoadTexture (char const* pName, char const* pFileName);
};//class
//
//Definition of my custom events
enum
{
//??cscmdCameraMoved = 0x80000001,
cscmdDragStart = 0x80000001,
cscmdDragEnd,
cscmdDragging,
};
//definition of our two global vars!
extern SKE* g_ske;
extern iObjectRegistry* g_objReg;
//exporting of some utility functions.
/*double String2Double (iString* p_string);
double String2Double (csString const& p_string);
csRef<iString> Double2String (float p_double);
float kround (float);
float krand (float p_max);
float clampRadiantAngle (float& p_rad);//??DELETEME!!!!!!!!!*/
//--------------------------------------------------------------
//Utility class.
template<class T>
class KEventHandlerHelper : public iEventHandler
{
private:
T* m_handler;
public:
SCF_DECLARE_IBASE;
KEventHandlerHelper (T* p_handler)
{
SCF_CONSTRUCT_IBASE (0);
m_handler = p_handler;
}
virtual bool HandleEvent (iEvent& p_e)
{
return m_handler->HandleEvent (p_e);
}
};//class
//--------------------------------------------------------------
//----
struct KEventPlug : public iEventPlug
{
SCF_DECLARE_IBASE;
virtual unsigned GetPotentiallyConflictingEvents ()
{
return 0xff;//????????????? what this value is???
}
virtual unsigned QueryEventPriority (unsigned )
{
return 0xff;//????????????? what this value is???
}
};
//----
//
//Prototypes for the UI.
//
//
//these below are for the Lighting tab.
void GetLightListLB (void* p_void, iAwsSource * p_awsSource);
void GetPosXTB (void* p_void, iAwsSource * p_awsSource);
void GetPosYTB (void* p_void, iAwsSource * p_awsSource);
void GetPosZTB (void* p_void, iAwsSource * p_awsSource);
void GetRadiusTB (void* p_void, iAwsSource * p_awsSource);
void GetRedTB (void* p_void, iAwsSource * p_awsSource);
void GetGreenTB (void* p_void, iAwsSource * p_awsSource);
void GetBlueTB (void* p_void, iAwsSource * p_awsSource);
void GetStaticRB (void* p_void, iAwsSource * p_awsSource);
void GetPseudodynamicRB (void* p_void, iAwsSource * p_awsSource);
void GetDynamicRB (void* p_void, iAwsSource * p_awsSource);
void GetNoneAttRB (void* p_void, iAwsSource * p_awsSource);
void GetLinearAttRB (void* p_void, iAwsSource * p_awsSource);
void GetInverseAttRB (void* p_void, iAwsSource * p_awsSource);
void GetRealisticAttRB (void* p_void, iAwsSource * p_awsSource);
void GetCLQAttRB (void* p_void, iAwsSource * p_awsSource);
void LightUpdate ();
void Create5Lights ();
void LSelectionChanged (void* p_void, iAwsSource * p_awsSource);
void CreateLight (void* p_void, iAwsSource * p_awsSource);
void DestroyLight (void* p_void, iAwsSource * p_awsSource);
void Relight (void* p_void, iAwsSource * p_awsSource);
//
//these below are for the Task tab.
void TaskSelectionChangedLB (void* p_void, iAwsSource * p_awsSource);
void GetTaskLB (void* p_void, iAwsSource * p_awsSource);
void GetSaveTaskTB (void* p_void, iAwsSource * p_awsSource);
void DeleteTask (void* p_void, iAwsSource * p_awsSource);
void LoadTask (void* p_void, iAwsSource * p_awsSource);
void SaveTask (void* p_void, iAwsSource * p_awsSource);
//
//these below are for the Mission tab.
void GetTargetRB (void* p_void, iAwsSource * p_awsSource);
void PutTargetRB (void* p_void, iAwsSource * p_awsSource);
void GetFreeWalkingRB (void* p_void, iAwsSource * p_awsSource);
void PutFreeWalkingRB (void* p_void, iAwsSource * p_awsSource);
void GetNotFreeWalkingRB (void* p_void, iAwsSource * p_awsSource);
void PutNotFreeWalkingRB (void* p_void, iAwsSource * p_awsSource);
void GetPointingTargetRB (void* p_void, iAwsSource * p_awsSource);
void PutPointingTargetRB (void* p_void, iAwsSource * p_awsSource);
void GetMissionAllowedTimeTB (void* p_void, iAwsSource * p_awsSource);
void StartMission (void* p_void, iAwsSource * p_awsSource);
void EndMission (void* p_void, iAwsSource * p_awsSource);
void StopSaveMission (void* p_void, iAwsSource * p_awsSource);
void GetTargetListLB (void* p_void, iAwsSource * p_awsSource);
void MTargetSelectionChanged(void* p_void, iAwsSource * p_awsSource);
void GetSaveMissionTB(void* p_void, iAwsSource * p_awsSource);
void DiscardDataCB (void* p_void, iAwsSource * p_awsSource);
void MUpdate();
//
//these below are the Player Configuration tab.
void GetHeightPlayerTB (void* p_void, iAwsSource * p_awsSource);
void GetFrictionPlayerTB (void* p_void, iAwsSource * p_awsSource);
void GetAccKPlayerTB (void* p_void, iAwsSource * p_awsSource);
void GetMaxVelPlayerTB (void* p_void, iAwsSource * p_awsSource);
void GetFOVAnglePlayerTB (void* p_void, iAwsSource * p_awsSource);
void GetFOVWidthPlayerTB (void* p_void, iAwsSource * p_awsSource);
void GetXPlayerTB (void* p_void, iAwsSource * p_awsSource);
void GetZPlayerTB (void* p_void, iAwsSource * p_awsSource);
void GetAnglePlayerTB (void* p_void, iAwsSource * p_awsSource);
void PlConfApply (void* p_void, iAwsSource * p_awsSource);
void PlConfUpdate();
void GetInitPosNameTB (void* p_void, iAwsSource * p_awsSource);
void GetInitPosListLB (void* p_void, iAwsSource * p_awsSource);
void DeleteInitPos (void* p_void, iAwsSource * p_awsSource);
void LoadInitPos (void* p_void, iAwsSource * p_awsSource);
void SaveInitPos (void* p_void, iAwsSource * p_awsSource);
void InitPosSelectionChanged (void* p_void, iAwsSource * p_awsSource);
//
//these below are the K page.
void GetUseJoystickCB (void* p_void, iAwsSource * p_awsSource);
void GetUseDynaVisCB (void* p_void, iAwsSource * p_awsSource);
void GetSkyBoxCB (void* p_void, iAwsSource * p_awsSource);
//?????Disabled until some1 will fix the terrain related code!void GetTerrainCB (void* p_void, iAwsSource * p_awsSource);
void GetDebugModeCB (void* p_void, iAwsSource * p_awsSource);
void GetSkyBoxHourTB (void* p_void, iAwsSource * p_awsSource);
void GetLightOntoHeadCB (void* p_void, iAwsSource * p_awsSource);
void GetLandscapeRB (void* p_void, iAwsSource * p_awsSource);
void GetSunRB (void* p_void, iAwsSource * p_awsSource);
void PutLandscapeRB (void* p_void, iAwsSource * p_awsSource);
void PutSunRB (void* p_void, iAwsSource * p_awsSource);
void GetShowCloudsCB (void* p_void, iAwsSource * p_awsSource);
void GetAmbientRedTB (void* p_void, iAwsSource * p_awsSource);
void GetAmbientGreenTB (void* p_void, iAwsSource * p_awsSource);
void GetAmbientBlueTB (void* p_void, iAwsSource * p_awsSource);
void GetDynAmbientRedTB (void* p_void, iAwsSource * p_awsSource);
void GetDynAmbientGreenTB (void* p_void, iAwsSource * p_awsSource);
void GetDynAmbientBlueTB (void* p_void, iAwsSource * p_awsSource);
void KApply (void* p_void, iAwsSource * p_awsSource);
void KUpdate();
void Exit (void* p_void, iAwsSource * p_awsSource);
//
//these below are the Editor page.
void EditorApply (void* p_void, iAwsSource * p_awsSource);
void EditorUpdate();
void SaveE (void* p_void, iAwsSource * p_awsSource);
void LoadE (void* p_void, iAwsSource * p_awsSource);
void NewMap (void* p_void, iAwsSource * p_awsSource);
void GetMapXTB (void* p_void, iAwsSource * p_awsSource);
void GetMapZTB (void* p_void, iAwsSource * p_awsSource);
void F (void* p_void, iAwsSource * p_awsSource);
void I1 (void* p_void, iAwsSource * p_awsSource);
void I2 (void* p_void, iAwsSource * p_awsSource);
void L1 (void* p_void, iAwsSource * p_awsSource);
void L2 (void* p_void, iAwsSource * p_awsSource);
void L3 (void* p_void, iAwsSource * p_awsSource);
void L4 (void* p_void, iAwsSource * p_awsSource);
void T1 (void* p_void, iAwsSource * p_awsSource);
void T2 (void* p_void, iAwsSource * p_awsSource);
void C (void* p_void, iAwsSource * p_awsSource);
void D1 (void* p_void, iAwsSource * p_awsSource);
void D2 (void* p_void, iAwsSource * p_awsSource);
const KBlockId GetSelectedBlockId();//????
void GetLevelNameTB (void* p_void, iAwsSource * p_awsSource);
void GetLoadLevelBT (void* p_void, iAwsSource * p_awsSource);
void GetSaveLevelBT (void* p_void, iAwsSource * p_awsSource);
void GetDestroyLevelBT (void* p_void, iAwsSource * p_awsSource);
void GetLevelsListLB (void* p_void, iAwsSource * p_awsSource);
void ESelectionChanged (void* p_void, iAwsSource * p_awsSource);
void DestroyE (void* p_void, iAwsSource * p_awsSource);
//
//these below are the Landmark page.
void CreateLM (void* p_void, iAwsSource * p_awsSource);
void DestroyLM (void* p_void, iAwsSource * p_awsSource);
void LMApply (void* p_void, iAwsSource * p_awsSource);
void LMUpdate();
void SaveLM (void* p_void, iAwsSource * p_awsSource);
void LoadLM (void* p_void, iAwsSource * p_awsSource);
void DeleteLM (void* p_void, iAwsSource * p_awsSource);
void LMSelectionChanged (void* p_void, iAwsSource * p_awsSource);
void LMCreatedSelectionChanged (void* p_void, iAwsSource * p_awsSource);
void LMSSelectionChanged(void* p_void, iAwsSource * p_awsSource);
void GetLandmarkToCreateLB (void* p_void, iAwsSource * p_awsSource);
void GetCreatedLMListLB (void* p_void, iAwsSource * p_awsSource);
void GetPositionXLMTB(void* p_void, iAwsSource * p_awsSource);
void GetPositionYLMTB(void* p_void, iAwsSource * p_awsSource);
void GetPositionZLMTB(void* p_void, iAwsSource * p_awsSource);
void GetSizeXLMTB(void* p_void, iAwsSource * p_awsSource);
void GetSizeYLMTB(void* p_void, iAwsSource * p_awsSource);
void GetSizeZLMTB(void* p_void, iAwsSource * p_awsSource);
void GetLandmarksNameTB (void* p_void, iAwsSource * p_awsSource);
void GetLandmarksListLB (void* p_void, iAwsSource * p_awsSource);
void GetMaterialLB (void* p_void, iAwsSource * p_awsSource);
void MaterialSelectionChanged (void* p_void, iAwsSource * p_awsSource);
//
//these below are the Path page.
void PathApply (void* p_void, iAwsSource * p_awsSource);
void PathUpdate ();
void SavePath (void* p_void, iAwsSource * p_awsSource);
void LoadPath (void* p_void, iAwsSource * p_awsSource);
void DeletePath (void* p_void, iAwsSource * p_awsSource);
void GetPathNameTB (void* p_void, iAwsSource * p_awsSource);
void GetPathPathLB (void* p_void, iAwsSource * p_awsSource);
void PathSelectionChangedPath (void* p_void, iAwsSource * p_awsSource);
void StartCreatingPath (void* p_void, iAwsSource * p_awsSource);
void StopPathCreation (void* p_void, iAwsSource * p_awsSource);
void DeleteCurrentPath (void* p_void, iAwsSource * p_awsSource);
void GetPathToleranceTB (void* p_void, iAwsSource * p_awsSource);
//
//these below are the Replay dialog.
void GetMissionLB (void* p_void, iAwsSource * p_awsSource);
void GetTargetNameL (void* p_void, iAwsSource * p_awsSource);
void GetTimeL (void* p_void, iAwsSource * p_awsSource);
void GetPathNameL (void* p_void, iAwsSource * p_awsSource);
void GetLmListNameL (void* p_void, iAwsSource * p_awsSource);
void GetMissionTypeL (void* p_void, iAwsSource * p_awsSource);
void GetInitPosNameL (void* p_void, iAwsSource * p_awsSource);
void GetLevelNameL (void* p_void, iAwsSource * p_awsSource);
void GetMissionNameL (void* p_void, iAwsSource * p_awsSource);
void GetMissionLB (void* p_void, iAwsSource * p_awsSource);
void ReplayUpdate ();
void StartReplay (void* p_void, iAwsSource * p_awsSource);
void StopReplay (void* p_void, iAwsSource * p_awsSource);
void MissionSelectionChangedLB (void* p_void, iAwsSource * p_awsSource);
//
//The buttons listeners.
void Apply (void* p_void, iAwsSource * p_awsSource);
void Ok (void* p_void, iAwsSource * p_awsSource);
void Cancel (void* p_void, iAwsSource * p_awsSource);
#endif // __SKE_H__
See more files for this project here