2011-03-31 06:44:20 +08:00
|
|
|
/*
|
|
|
|
This file is part of Mitsuba, a physically based rendering system.
|
|
|
|
|
2012-09-28 00:43:51 +08:00
|
|
|
Copyright (c) 2007-2012 by Wenzel Jakob and others.
|
2011-03-31 06:44:20 +08:00
|
|
|
|
|
|
|
Mitsuba is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License Version 3
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
Mitsuba is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-04-14 21:15:59 +08:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-03-31 06:44:20 +08:00
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "shapegroup.h"
|
|
|
|
|
|
|
|
MTS_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Geometry instancing support (to be used in conjunction
|
|
|
|
* with the \c shapegroup plugin)
|
|
|
|
*/
|
|
|
|
class Instance : public Shape {
|
|
|
|
public:
|
|
|
|
/// Create a new instance based on properties from an XML file
|
|
|
|
Instance(const Properties &props);
|
|
|
|
|
|
|
|
/// Unserialize from a binary data stream
|
|
|
|
Instance(Stream *stream, InstanceManager *manager);
|
|
|
|
|
|
|
|
/// Serialize to a binary data stream
|
|
|
|
void serialize(Stream *stream, InstanceManager *manager) const;
|
|
|
|
|
2012-09-28 00:43:51 +08:00
|
|
|
/** \brief Configure this object (called \a once after construction
|
|
|
|
and addition of all child \ref ConfigurableObject instances).) */
|
2011-03-31 06:44:20 +08:00
|
|
|
void configure();
|
|
|
|
|
|
|
|
/// Return the object-to-world transformation used by this instance
|
|
|
|
inline Transform getWorldTransform() const { return m_objectToWorld; }
|
|
|
|
|
|
|
|
/// Add a child ConfigurableObject
|
|
|
|
void addChild(const std::string &name, ConfigurableObject *child);
|
2012-10-21 02:04:13 +08:00
|
|
|
|
2011-03-31 06:44:20 +08:00
|
|
|
/// Return a pointer to the associated \ref ShapeGroup
|
|
|
|
inline ShapeGroup* getShapeGroup() { return m_shapeGroup; }
|
|
|
|
|
|
|
|
/// Return a pointer to the associated \ref ShapeGroup (const version)
|
|
|
|
inline const ShapeGroup* getShapeGroup() const { return m_shapeGroup.get(); }
|
2012-10-21 02:04:13 +08:00
|
|
|
|
2011-03-31 06:44:20 +08:00
|
|
|
// =============================================================
|
|
|
|
//! @{ \name Implementation of the Shape interface
|
|
|
|
// =============================================================
|
|
|
|
|
|
|
|
AABB getAABB() const;
|
|
|
|
|
|
|
|
Float getSurfaceArea() const;
|
|
|
|
|
2012-10-21 02:04:13 +08:00
|
|
|
bool rayIntersect(const Ray &_ray, Float mint,
|
2011-03-31 06:44:20 +08:00
|
|
|
Float maxt, Float &t, void *temp) const;
|
|
|
|
|
|
|
|
bool rayIntersect(const Ray &_ray, Float mint, Float maxt) const;
|
|
|
|
|
2012-10-21 02:04:13 +08:00
|
|
|
void fillIntersectionRecord(const Ray &ray,
|
2011-03-31 06:44:20 +08:00
|
|
|
const void *temp, Intersection &its) const;
|
2012-10-21 02:04:13 +08:00
|
|
|
|
2012-09-28 00:43:51 +08:00
|
|
|
void getNormalDerivative(const Intersection &its,
|
|
|
|
Vector &dndu, Vector &dndv, bool shadingFrame) const;
|
|
|
|
|
|
|
|
size_t getPrimitiveCount() const;
|
|
|
|
|
|
|
|
size_t getEffectivePrimitiveCount() const;
|
|
|
|
|
2011-03-31 06:44:20 +08:00
|
|
|
//! @}
|
|
|
|
// =============================================================
|
|
|
|
|
|
|
|
MTS_DECLARE_CLASS()
|
|
|
|
private:
|
|
|
|
ref<ShapeGroup> m_shapeGroup;
|
|
|
|
Transform m_objectToWorld, m_worldToObject;
|
2012-09-28 00:43:51 +08:00
|
|
|
Float m_invScale;
|
2011-03-31 06:44:20 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
MTS_NAMESPACE_END
|