Sign in to follow this  
mike25025

my game engine. comments wanted

Recommended Posts

i have been working on a game engine for 3 months now and i have run into a problem but before i try to solve the problem i would like to know if i have a good design please tell me what u think
#ifndef MGE_H
#define MGE_H

#ifdef MGE_EXPORT
 #define MGE_API __declspec(dllexport)
#else
 #define MGE_API __declspec(dllimport)
 #ifdef _DEBUG
  #pragma comment(lib,"mge_d.lib")
 #else
  #pragma comment(lib,"mge.lib")
 #endif
#endif

namespace mge
{
	namespace core
	{
		MGE_API extern const void* null;

		typedef __int64 int64;
		typedef int64 ID;

		class Interface
		{
		private:
			int m_ref;
		protected:
			MGE_API Interface();
			MGE_API virtual ~Interface();
			MGE_API virtual void OnRelease();
			MGE_API virtual void OnAddRef();
		public:
			MGE_API void AddRef();
			MGE_API bool Release();
			MGE_API virtual Interface* QueryInterface(ID id);
		};

		enum TimerState
		{
			Running,
			Paused,
			Stopped
		};

		class ITimer : public Interface
		{
		protected:
			~ITimer(){};
		public:
			virtual void Start(float starttime=0.0f)=0;
			virtual void Pause()=0;
			virtual void Resume()=0;
			virtual void Stop()=0;
			virtual TimerState GetState()=0;
			virtual float GetTime()=0;
		};

		MGE_API ITimer* CreateTimer();
	}

	namespace fileio
	{
		class IDirectory;

		enum OpenType
		{
			Read,
			Write
		};

		enum PosType
		{
			Beginning,
			Current,
			End
		};

		class IFile : public core::Interface
		{
		protected:
			~IFile(){};
		public:
			virtual char* GetName()=0;
			virtual IDirectory* GetDirectory()=0;
			virtual bool Open(OpenType opentype)=0;
			virtual void Close()=0;
			virtual bool Delete()=0;
			virtual unsigned int GetSize()=0;
			virtual unsigned int GetPos()=0;
			virtual void SetPos(unsigned int pos,PosType postype)=0;
			virtual int Read(void* buf,unsigned int size,unsigned int count)=0;
			virtual void Write(void* buf,unsigned int size,unsigned int count)=0;
			virtual void Flush()=0;
		};

		class IDirectory : public core::Interface
		{
		protected:
			~IDirectory(){};
		public:
			virtual char* GetName()=0;
			virtual IDirectory* GetParent()=0;
			virtual char** GetDirectoryNames()=0;
			virtual char** GetFileNames()=0;
			virtual IDirectory* GetDirectory(char* name)=0;
			virtual IFile* GetFile(char* name)=0;
			virtual bool Delete()=0;
			virtual IFile* CreateNewFile(char* name)=0;
			virtual IDirectory* CreateNewDirectory(char* name)=0;
		};

		MGE_API IFile* GetProgramFile();
	}

	namespace math
	{
		MGE_API extern const float epsilon;
		MGE_API extern const float pi;
		MGE_API extern const float sqrt2;
		MGE_API extern const float e;

		MGE_API float Sqrt(float x);
		MGE_API float Sin(float x);
		MGE_API float Cos(float x);
		MGE_API float Tan(float x);
		MGE_API float ASin(float x);
		MGE_API float ACos(float x);
		MGE_API float ATan(float x);
		MGE_API float Abs(float x);
		MGE_API int Abs(int x);
		MGE_API float Pow(float x,float n);
		MGE_API int Pow(int x,int n);
		MGE_API float Pow(float x,int n);
		MGE_API float Mod(float x,float n);
		MGE_API int Mod(int x,int y);
		MGE_API float Floor(float x);
		MGE_API float Ceil(float x);
		MGE_API float Log(float x);
		MGE_API float Log10(float x);
		MGE_API float RToD(float x);
		MGE_API float DToR(float x);
		MGE_API float Rand();

		class Matrix4x4;

		class Vector3D
		{
		private:
			float m_x;
			float m_y;
			float m_z;
		public:
			MGE_API Vector3D();
			MGE_API ~Vector3D();
			MGE_API Vector3D(const Vector3D& vector);
			MGE_API Vector3D(float x,float y,float z);
			MGE_API float& operator()(unsigned char index);
			MGE_API void Normalize();
			MGE_API float GetLen();
			MGE_API Vector3D& operator=(Vector3D& vector);
			MGE_API Vector3D& operator+=(Vector3D& v);
			MGE_API Vector3D& operator-=(Vector3D& v);
			MGE_API Vector3D& operator*=(float f);
			MGE_API Vector3D& operator/=(float f);
			MGE_API Vector3D operator+();
			MGE_API Vector3D operator-();
			MGE_API Vector3D operator+(Vector3D& v);
			MGE_API Vector3D operator-(Vector3D& v);
			MGE_API Vector3D operator*(float f);
			MGE_API Vector3D operator/(float f);
			MGE_API bool operator==(Vector3D& v);
			MGE_API bool operator!=(Vector3D& v);
			MGE_API Vector3D& operator*=(Matrix4x4& m);
			MGE_API Vector3D operator*(Matrix4x4& m);
			MGE_API Vector3D& operator^=(Vector3D& v);
			MGE_API float operator*(Vector3D& v);
			MGE_API Vector3D operator^(Vector3D& v);
		};

		class Matrix4x4
		{
		private:
			float m_00;float m_01;float m_02;float m_03;
			float m_10;float m_11;float m_12;float m_13;
			float m_20;float m_21;float m_22;float m_23;
			float m_30;float m_31;float m_32;float m_33;
		public:
			MGE_API Matrix4x4();
			MGE_API ~Matrix4x4();
			MGE_API Matrix4x4(const Matrix4x4& matrix);
			MGE_API Matrix4x4(float f00,float f01,float f02,float f03,
				float f10,float f11,float f12,float f13,
				float f20,float f21,float f22,float f23,
				float f30,float f31,float f32,float f33);
			MGE_API float& operator()(unsigned char row,unsigned char col);
			MGE_API void MakeIdentity();
			MGE_API Matrix4x4& operator+=(Matrix4x4& m);
			MGE_API Matrix4x4& operator-=(Matrix4x4& m);
			MGE_API Matrix4x4& operator*=(Matrix4x4& m);
			MGE_API Matrix4x4& operator*=(float f);
			MGE_API Matrix4x4& operator/=(float f);
			MGE_API Matrix4x4 operator+();
			MGE_API Matrix4x4 operator-();
			MGE_API Matrix4x4 operator+(Matrix4x4& m);
			MGE_API Matrix4x4 operator-(Matrix4x4& m);
			MGE_API Matrix4x4 operator*(Matrix4x4& m);
			MGE_API Matrix4x4 operator*(float f);
			MGE_API Matrix4x4 operator/(float f);
			MGE_API bool operator==(Matrix4x4& m);
			MGE_API bool operator!=(Matrix4x4& m);
			MGE_API Matrix4x4 GetTranspose();
			MGE_API Matrix4x4 GetInverse();
		};

		MGE_API Matrix4x4 CreateXRotationMatrix(float r);
		MGE_API Matrix4x4 CreateYRotationMatrix(float r);
		MGE_API Matrix4x4 CreateZRotationMatrix(float r);
		MGE_API Matrix4x4 CreateScalingMatrix(float s);
		MGE_API Matrix4x4 CreateTranslationMatrix(float x,float y,float z);
		MGE_API Matrix4x4 CreateLookAtMatrix(Vector3D eye,Vector3D at,Vector3D up);
	}

	namespace video
	{
		enum TextureFormat
		{
			RGB,
			ARGB,
			A1R5G5B5,
			X1R5G5B5,
			R5G6B5,
			A4R4G4B4,
			X4R4G4B4,
			R8G8B8,
			A8R8G8B8,
			X8R8G8B8
		};

		class IVideoDevice;

		class ITexture : public core::Interface
		{
		protected:
			~ITexture(){};
		public:
			virtual unsigned int GetWidth()=0;
			virtual unsigned int GetHeight()=0;
			virtual unsigned int GetPitch()=0;
			virtual TextureFormat GetFormat()=0;
			virtual unsigned int BytesPerPixel()=0;
			virtual void* Lock()=0;
			virtual void Unlock()=0;
			virtual void CopyFromDevice(IVideoDevice* videodevice)=0;
			virtual unsigned int GetAMask()=0;
			virtual unsigned int GetRMask()=0;
			virtual unsigned int GetGMask()=0;
			virtual unsigned int GetBMask()=0;
		};

		class Color
		{
		private:
			float m_a;
			float m_r;
			float m_g;
			float m_b;
		public:
			MGE_API Color();
			MGE_API Color(float a,float r,float g,float b);
			MGE_API Color(unsigned long color);
			MGE_API operator double();
			MGE_API Color operator=(double color);
			MGE_API operator unsigned long();
			MGE_API Color operator=(unsigned long color);
			MGE_API float& operator()(unsigned char index);
			MGE_API Color& operator*=(Color& color);
			MGE_API Color& operator+=(Color& color);
			MGE_API Color& operator-=(Color& color);
			MGE_API Color operator+(Color& color);
			MGE_API Color operator-(Color& color);
			MGE_API Color operator*(Color& color);
			MGE_API void SetMax(float a,float r,float g,float b);
			MGE_API void SetMin(float a,float r,float g,float b);
		};

		struct Vertex
		{
			float x;
			float y;
			float z;
			float nx;
			float ny;
			float nz;
			unsigned long c;
			unsigned long b;
			float u;
			float v;
		};

		class ILight : public core::Interface
		{
		private:
			math::Vector3D m_pos;
			Color m_color;
			math::Vector3D m_direction;
		protected:
			~ILight(){};
			MGE_API ILight();
		public:
			virtual Color LightVertex(Vertex& vertex)=0;
			MGE_API void SetPos(math::Vector3D pos);
			MGE_API math::Vector3D GetPos();
			MGE_API void SetColor(Color color);
			MGE_API Color GetColor();
			MGE_API void SetDirection(math::Vector3D direction);
			MGE_API math::Vector3D GetDirection();
		};

		MGE_API ILight* CreatePointLight();
		MGE_API ILight* CreateOmniLight();
		MGE_API ILight* CreateDirectionalLight();

		enum VertexListType
		{
			LineList,
			LineStrip,
			TriangleList,
			TriangleStrip,
			TriangleFan
		};

		enum RenderState
		{
			Alpha,
			Filter,
			Fog,
			FogEnd,
			FogStart,
			FogColor,
			Projection,
			FOV,
			ZNear,
			ZFar,
			Lighting,
			Ambient,
			Cull,
			ZWrite
		};

		enum RenderStateValue
		{
			Enable = 1,
			Disable = 0,
			Linear = 1,
			Point = 0,
			Perspective = 1,
			Orthogonal = 0
		};

		class IVideoDevice : public core::Interface
		{
		protected:
			~IVideoDevice(){};
		public:
			virtual bool Init(int width=640,int height=480,int bits=16,
				bool fullscreen=true,char* caption="")=0;
			virtual void Uninit()=0;
			virtual bool Initalized()=0;
			virtual ITexture* LoadTexture(fileio::IFile* file,TextureFormat format=ARGB)=0;
			virtual void SetTexture(ITexture* texture)=0;
			virtual ITexture* GetTexture()=0;
			virtual void Render(Vertex* vertices,unsigned int nvertices,VertexListType vertexlisttype)=0;
			virtual void Render(Vertex* vertices,unsigned int nvertices,
				unsigned short* indices,unsigned short nindices,VertexListType vertexlisttype)=0;
			virtual void LookAt(math::Vector3D& eye,math::Vector3D& at,math::Vector3D& up)=0;
			virtual void GetLookAt(math::Vector3D* eye,math::Vector3D* at,math::Vector3D* up)=0;
			virtual void Flip()=0;
			virtual void Clear(Color color=Color(0,0,0,0),bool clearcolor=true,bool cleardepth=true)=0;
			virtual void SetRenderState(RenderState state,double value)=0;
			virtual double GetRenderState(RenderState state)=0;
			virtual void SetWorldMatrix(math::Matrix4x4& matrix)=0;
			virtual math::Matrix4x4 GetWorldMatrix()=0;
			virtual unsigned int AddLight(ILight* light)=0;
			virtual void RemoveLight(ILight* light)=0;
			virtual void RemoveLight(unsigned int light)=0;
			virtual ILight* GetLight(unsigned int light)=0;
			virtual unsigned int GetNLights()=0;
			virtual ITexture* CreateTexture(unsigned int width,unsigned int height,TextureFormat format)=0;
			virtual unsigned int GetWidth()=0;
			virtual unsigned int GetHeight()=0;
		};

		MGE_API IVideoDevice* CreateVideoDevice();
	}

	namespace audio
	{
		class ISound : public core::Interface
		{
		protected:
			~ISound(){};
		public:
			virtual ISound* Copy()=0;
			virtual void Play(bool loop=false)=0;
			virtual void Stop()=0;
			virtual void SetVolume(float volume)=0;
			virtual float GetVolume()=0;
			virtual void SetPitch(float pitch)=0;
			virtual float GetPitch()=0;
			virtual void SetPlayPos(float pos)=0;
			virtual float GetPlayPos()=0;
			virtual float GetLength()=0;
			virtual void SetPosition(math::Vector3D& v)=0;
			virtual math::Vector3D GetPosition()=0;
			virtual bool IsPlaying()=0;
			virtual void Pause()=0;
			virtual void Resume()=0;
		};

		class IMusic : public core::Interface
		{
		protected:
			~IMusic(){};
		public:
			virtual void Play(bool loop=false)=0;
			virtual void Stop()=0;
			virtual void SetVolume(float volume)=0;
			virtual float GetVolume()=0;
			virtual void SetPlayPos(float pos)=0;
			virtual float GetPlayPos()=0;
			virtual float GetLength()=0;
			virtual bool IsPlaying()=0;
			virtual void Pause()=0;
			virtual void Resume()=0;
		};

		class IAudioDevice : public core::Interface
		{
		protected:
			~IAudioDevice(){};
		public:
			virtual void LookAt(math::Vector3D& eye,math::Vector3D& at,math::Vector3D& up)=0;
			virtual void GetLookAt(math::Vector3D* eye,math::Vector3D* at,math::Vector3D* up)=0;
			virtual ISound* LoadSound(fileio::IFile* file)=0;
			virtual IMusic* LoadMusic(fileio::IFile* file)=0;
			virtual void SetUnitsPerMeter(float u)=0;
			virtual float GetUnitsPerMeter()=0;
		};

		MGE_API IAudioDevice* CreateAudioDevice();
	}

	namespace input
	{
		enum Key
		{
			Escape=1,		Key1=2,			Key2=3,			Key3=4,			Key4=5,			Key5=6,
			Key6=7,			Key7=8,			Key8=9,			Key9=10,		Key0=11,		Minus=12,
			Equals=13,		BackSpace=14,	Back=14,		Tab=15,			Q=16,			W=17,
			E=18,			R=19,			T=20,			Y=21,			U=22,			I=23,
			O=24,			P=25,			LeftBracket=26,	RightBracket=27,Enter=28,		Return=28,
			LeftControl=29,	A=30,			S=31,			D=32,			F=33,			G=34,
			H=35,			J=36,			K=37,			L=38,			Semicolon=39,	Apostrophe=40,
			Grave=41,		LeftShift=42,	BackSlash=43,	Z=44,			X=45,			C=46,
			V=47,			B=48,			N=49,			M=50,			Comma=51,		Period=52,
			Slash=53,		RightShift=54,	Multiply=55,	LeftAlt=56,		LeftMenu=56,	Space=57,
			Spacebar=57,	Caps=58,		CapsLock=58,	Capital=58,		F1=59,			F2=60,
			F3=61,			F4=62,			F5=63,			F6=64,			F7=65,			F8=66,
			F9=67,			F10=68,			NumLock=69,		ScrollLock=70,	Num7=71,		Num8=72,
			Num9=73,		Subtract=74,	Num4=75,		Num5=76,		Num6=77,		Add=78,
			Num1=79,		Num2=80,		Num3=81,		Num0=82,		Decimal=83,		OEM102=86,
			F11=87,			F12=88,			F13=100,		F14=101,		F15=102,		Kana=112,
			ABNTC1=115,		Convert=121,	NoConvert=123,	Yen=125,		ABNTC2=126,		NumEquals=141,
			PrevTrack=144,	Circumflex=144,	At=145,			Colon=146,		Underline=147,	Kanji=148,
			Stop=149,		Ax=150,			Unlabeled=151,	NextTrack=153,	NumEnter=156,	RightControl=157,
			Mute=160,		Calculator=161,	Play=162,		PlayPause=162,	MediaPause=162,	MediaPlay=162,
			MediaStop=163,	VolumeDown=174,	VolumeUp=176,	WebHome=178,	NumComma=179,	Divide=181,
			PrintScreen=183,SysRequest=183,	RightAlt=184,	RightMenu=184,	Pause=197,		Break=197,
			Home=199,		Up=200,			PageUp=201,		Prior=201,		Left=203,		Right=205,
			End=207,		Down=208,		PageDown=209,	Next=209,		Insert=210,		Delete=211,
			LeftWindows=219,RightWindows=220,Application=221,Power=222,		Sleep=223,		Wake=227,
			WebSearch=229,	WebFavorites=230,WebRefresh=231,WebStop=232,	WebForward=233,	WebBack=234,
			MyComputer=235,	Mail=236,		MediaSelect=237 
		};

		enum DeviceType
		{
			Keyboard,
			Mouse,
			Joystick
		};

		struct Effect
		{
			float attacktime;
			float attack;
			float fadetime;
			float fade;
			float time;
			float magnitude;
		};

		struct InputDeviceInfo
		{
			unsigned int nbuttons;
			unsigned int naxis;
			unsigned int npovs;
			DeviceType type;
			bool forcefeedback;
			core::ID id;
			char* name;
		};

		class IInputDevice : public core::Interface
		{
		protected:
			~IInputDevice(){};
		public:
			virtual InputDeviceInfo GetInfo()=0;
			virtual float GetAxisPos(unsigned int axis)=0;
			virtual bool ButtonDown(unsigned int button)=0;
			virtual float GetPovPos(unsigned int pov)=0;
			virtual void PlayEffect(const Effect& effect)=0;
			virtual void StopAllEffects()=0;
		};

		MGE_API unsigned int GetNDevices();
		MGE_API InputDeviceInfo GetDeviceInfo(unsigned int device);
		MGE_API IInputDevice* GetDevice(char* name,core::ID id);
	}

	namespace network
	{
		enum SysMessage
		{
			Connected=-1,
			Disconnected=-2
		};

		struct Message
		{
			int message;
			unsigned int from;
			void* data;
			unsigned int size;
		};

		class IClient : public core::Interface
		{
		protected:
			~IClient(){};
		public:
			virtual bool Connect(char* address,unsigned short port)=0;
			virtual void Disconnect()=0;
			virtual void Send(int message,void* data,unsigned int size)=0;
			virtual bool GetNextMessage(Message& message)=0;
		};

		class IServer : public core::Interface
		{
		protected:
			~IServer(){};
		public:
			virtual bool Start(unsigned short port)=0;
			virtual void Stop()=0;
			virtual void Disconnect(unsigned int id)=0;
			virtual void Broadcast(int message,void* data,unsigned int size)=0;
			virtual void SendTo(unsigned int to,int message,void* data,unsigned int size)=0;
			virtual bool GetNextMessage(Message& message)=0;
		};

		MGE_API IClient* CreateClient();
		MGE_API IServer* CreateServer();
	}

	namespace scene
	{
		class INodeData : public core::Interface
		{
		protected:
			~INodeData(){};
		public:
			virtual bool GetVector(char* name,math::Vector3D& v)=0;
			virtual void SetVector(char* name,math::Vector3D& v)=0;
		};

		MGE_API INodeData* CreateNodeData();

		class ISceneNode;

		class IScene : public core::Interface
		{
			ISceneNode** m_nodes;
			unsigned int m_nnodes;
		protected:
			MGE_API ~IScene();
			MGE_API IScene();
		public:
			MGE_API virtual void Render(video::IVideoDevice* device);
			MGE_API virtual unsigned int AddSceneNode(ISceneNode* node);
			MGE_API virtual void RemoveSceneNode(ISceneNode* node);
		};

		MGE_API IScene* CreateScene();

		enum RenderTime
		{
			DontRender,
			Pre,
			Normal,
			Post
		};

		class ISceneNode : public IScene
		{
		private:
			INodeData* m_nodedata;
			math::Vector3D m_pos;
			math::Vector3D m_direction;
			math::Vector3D m_up;
			float m_scale;
		protected:
			MGE_API ~ISceneNode();
			MGE_API ISceneNode();
		public:
			MGE_API INodeData* GetNodeData();
			MGE_API void SetNodeData(INodeData* data);
			virtual RenderTime PreRender(video::IVideoDevice* device)=0;
			virtual void Render(video::IVideoDevice* device)=0;
			virtual void PostRender(video::IVideoDevice* device)=0;
			MGE_API math::Vector3D GetPos();
			MGE_API void SetPos(math::Vector3D& pos);
			MGE_API math::Vector3D GetDirection();
			MGE_API void SetDirection(math::Vector3D& direction);
			MGE_API math::Vector3D GetUp();
			MGE_API void SetUp(math::Vector3D& up);
			MGE_API float GetScale();
			MGE_API void SetScale(float scale);
		};
	}
}

#endif

Share this post


Link to post
Share on other sites
Well I read quickly through the various declarations and it seems modular enough. Each class appears to be reasonably specific. But without an explanation of your system it is impossible to comment further.

Share this post


Link to post
Share on other sites
If I had one complaint I'd say that it's overly complex. For example, why do you define your own math functions? Those functions are part of the standard c library. I don't know if you're using DirectX or not, but I'm pretty sure the matrix functions are available in that API, too. In my opinion, an engine should enable the programmer to write games at a higher level than the API. Instead of giving the programmer a more organized interface to their matrix functions, try to eliminate the necessity for the programmer to worry about matrices at all.

Just a style thing:
float m_00;float m_01;float m_02;float m_03;
Is harder to read than:
float m_00, m_01, m_02, m_03;


Btw: your "SetUp" method is easily confused with the word Setup. Maybe changing it to "SetUpVector" or something would help make it less ambiguous? Just a though. Not a very important one at that.

Share this post


Link to post
Share on other sites
Quote:
Original post by smr
If I had one complaint I'd say that it's overly complex. For example, why do you define your own math functions? Those functions are part of the standard c library. I don't know if you're using directx or not, but I'm pretty sure the matrix functions are available there, too. In my opinion, an engine should enable the programmer to write games at a higher level. Instead of giving the programmer a more organized interface to their matrix functions, try to eliminate the necessity for the programmer to worry about matrices at all.


i was going to make the engine do all the collision detection but the i found a problem

i dont know why i defined the math functions (i think it was because i didnt want to type include math every where)
the matrics are there for portablity

Share this post


Link to post
Share on other sites
Quote:
Original post by mike25025
(i think it was because i didnt want to type include math every where)


Such is life. Just include math. It's better that way. It's less code for you to maintain. Less code is better.

Besides, that's what header files are there for.

And another thing, you probably typed more this way. You'd have to type #include <math.h> many, many, many times to amount to the same number of characters as all that stuff you typed.

Share this post


Link to post
Share on other sites
Quote:
Original post by mike25025
can u give me a list of things to include in my explanation
i have no idea where to begin


Well you could run through what someone would need to do to create a simple application using your engine.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kuladus
Quote:
Original post by mike25025
can u give me a list of things to include in my explanation
i have no idea where to begin


Well you could run through what someone would need to do to create a simple application using your engine.


what do u meen by simple?

and the engine isnt compleat yet because of the problem i found

so should i do?

decribe what i havent implmented yet and explane what the problem is or should i explain the engine in its current state?

Share this post


Link to post
Share on other sites
You need to get more high level things in it such as cameras, terrain, etc., and things that make it easier to make a game.

Quote:

decribe what i havent implmented yet and explane what the problem is or should i explain the engine in its current state?

Both.

Share this post


Link to post
Share on other sites
currently the engine is very low level
basicly at this point its a big abstraction layer

to make a game with it you would have to write a level loader and do your own collision detection

i found this somewhere on my hd

The levels would be divided into nodes and each node would be divided into more nodes. Then there would be a list of objects that would be used for charactors, doors, etc. No object would be inside a node so it would not be affected by the node's transformations. Both nodes and objects would have a string that would tell the level loading class which class to assign to the object or node. Objects would also have their own collision data (bounding volumes) and the engine would perform collision detection. That way there would be no collision detection code in the game code.

it decribes how the level files would be organized

and the problem is that i cant see a way of implementing a portal system using the scene nodes

Share this post


Link to post
Share on other sites
Quote:
Original post by smr
If I had one complaint I'd say that it's overly complex. For example, why do you define your own math functions? Those functions are part of the standard c library. I don't know if you're using DirectX or not, but I'm pretty sure the matrix functions are available in that API, too. In my opinion, an engine should enable the programmer to write games at a higher level than the API. Instead of giving the programmer a more organized interface to their matrix functions, try to eliminate the necessity for the programmer to worry about matrices at all.

Just a style thing:
float m_00;float m_01;float m_02;float m_03;
Is harder to read than:
float m_00, m_01, m_02, m_03;


Btw: your "SetUp" method is easily confused with the word Setup. Maybe changing it to "SetUpVector" or something would help make it less ambiguous? Just a though. Not a very important one at that.


or even better

float m_pMatrix[16];
0,4,8,12
1,5,9,13
2,6,10,14
3,7,11,15

thats a opengl conform matrix

and maybe move your declarations into seperate header files

my engine for example use structured like this
i have a standardinclude folder for all my headers
math_lib.h
+ math_vector.h
+ math_matrix.h
+ math_plane.h
...
system_lib.h // contains of a sys namespace with basic functions that are needed every now and then

the advantage of my code and the standard include folder is i don t have to worry about different versions of my basic files since i have only one version of each and i can easily reuse them in any project a simple include routine does the job

Share this post


Link to post
Share on other sites
i dont think i will continue to work on my engine
i cant solve the problem and implementing level loader/exporter is to complex for me
and without levels the engine isnt of much use

thanx for all your comments

Share this post


Link to post
Share on other sites
Don't give up completely. I have to say I'm quite impressed with your engine. There is room for improvement, yes, but if you've implemented all the methods you've listed you certainly have a worthwhile base to start from. The maths functions aren't even necessarily useless, if you ever end up porting something to the PS2 you'll find that the standard sin and cos implementations won't quite cut it in terms of speed, if you've consistently used your macros you should be able to do quite a pain-free swap.

Chief criticism would be that functions like

virtual Color ILight::LightVertex(Vertex& vertex)=0;

will not really be useful unless you're writing the very guts of your own renderer. I agree that slightly more abstract entity classes (Cameras, GeometryChunks, Terrain) would probably be a good thing to think about next, and after that would suggest perhaps working on some sort of material system, or establishing at least how materials relate to meshes so you can write your first demo application, even if it's all hard-coded. I'd suggest thinking about level loading slightly later on whenever you have made entity classes that you can easily provide data for.

Best of Luck

John

Share this post


Link to post
Share on other sites
I think that you should keep going with the engine now, you seem to have a pretty decent base to start off with, to be honest writing a level loader is not as hard as you would think, why not just use the standard c++ io file streams using text files, think about what you want to include in levels i.e. geomotry, lights, models etc all your level loader will do is pull in a file which lists all the things you can find in your level, and load the appropriate resources. The DX Extensions have some useful classes and functions to help you with this so you don't have to have a mental breakdown about creating your own model formats etc. Once you get this sorted then you can build on it with level scripts etc.

In terms of the maths functions I'm very happy to see them there, it won't take you too much time to implement them and in terms of maintaining the code, if you code them correctly in the first place then i doubt you will run into too many problems, the standard math functions are horribly slow, and you can do so much better in terms of speed if you sacrifice a bit of accuracy.

I hope that you feel encouraged to carry on, don't give up you will fix the problem's you are having eventually.

Share this post


Link to post
Share on other sites
Stop being a puss, finish what you start. Continue in a year or two to learn more? That basically means you'll never touch it again. I'd make it more like "continue in a few weeks after I've read my ass off".

The only way you'll ever make anything is if you continually screw up that engine and then rewrite that engine, over and over until it's worth something. If you just stop all of a sudden, your motivation dies along with the recent memory of exactly how that engine works.

Share this post


Link to post
Share on other sites

<pedant>

Quote:
Original post by smr
Btw: your "SetUp" method is easily confused with the word Setup. Maybe changing it to "SetUpVector" or something would help make it less ambiguous? Just a though. Not a very important one at that.


Are you sure Setup is really a word? ;)

</pedant>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this