Really Annoying Errors, Any help?

Started by
2 comments, last by Pink Horror 10 years, 4 months ago

Hello! I am creating a system in my engine that reads my custom format and I am having trouble.

jaie.png


class NXSceneObject : public NXGameObject
		{
			public:
				virtual void ReadData(NXBinaryReader* reader);
				virtual void Render(NXCamera3D* camera, NXGameTime* gameTime);

				virtual void Initialize();
				virtual void Update(NXGameTime* gameTime);
				void Render(NXGameTime* gameTime){}
				virtual void Dispose();

				NXGameObject* ParentScene;
				map<string, NXSceneObject> Chlidren;

				bool IsVisible;

				XMMATRIX WorldMatrix() { return XMMatrixScaling(Size.x, Size.y, Size.z) * XMMatrixTranslation(Position.x, Position.y, Position.z) * XMMatrixRotationRollPitchYaw(Rotation.x, Rotation.y, Rotation.z); }
				XMFLOAT3 Position;
				XMFLOAT3 Rotation;
				XMFLOAT3 Size;
				NXBoundingBox Bounds;

				NXSceneObject(NXBinaryReader* reader)
				{
					IsVisible = reader->ReadBoolean();
					Position = reader->ReadVector3(false);
					Rotation = reader->ReadVector3(false);
					Size = reader->ReadVector3(false);
					Bounds = reader->ReadBoundingBox(false);

					ReadData(reader);
				}
		};

		class NXScene : public NXGameObject
		{
			public:
				NXSceneConfiguration Information;

				NXPlayer Player;

				map<string, NXSceneObject> Objects;

				NXScene(){}

				void Initialize()
				{
					for (map<string, NXSceneObject>::iterator it = Objects.begin(); it != Objects.end(); it++)
					{
						it->second.Initialize();
					}
				}

				void Update(NXGameTime* gameTime)
				{
					for (map<string, NXSceneObject>::iterator it = Objects.begin(); it != Objects.end(); it++)
					{
						it->second.Update(gameTime);
					}
				}

				void Render(NXGameTime* gameTime)
				{
					for (map<string, NXSceneObject>::iterator it = Objects.begin(); it != Objects.end(); it++)
					{
						it->second.Render(Player.Camera, gameTime);
					}
				}

				void Dispose()
				{
					for (map<string, NXSceneObject>::iterator it = Objects.begin(); it != Objects.end(); it++)
					{
						it->second.Dispose();
					}

					Objects.clear();
				}

				void AddSceneObject(string name, NXSceneObject obj)
				{
					obj.ParentScene = this;
					Objects.insert(std::make_pair(name, obj));
				}
		};

class NXGameObject
		{
			public:
				LPCWSTR Name;
				bool RenderToTexture = true;
				bool IsActive = false;
				virtual void NEXENGINE_API Initialize() = 0;
				virtual void NEXENGINE_API Update(NXGameTime*) = 0;
				virtual void NEXENGINE_API Render(NXGameTime*) = 0;
				virtual void NEXENGINE_API RenderDeferred(NXGameTime*){}
				virtual void NEXENGINE_API Dispose() = 0;
		};

What I am trying to do is create an abstract class derived from NXGameObject. But when I try to use my NXScene class:


NXScene scene;
void TestScreen::Initialize()
{
	NXRenderer::Initialize(NXRType::Forward);

	scene = NXLoader::LoadSceneFromFile("C:/nx/town1.nxs");
}

I get the errors shown above. Any help? Thanks! smile.png

EDIT: Also here is an example of what the NXSceneObject class is used for:


class NXMarker : public NXSceneObject
		{
			public:
				NXMarker(NXBinaryReader* reader) : NXSceneObject(reader)
				{

				}
		};

class NXPlayerStartMarker : public NXMarker
		{
			public:
				float Health;
				float MoveSpeed;
				bool Realistic;

				NXPlayerStartMarker(NXBinaryReader* reader) : NXMarker(reader)
				{

				}

				void ReadData(NXBinaryReader* reader)
				{
					Realistic = reader->ReadBoolean();
					Health = reader->ReadFloat();
					MoveSpeed = reader->ReadFloat();
				}
		};
Advertisement

You didn't write any code for those five functions in your error messages. That's what makes them "unresolved symbols". The linker can't find any compiled code for them, and the simplest reason for that is usually because you didn't give the compiler anything to compile.

I didn't see the camera stuff in your code so I cannot tell you what's wrong with your warnings, but my guess is you are putting aligned matrices in a vector.

Hello, thanks for the reply. I am having another problem. Adding code fixes the problem, but it is not exactly what I am trying to do. My NXGameObject class has five abstract functions. What I would like to do now is be able to override the abstract/virtual functions of the NXGameObject class in any class derived from NXSceneObject (which is derived from NXGameObject). Shouldn't this be as simple as making the functions virtual then adding code in the class rather than adding it to the NXSceneObject class like this:


class NXPlayerStartMarker : public NXMarker
		{
			public:
				float Health;
				float MoveSpeed;
				bool Realistic;

				NXPlayerStartMarker(NXBinaryReader* reader) : NXMarker(reader)
				{

				}

				void ReadData(NXBinaryReader* reader)
				{
					Realistic = reader->ReadBoolean();
					Health = reader->ReadFloat();
					MoveSpeed = reader->ReadFloat();
				}

                                //NXMarker is derived from NXSceneObject which is derived from NXGameObject, so I override NXGameObject's Update function here.
                                void Update(NXGameTime* gameTime) override
                                {
                                        //Add Code Here
                                }
		};

I tried doing that, and it will not compile without the errors above. What do I need to do to allow me to override the abstract functions in NXGameObject from a class derived from NXSceneObject then derived from NXMarker? Similar to how it works in C#:


public abstract class A
{
   //Create the abstract method up here
   public abstract void Method();
}

public abstract class B : A
{
   //Pass down the abstract method
}

public class M : B
{
   //All the way
}

public class P : M
{
   //Down here and override it.
   public override void Method()
   {

   }
}

Sorry if I am not clear. Thanks for the help, I really appreciate it. :)

You added prototypes for those five functions to NXSceneObject, so the compiler expects implementations to exist. I believe you can delete the prototypes if you intend for NXSceneObject to remain abstract, just like your C#. You also should be able to add the "= 0" to the prototypes if your intention is for them to be pure virtual functions.

This topic is closed to new replies.

Advertisement