Thanks for the links. Accually the whole page was kind of nice[bookmarked].
I am still working on this, but I think I have made some progress at least.
Now I dont get any erros when compiling the class, but I do when I try to acces members of the sphere class.
Here is what I have for my classes
Code:
class Primitive
{
public:
Primitive(std::string n = "DefaultName");
//~Primitive();
//void setType(); // ??
//void getType(); // ??
void setName(std::string n);
virtual std::string getName();
void setMaterial(Material m);
virtual Material* getMaterial();
void setPos(Vector3D pos);
virtual Vector3D getPos();
virtual result intersectionTest(Ray r) = 0;
private:
//type
std::string name;
Material material;
Vector3D position;
};
// The subclass for a sphere
class Sphere : public Primitive
{
public:
void setRadius(float r);
float getRadius();
float getRadiusSqr();
result intersectionTest(Ray r);
private:
float radius;
};
And here I try to use it:
Code:
// Create a container for all the objects in the scene
primitiveList = new Primitive*[100];
// Add some object to the scene
// ----------------------------------------
// A small blue sphere at the scene of the screen
primitiveList[0] = new Sphere;
primitiveList[0]->setName("SmallBlueSphere");
primitiveList[0]->setPos(Vector3D(0,-50,0));
primitiveList[0]->setRadius(20);
primitiveList[0]->setMaterial(Material(0,0,255,0)); // Blue with 0 diffuse
primitiveList[1] = new Sphere;
primitiveList[1]->setName("BigRedSphere");
primitiveList[1]->setPos(Vector3D(0,50,0));
primitiveList[1]->setRadius(50);
primitiveList[1]->setMaterial(Material(255,0,0,0));
// -----------------------------------------
// Done with the scene
The error I get is:
'class Primitive' has no member named 'setRadius'
Not sure why this happens. I can acces all the functions in the Primitive class, but not in the SPhere class. This would have made sense to me if I had done new Primitive insted of new Sphere.
So, again I need a helping hand...
Thanks for you time