removed static const Material::white (had a problem with C++ since the order that the static const constructors were being called in was not correct according to the order that the code depended on them), made Shape constructor use a common default material instead of recreating one every time
git-svn-id: svn://anubis/fart/trunk@174 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
6a649ecac7
commit
84f6b04cd7
@ -15,18 +15,17 @@ void Scene::load(const char * filename)
|
|||||||
refptr<Node> node = parse(filename);
|
refptr<Node> node = parse(filename);
|
||||||
processNode(node);
|
processNode(node);
|
||||||
|
|
||||||
Transform transform;
|
#if 0
|
||||||
transform.translate(0, 2, 0);
|
|
||||||
|
|
||||||
refptr<Material> m = new Material();
|
refptr<Material> m = new Material();
|
||||||
refptr<Shape> shape = new Sphere(0.5);
|
refptr<Shape> shape = new Sphere(0.5);
|
||||||
shape->setTransform(transform);
|
shape->setTransform(m_transforms.top());
|
||||||
shape->setMaterial(m);
|
shape->setMaterial(m);
|
||||||
m_shapes.push_back(shape);
|
m_shapes.push_back(shape);
|
||||||
|
|
||||||
refptr<Light> light = new PointLight();
|
refptr<Light> light = new PointLight();
|
||||||
light->setPosition(Vector(2, -1, 2));
|
light->setPosition(Vector(2, -1, 2));
|
||||||
m_lights.push_back(light);
|
m_lights.push_back(light);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
Transform transform;
|
Transform transform;
|
||||||
|
@ -5,10 +5,18 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
static refptr<Material> default_material;
|
||||||
|
static bool default_material_initialized = false;
|
||||||
|
|
||||||
Shape::Shape()
|
Shape::Shape()
|
||||||
{
|
{
|
||||||
m_transparency = 0.0;
|
m_transparency = 0.0;
|
||||||
m_material = new Material(Material::white);
|
if (default_material_initialized == false)
|
||||||
|
{
|
||||||
|
default_material = new Material();
|
||||||
|
default_material_initialized = true;
|
||||||
|
}
|
||||||
|
m_material = default_material;
|
||||||
}
|
}
|
||||||
|
|
||||||
Shape::~Shape()
|
Shape::~Shape()
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
|
|
||||||
#include "Material.h"
|
#include "Material.h"
|
||||||
|
|
||||||
const Material Material::white = Material();
|
|
||||||
|
|
||||||
Material::Material()
|
Material::Material()
|
||||||
{
|
{
|
||||||
m_ambient_color = Color::white;
|
m_ambient_color = Color::white;
|
||||||
|
@ -7,9 +7,6 @@
|
|||||||
class Material
|
class Material
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/* static members */
|
|
||||||
static const Material white;
|
|
||||||
|
|
||||||
Material();
|
Material();
|
||||||
|
|
||||||
void setAmbientColor(const Color & ambient)
|
void setAmbientColor(const Color & ambient)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user