www.pudn.com > simpleraytracer_v1_0.zip > object.cpp
/*===================================================================
digital liberation front 2002
_______ ______ _______
/______/\ |______| /\______\
| \ \ | | / / |
| \| | | |/ |
|_____ \ | |_ / ______|
____| | | |_|| |_____
|____| |________||____|
Code by Nicholas Chapman[/ Ono-Sendai]
nickamy@paradise.net.nz
You may use this code for any non-commercial project,
as long as you do not remove this description.
You may not use this code for any commercial project.
====================================================================*/
#include "object.h"
#include "geometry.h"
#include "../maths/vec3.h"
#include "world.h"
Object::Object(const Material&amt; material_, Geometry* geometry_)
: material(material_),
geometry(geometry_)
{
}
Object::~Object()
{
delete geometry;
}
//get the colour of the ray that is known to hit this object
void Object::getColourForRay(const Vec3&amt; intersect_pos, const Vec3&amt; unit_raydir,
World&amt; world, Colour&amt; colour_out) const
{
colour_out.set(0.0f,0.0f,0.0f);
//------------------------------------------------------------------------
//get normal at hit position
//------------------------------------------------------------------------
const Vec3 normal = geometry->getNormalForPos(intersect_pos);
//------------------------------------------------------------------------
//add lighting at this point
//------------------------------------------------------------------------
// world.calcLightingForSurfPoint(*this,
world.calcLightingForSurfPoint(*this, unit_raydir, intersect_pos, normal, colour_out);
}