added a convenience wrapper to permit direct animation of every type of shape without having to declare instances etc
parent
0c09791f47
commit
3881f295d8
|
@ -71,6 +71,10 @@ MTS_NAMESPACE_BEGIN
|
||||||
* Specifies the relative amount of samples
|
* Specifies the relative amount of samples
|
||||||
* allocated to this emitter. \default{1}
|
* allocated to this emitter. \default{1}
|
||||||
* }
|
* }
|
||||||
|
* \parameter{toWorld}{\Transform\Or\ATransform}{
|
||||||
|
* Specifies an optional sensor-to-world transformation.
|
||||||
|
* \default{none (i.e. sensor space $=$ world space)}
|
||||||
|
* }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* \renderings{
|
* \renderings{
|
||||||
|
@ -376,8 +380,7 @@ public:
|
||||||
bitmapData.ptr = (uint8_t *) bitmap.get();
|
bitmapData.ptr = (uint8_t *) bitmap.get();
|
||||||
bitmapData.size = sizeof(Bitmap);
|
bitmapData.size = sizeof(Bitmap);
|
||||||
props.setData("bitmap", bitmapData);
|
props.setData("bitmap", bitmapData);
|
||||||
const Transform &trafo = m_worldTransform->eval(0);
|
props.setAnimatedTransform("toWorld", m_worldTransform);
|
||||||
props.setTransform("toWorld", trafo);
|
|
||||||
props.setFloat("samplingWeight", m_samplingWeight);
|
props.setFloat("samplingWeight", m_samplingWeight);
|
||||||
Emitter *emitter = static_cast<Emitter *>(
|
Emitter *emitter = static_cast<Emitter *>(
|
||||||
PluginManager::getInstance()->createObject(
|
PluginManager::getInstance()->createObject(
|
||||||
|
|
|
@ -221,8 +221,7 @@ public:
|
||||||
bitmapData.ptr = (uint8_t *) bitmap.get();
|
bitmapData.ptr = (uint8_t *) bitmap.get();
|
||||||
bitmapData.size = sizeof(Bitmap);
|
bitmapData.size = sizeof(Bitmap);
|
||||||
props.setData("bitmap", bitmapData);
|
props.setData("bitmap", bitmapData);
|
||||||
const Transform &trafo = m_worldTransform->eval(0);
|
props.setAnimatedTransform("toWorld", m_worldTransform);
|
||||||
props.setTransform("toWorld", trafo);
|
|
||||||
props.setFloat("samplingWeight", m_samplingWeight);
|
props.setFloat("samplingWeight", m_samplingWeight);
|
||||||
Emitter *emitter = static_cast<Emitter *>(
|
Emitter *emitter = static_cast<Emitter *>(
|
||||||
PluginManager::getInstance()->createObject(
|
PluginManager::getInstance()->createObject(
|
||||||
|
|
|
@ -223,7 +223,7 @@ public:
|
||||||
bitmapData.ptr = (uint8_t *) bitmap.get();
|
bitmapData.ptr = (uint8_t *) bitmap.get();
|
||||||
bitmapData.size = sizeof(Bitmap);
|
bitmapData.size = sizeof(Bitmap);
|
||||||
envProps.setData("bitmap", bitmapData);
|
envProps.setData("bitmap", bitmapData);
|
||||||
envProps.setTransform("toWorld", trafo);
|
envProps.setAnimatedTransform("toWorld", m_worldTransform);
|
||||||
envProps.setFloat("samplingWeight", m_samplingWeight);
|
envProps.setFloat("samplingWeight", m_samplingWeight);
|
||||||
m_envEmitter = static_cast<Emitter *>(
|
m_envEmitter = static_cast<Emitter *>(
|
||||||
PluginManager::getInstance()->createObject(
|
PluginManager::getInstance()->createObject(
|
||||||
|
|
|
@ -198,9 +198,9 @@ Properties::~Properties() {
|
||||||
void Properties::operator=(const Properties &props) {
|
void Properties::operator=(const Properties &props) {
|
||||||
for (std::map<std::string, PropertyElement>::iterator it = m_elements->begin();
|
for (std::map<std::string, PropertyElement>::iterator it = m_elements->begin();
|
||||||
it != m_elements->end(); ++it) {
|
it != m_elements->end(); ++it) {
|
||||||
AnimatedTransform *trafo = boost::get<AnimatedTransform *>((*it).second.data);
|
AnimatedTransform **trafo = boost::get<AnimatedTransform *>(&(*it).second.data);
|
||||||
if (trafo)
|
if (trafo)
|
||||||
trafo->decRef();
|
(*trafo)->decRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pluginName = props.m_pluginName;
|
m_pluginName = props.m_pluginName;
|
||||||
|
@ -209,9 +209,9 @@ void Properties::operator=(const Properties &props) {
|
||||||
|
|
||||||
for (std::map<std::string, PropertyElement>::iterator it = m_elements->begin();
|
for (std::map<std::string, PropertyElement>::iterator it = m_elements->begin();
|
||||||
it != m_elements->end(); ++it) {
|
it != m_elements->end(); ++it) {
|
||||||
AnimatedTransform *trafo = boost::get<AnimatedTransform *>((*it).second.data);
|
AnimatedTransform **trafo = boost::get<AnimatedTransform *>(&(*it).second.data);
|
||||||
if (trafo)
|
if (trafo)
|
||||||
trafo->incRef();
|
(*trafo)->incRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,6 +223,9 @@ bool Properties::removeProperty(const std::string &name) {
|
||||||
std::map<std::string, PropertyElement>::iterator it = m_elements->find(name);
|
std::map<std::string, PropertyElement>::iterator it = m_elements->find(name);
|
||||||
if (it == m_elements->end())
|
if (it == m_elements->end())
|
||||||
return false;
|
return false;
|
||||||
|
AnimatedTransform **trafo = boost::get<AnimatedTransform *>(&(*it).second.data);
|
||||||
|
if (trafo)
|
||||||
|
(*trafo)->decRef();
|
||||||
m_elements->erase(it);
|
m_elements->erase(it);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,7 @@ void SceneHandler::endElement(const XMLCh* const xmlName) {
|
||||||
if (context.attributes.find("id") != context.attributes.end())
|
if (context.attributes.find("id") != context.attributes.end())
|
||||||
context.properties.setID(context.attributes["id"]);
|
context.properties.setID(context.attributes["id"]);
|
||||||
|
|
||||||
ref<ConfigurableObject> object = NULL;
|
ref<ConfigurableObject> object;
|
||||||
|
|
||||||
TagMap::const_iterator it = m_tags.find(name);
|
TagMap::const_iterator it = m_tags.find(name);
|
||||||
if (it == m_tags.end())
|
if (it == m_tags.end())
|
||||||
|
@ -686,11 +686,57 @@ void SceneHandler::endElement(const XMLCh* const xmlName) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default: {
|
||||||
if (tag.second == NULL)
|
if (tag.second == NULL)
|
||||||
XMLLog(EError, "Internal error: could not instantiate an object "
|
XMLLog(EError, "Internal error: could not instantiate an object "
|
||||||
"corresponding to the tag '%s'", name.c_str());
|
"corresponding to the tag '%s'", name.c_str());
|
||||||
object = m_pluginManager->createObject(tag.second, context.properties);
|
|
||||||
|
Properties &props = context.properties;
|
||||||
|
|
||||||
|
/* Convenience hack: allow passing animated transforms to arbitrary shapes
|
||||||
|
and then internally rewrite this into a shape group + animated instance */
|
||||||
|
if (tag.second == MTS_CLASS(Shape) && props.getPluginName() != "instance" &&
|
||||||
|
props.hasProperty("toWorld") && props.getType("toWorld") == Properties::EAnimatedTransform) {
|
||||||
|
|
||||||
|
ref<const AnimatedTransform> trafo = props.getAnimatedTransform("toWorld");
|
||||||
|
props.removeProperty("toWorld");
|
||||||
|
|
||||||
|
if (trafo->isStatic())
|
||||||
|
props.setTransform("toWorld", trafo->eval(0));
|
||||||
|
|
||||||
|
object = m_pluginManager->createObject(tag.second, props);
|
||||||
|
|
||||||
|
if (!trafo->isStatic()) {
|
||||||
|
object = m_pluginManager->createObject(tag.second, props);
|
||||||
|
/* If the object has children, append them */
|
||||||
|
for (std::vector<std::pair<std::string, ConfigurableObject *> >
|
||||||
|
::iterator it = context.children.begin();
|
||||||
|
it != context.children.end(); ++it) {
|
||||||
|
if (it->second != NULL) {
|
||||||
|
object->addChild(it->first, it->second);
|
||||||
|
it->second->setParent(object);
|
||||||
|
it->second->decRef();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context.children.clear();
|
||||||
|
|
||||||
|
object->configure();
|
||||||
|
|
||||||
|
ref<Shape> shapeGroup = static_cast<Shape *> (
|
||||||
|
m_pluginManager->createObject(MTS_CLASS(Shape), Properties("shapegroup")));
|
||||||
|
shapeGroup->addChild(object);
|
||||||
|
shapeGroup->configure();
|
||||||
|
|
||||||
|
Properties instanceProps("instance");
|
||||||
|
instanceProps.setAnimatedTransform("toWorld", trafo);
|
||||||
|
object = m_pluginManager->createObject(instanceProps);
|
||||||
|
object->addChild(shapeGroup);
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
object = m_pluginManager->createObject(tag.second, props);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ MTS_NAMESPACE_BEGIN
|
||||||
* Is the cylinder inverted, i.e. should the normal vectors
|
* Is the cylinder inverted, i.e. should the normal vectors
|
||||||
* be flipped? \default{\code{false}, i.e. the normals point outside}
|
* be flipped? \default{\code{false}, i.e. the normals point outside}
|
||||||
* }
|
* }
|
||||||
* \parameter{toWorld}{\Transform}{
|
* \parameter{toWorld}{\Transform\Or\ATransform}{
|
||||||
* Specifies an optional linear object-to-world transformation.
|
* Specifies an optional linear object-to-world transformation.
|
||||||
* Note that non-uniform scales are not permitted!
|
* Note that non-uniform scales are not permitted!
|
||||||
* \default{none (i.e. object space $=$ world space)}
|
* \default{none (i.e. object space $=$ world space)}
|
||||||
|
|
|
@ -31,7 +31,7 @@ MTS_NAMESPACE_BEGIN
|
||||||
/*!\plugin{disk}{Disk intersection primitive}
|
/*!\plugin{disk}{Disk intersection primitive}
|
||||||
* \order{4}
|
* \order{4}
|
||||||
* \parameters{
|
* \parameters{
|
||||||
* \parameter{toWorld}{\Transform}{
|
* \parameter{toWorld}{\Transform\Or\ATransform}{
|
||||||
* Specifies a linear object-to-world transformation.
|
* Specifies a linear object-to-world transformation.
|
||||||
* Note that non-uniform scales are not permitted!
|
* Note that non-uniform scales are not permitted!
|
||||||
* \default{none (i.e. object space $=$ world space)}
|
* \default{none (i.e. object space $=$ world space)}
|
||||||
|
|
|
@ -55,7 +55,7 @@ MTS_NAMESPACE_BEGIN
|
||||||
* this convention. \default{\code{true}, i.e. flip them to get the
|
* this convention. \default{\code{true}, i.e. flip them to get the
|
||||||
* correct coordinates}.
|
* correct coordinates}.
|
||||||
* }
|
* }
|
||||||
* \parameter{toWorld}{\Transform}{
|
* \parameter{toWorld}{\Transform\Or\ATransform}{
|
||||||
* Specifies an optional linear object-to-world transformation.
|
* Specifies an optional linear object-to-world transformation.
|
||||||
* Note that non-uniform scales are not permitted!
|
* Note that non-uniform scales are not permitted!
|
||||||
* \default{none (i.e. object space $=$ world space)}
|
* \default{none (i.e. object space $=$ world space)}
|
||||||
|
|
|
@ -62,7 +62,7 @@ MTS_NAMESPACE_BEGIN
|
||||||
* Optional flag to flip all normals. \default{\code{false}, i.e.
|
* Optional flag to flip all normals. \default{\code{false}, i.e.
|
||||||
* the normals are left unchanged}.
|
* the normals are left unchanged}.
|
||||||
* }
|
* }
|
||||||
* \parameter{toWorld}{\Transform}{
|
* \parameter{toWorld}{\Transform\Or\ATransform}{
|
||||||
* Specifies an optional linear object-to-world transformation.
|
* Specifies an optional linear object-to-world transformation.
|
||||||
* Note that non-uniform scales are not permitted!
|
* Note that non-uniform scales are not permitted!
|
||||||
* \default{none (i.e. object space $=$ world space)}
|
* \default{none (i.e. object space $=$ world space)}
|
||||||
|
|
|
@ -30,7 +30,7 @@ MTS_NAMESPACE_BEGIN
|
||||||
/*!\plugin{rectangle}{Rectangle intersection primitive}
|
/*!\plugin{rectangle}{Rectangle intersection primitive}
|
||||||
* \order{3}
|
* \order{3}
|
||||||
* \parameters{
|
* \parameters{
|
||||||
* \parameter{toWorld}{\Transform}{
|
* \parameter{toWorld}{\Transform\Or\ATransform}{
|
||||||
* Specifies a linear object-to-world transformation.
|
* Specifies a linear object-to-world transformation.
|
||||||
* It is allowed to use non-uniform scaling, but no shear.
|
* It is allowed to use non-uniform scaling, but no shear.
|
||||||
* \default{none (i.e. object space $=$ world space)}
|
* \default{none (i.e. object space $=$ world space)}
|
||||||
|
|
|
@ -48,7 +48,7 @@ MTS_NAMESPACE_BEGIN
|
||||||
* Optional flag to flip all normals. \default{\code{false}, i.e.
|
* Optional flag to flip all normals. \default{\code{false}, i.e.
|
||||||
* the normals are left unchanged}.
|
* the normals are left unchanged}.
|
||||||
* }
|
* }
|
||||||
* \parameter{toWorld}{\Transform}{
|
* \parameter{toWorld}{\Transform\Or\ATransform}{
|
||||||
* Specifies an optional linear object-to-world transformation.
|
* Specifies an optional linear object-to-world transformation.
|
||||||
* Note that non-uniform scales are not permitted!
|
* Note that non-uniform scales are not permitted!
|
||||||
* \default{none (i.e. object space $=$ world space)}
|
* \default{none (i.e. object space $=$ world space)}
|
||||||
|
|
|
@ -37,7 +37,7 @@ MTS_NAMESPACE_BEGIN
|
||||||
* \parameter{radius}{\Float}{
|
* \parameter{radius}{\Float}{
|
||||||
* Radius of the sphere in object-space units \default{1}
|
* Radius of the sphere in object-space units \default{1}
|
||||||
* }
|
* }
|
||||||
* \parameter{toWorld}{\Transform}{
|
* \parameter{toWorld}{\Transform\Or\ATransform}{
|
||||||
* Specifies an optional linear object-to-world transformation.
|
* Specifies an optional linear object-to-world transformation.
|
||||||
* Note that non-uniform scales are not permitted!
|
* Note that non-uniform scales are not permitted!
|
||||||
* \default{none (i.e. object space $=$ world space)}
|
* \default{none (i.e. object space $=$ world space)}
|
||||||
|
|
Loading…
Reference in New Issue