Help, with um, my class composition?

Started by
3 comments, last by Shamino 18 years, 4 months ago
class Object
{
public:


	bool MarkedForDeletion;
        float locx, locy, locz;
	virtual void GetRenderInformation(){}
	virtual void GetPhysicsInformation(){}
	virtual void GetSoundInformation(){}
	virtual void Update(){}


};

class Ship : public Object
{
public:
	
	Ship(float x, float y, float z)
	{
		x = locx;
                y = locy;
                z = locz;
	}

	void GetRenderInformation()
	{

	}

	void GetPhysicsInformation()
	{
	
	}

	void GetSoundInformation()
	{
	
	}

	void Update()
	{
	
	}
protected:

	// Cross specific functions go here

};


Okay, so ultimately, I want my render function to read what model is in Ship by doing a Ship.getrenderinfo, then taking what is in the constructor of ship and draw the ship at the x,y,z specified... My question isn't about the Draw function, it is about what exactly do I return with the GetRenderData function, simply a pointer to a model?
----------------------------------------------------------Rating me down will only make me stronger.----------------------------------------------------------
Advertisement
Yes, a pointer should be all that you need.
What the heck is the syntax for returning a pointer?

like this?

	MS3DModel *GetRenderInformation()	{		return Model1;	}
----------------------------------------------------------Rating me down will only make me stronger.----------------------------------------------------------
The same way you'd return anything else.

MyModelClass* Model = new MyModelClass("awesome.3ds", REALLY_COOL);
return Model;

would return a pointer to MyModelClass.
EDIT: That is, a pointer to that instance of MyModelClass, 'course.
It only takes one mistake to wake up dead the next morning.
Okay, so lets talk about resource management now...

Where in the world do I declare the pointer for Model....

Do I have a resource management class that simply creates pointers for each model that I load and throws them into a vector...

And then have the getrenderdata function look in that container of pointers for model?
----------------------------------------------------------Rating me down will only make me stronger.----------------------------------------------------------

This topic is closed to new replies.

Advertisement