Archived

This topic is now archived and is closed to further replies.

taybrin

im making a scene graph and runnning into some probs

Recommended Posts

here is my code
  
class WorldEntityList;
class WorldEntity;
class WorldTree;

class WorldEntity {

	public:

		/* transformation vectors */
		GLfloat transform[3];
		GLfloat rotate[3];
		int rot_angle;
		GLfloat scale[3];

		ObjectList * object_list;
		WorldEntityList * child_entities;

		char * name;
		WorldEntity * next;

		WorldEntity(char * n) :  name(n) {
			transform[0] = 0.0;
			transform[1] = 0.0;
			transform[2] = 0.0;

			rot_angle = 0; // should this be a float


			rotate[0] = 0.0;
			rotate[1] = 0.0;
			rotate[2] = 1.0;

			scale[0] = 1.0;
			scale[1] = 1.0;
			scale[2] = 1.0;

			object_list = NULL;

			object_list = new ObjectList();
------>			child_entities = new WorldEntityList();
		}

		~WorldEntity() {}

		// depending on the object we will have one or more extra parameters

		void SetObject(char *, char *, char *, ...); 
		void SetTranslate(GLfloat, GLfloat, GLfloat);
		void SetRotate(int, GLfloat, GLfloat, GLfloat);
		void SetScale(GLfloat, GLfloat, GLfloat);
		int GetObjectTypeID(char *);

};

class WorldEntityList 
{
	public:

	WorldEntity * rootNode;

	WorldEntityList() {
		rootNode = NULL;
	}
	~WorldEntityList() {}

	WorldEntity * Insert(char * name) {
		if(!rootNode) {
			rootNode = new WorldEntity(name);
			return rootNode;
		}
		else {
			WorldEntity * temp = rootNode;
			while(temp->next != NULL) {
				temp = temp->next;
			}
			temp->next = new WorldEntity(name);
			return temp->next;
		}
	}
};


class WorldTree {
	
	private:
		int ent_index;

	public:
		WorldEntity * w_ents[100];
		WorldEntityList * world_ents;

		WorldTree() : ent_index(0) {
			world_ents = new WorldEntityList();
		}
		~WorldTree() {}

		WorldEntity * createNewEntity(char * name) {
			return world_ents->Insert(name);
			//w_ents[ent_index] = new WorldEntity(name);

			//return w_ents[ent_index++];

		}

};

  
It says that there is no default construct for WorldEntityList. This boggles me, the line it complains on has an arrow pointing to it. Does anyone have any ideas, i have been starting at it forever. Edited by - taybrin on October 23, 2001 5:33:54 AM Edited by - taybrin on October 23, 2001 5:34:20 AM

Share this post


Link to post
Share on other sites
You can separate your class definitions and member body. This way, the compiler won''t complain since all your classes members will be declared when it comes to the actual body members.

Share this post


Link to post
Share on other sites
I separated out all of my code into three different header files and I still get the same errors from VC++. Here are the errors,

d:\msdev98\myprojects\scene graph\worldentity.h(18) : error C2143: syntax error : missing ';' before '*'
d:\msdev98\myprojects\scene graph\worldentity.h(18) : error C2501: 'WorldEntityList' : missing storage-class or type specifiers
d:\msdev98\myprojects\scene graph\worldentity.h(18) : error C2501: 'child_entities' : missing storage-class or type specifiers

and here is the new code:

WorldEntity.h
    
#ifndef WORLDENTITY
#define WORLDENTITY 1

#include "WorldEntityList.h"
#include "ObjectList.h"

class WorldEntity {

public:

/* transformation vectors */
GLfloat transform[3];
GLfloat rotate[3];
int rot_angle;
GLfloat scale[3];

ObjectList * object_list;
WorldEntityList * child_entities;

char * name;
WorldEntity * next;

WorldEntity(char * n) : name(n) {
transform[0] = 0.0;
transform[1] = 0.0;
transform[2] = 0.0;

rot_angle = 0; // should this be a float


rotate[0] = 0.0;
rotate[1] = 0.0;
rotate[2] = 1.0;

scale[0] = 1.0;
scale[1] = 1.0;
scale[2] = 1.0;

object_list = NULL;

object_list = new ObjectList();
child_entities = new WorldEntityList();
};

~WorldEntity() {};

// depending on the object we will have one or more extra parameters

void SetObject(char *, char *, char *, ...);
void SetTranslate(GLfloat, GLfloat, GLfloat);
void SetRotate(int, GLfloat, GLfloat, GLfloat);
void SetScale(GLfloat, GLfloat, GLfloat);
int GetObjectTypeID(char *);

};

#endif


Here is the WorldEntityList.h file where this class is defined.

  
#ifndef WORLDLIST
#define WORLDLIST 1

#include "WorldTree.h"
#include "WorldEntity.h"

class WorldEntityList
{
public:

WorldEntity * rootNode;

WorldEntityList() {
rootNode = NULL;
};
~WorldEntityList() {};

WorldEntity * Insert(char * name) {
if(!rootNode) {
rootNode = new WorldEntity(name);
return rootNode;
}
else {
WorldEntity * temp = rootNode;
while(temp->next != NULL) {
temp = temp->next;
}
temp->next = new WorldEntity(name);
return temp->next;
}
};
};

#endif


Does anyone have any ideas on what may be wrong . . . I have been going hit and miss for awhile now with ideas.

Thanks

Matt

Edited by - taybrin on October 23, 2001 12:16:20 AM

Share this post


Link to post
Share on other sites
This isn''t your problem, but don''t do this:
... = new WorldEntityList();

It calls the copy constructor AND the operator().
99% of the time the operator() optimizes away to nothing, but if you ever define it for a class it''ll get called and then new xxx() won''t return a xxx*, but whatever the operator() returns.


Look at the line this error is on:
d:\msdev98\myprojects\scene graph\worldentity.h(18) : error C2143: syntax error : missing '';'' before ''*''

Whatever is before the * is likely undefined. You need a forward reference or include it''s header file.

A ; could actually be missing above that line as well. If it the first line in the file, look at the end of the last file #include''d for a missing ;.

Magmai Kai Holmlor
- Not For Rent

Share this post


Link to post
Share on other sites