vector < Shape* > shapes;
void createScene()
{
image = QImage(width, height, 32); // 32 Bit
Color amb(0.1,0.1,0.1);
Color difCoef(0.75,0.6,0.22);
Color spec(0.5,0.5,0.5);
double shine= 3.0;
Sphere *s = new Sphere(Point(0.0,0.0,-5), 100.0, amb, difCoef, spec, shine);
shapes.push_back(s);
}
int main(){
// initialize glut
init();
createScene();
Shape *x = shapes[0];
cout << x->shine << endl;
}
class Shape
{
public:
Shape() {}
~Shape(){}
Color ambient;
Color dif;
Color spec;
double shine;
virtual bool checkIntersect(Point p, Point d, Point &temp) = 0; // If intersects, return true else false.
virtual Point getNormal(Point intPt) = 0; // Get the normal at the point of intersection
//virtual void printstuff() = 0;
};
當它打印出光芒時,我得到一個零值?這是爲什麼?對象和指針的問題
我認爲你需要提供更多一點你的代碼.... – retracile 2009-12-08 19:37:45
你的形狀[]定義在哪裏? – 2009-12-08 19:38:30
什麼庫是'Shape'?這是你設計的課程還是來自圖書館? – 2009-12-08 19:38:39