Form Wang Rui, "An initial GLSL shader support of rendering particles. Only the POINT
type is supported at present. The attached osgparticleshader.cpp will show how it works. It can also be placed in the examples folder. But I just wonder how this example co-exists with another two (osgparticle and osgparticleeffect)? Member variables in Particle, including _alive, _current_size and _current_alpha, are now merged into one Vec3 variable. Then we can make use of the set...Pointer() methods to treat them as vertex attribtues in GLSL. User interfaces are not changed. Additional methods of ParticleSystem are introduced, including setDefaultAttributesUsingShaders(), setSortMode() and setVisibilityDistance(). You can see how they work in osgparticleshader.cpp. Additional user-defined particle type is introduced. Set the particle type to USER and attach a drawable to the template. Be careful because of possible huge memory consumption. It is highly suggested to use display lists here. The ParticleSystemUpdater can accepts ParticleSystem objects as child drawables now. I myself think it is a little simpler in structure, than creating a new geode for each particle system. Of course, the latter is still compatible, and can be used to transform entire particles in the world. New particle operators: bounce, sink, damping, orbit and explosion. The bounce and sink opeartors both use a concept of domains, and can simulate a very basic collision of particles and objects. New composite placer. It contains a set of placers and emit particles from them randomly. The added virtual method size() of each placer will help determine the probability of generating. New virtual method operateParticles() for the Operator class. It actually calls operate() for each particle, but can be overrode to use speedup techniques like SSE, or even shaders in the future. Partly fix a floating error of 'delta time' in emitter, program and updaters. Previously they keep the _t0 variable seperately and compute different copies of dt by themseleves, which makes some operators, especially the BounceOperator, work incorrectly (because the dt in operators and updaters are slightly different). Now a getDeltaTime() method is maintained in ParticleSystem, and will return the unique dt value (passing by reference) for use. This makes thing better, but still very few unexpected behavours at present... All dotosg and serialzier wrappers for functionalities above are provided. ... According to some simple tests, the new shader support is slightly efficient than ordinary glBegin()/end(). That means, I haven't got a big improvement at present. I think the bottlenack here seems to be the cull traversal time. Because operators go through the particle list again and again (for example, the fountain in the shader example requires 4 operators working all the time). A really ideal solution here is to implement the particle operators in shaders, too, and copy the results back to particle attributes. The concept of GPGPU is good for implementing this. But in my opinion, the Camera class seems to be too heavy for realizing such functionality in a particle system. Myabe a light-weight ComputeDrawable class is enough for receiving data as textures and outputting the results to the FBO render buffer. What do you think then? The floating error of emitters (http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2009-May/028435.html) is not solved this time. But what I think is worth testing is that we could directly compute the node path from the emitter to the particle system rather than multiplying the worldToLocal and LocalToWorld matrices. I'll try this idea later. "
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
|
||||
#include <osgParticle/AngularDampingOperator>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
#include <osg/Vec3>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
bool AngularDampingOperator_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool AngularDampingOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
REGISTER_DOTOSGWRAPPER(AngularDampingOperator_Proxy)
|
||||
(
|
||||
new osgParticle::AngularDampingOperator,
|
||||
"AngularDampingOperator",
|
||||
"Object Operator AngularDampingOperator",
|
||||
AngularDampingOperator_readLocalData,
|
||||
AngularDampingOperator_writeLocalData
|
||||
);
|
||||
|
||||
bool AngularDampingOperator_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgParticle::AngularDampingOperator &adp = static_cast<osgParticle::AngularDampingOperator &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
osg::Vec3 a;
|
||||
if (fr[0].matchWord("damping")) {
|
||||
if (fr[1].getFloat(a.x()) && fr[2].getFloat(a.y()) && fr[3].getFloat(a.z())) {
|
||||
adp.setDamping(a);
|
||||
fr += 4;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
float low = 0.0f, high = FLT_MAX;
|
||||
if (fr[0].matchWord("cutoff")) {
|
||||
if (fr[1].getFloat(low) && fr[2].getFloat(high)) {
|
||||
adp.setCutoff(low, high);
|
||||
fr += 3;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
bool AngularDampingOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const osgParticle::AngularDampingOperator &adp = static_cast<const osgParticle::AngularDampingOperator &>(obj);
|
||||
osg::Vec3 a = adp.getDamping();
|
||||
fw.indent() << "damping " << a.x() << " " << a.y() << " " << a.z() << std::endl;
|
||||
|
||||
float low = adp.getCutoffLow(), high = adp.getCutoffHigh();
|
||||
fw.indent() << "cutoff " << low << " " << high << std::endl;
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
|
||||
#include <osgParticle/BounceOperator>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
#include <osg/Vec3>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
bool BounceOperator_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool BounceOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
REGISTER_DOTOSGWRAPPER(BounceOperator_Proxy)
|
||||
(
|
||||
new osgParticle::BounceOperator,
|
||||
"BounceOperator",
|
||||
"Object Operator DomainOperator BounceOperator",
|
||||
BounceOperator_readLocalData,
|
||||
BounceOperator_writeLocalData
|
||||
);
|
||||
|
||||
bool BounceOperator_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgParticle::BounceOperator &bp = static_cast<osgParticle::BounceOperator &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
float value = 0.0f;
|
||||
if (fr[0].matchWord("friction")) {
|
||||
if (fr[1].getFloat(value)) {
|
||||
bp.setFriction(value);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("resilience")) {
|
||||
if (fr[1].getFloat(value)) {
|
||||
bp.setResilience(value);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("cutoff")) {
|
||||
if (fr[1].getFloat(value)) {
|
||||
bp.setCutoff(value);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
bool BounceOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const osgParticle::BounceOperator &bp = static_cast<const osgParticle::BounceOperator &>(obj);
|
||||
fw.indent() << "friction " << bp.getFriction() << std::endl;
|
||||
fw.indent() << "resilience " << bp.getResilience() << std::endl;
|
||||
fw.indent() << "cutoff " << bp.getCutoff() << std::endl;
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
|
||||
#include <osgParticle/DampingOperator>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
#include <osg/Vec3>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
bool DampingOperator_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool DampingOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
REGISTER_DOTOSGWRAPPER(DampingOperator_Proxy)
|
||||
(
|
||||
new osgParticle::DampingOperator,
|
||||
"DampingOperator",
|
||||
"Object Operator DampingOperator",
|
||||
DampingOperator_readLocalData,
|
||||
DampingOperator_writeLocalData
|
||||
);
|
||||
|
||||
bool DampingOperator_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgParticle::DampingOperator &dp = static_cast<osgParticle::DampingOperator &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
osg::Vec3 a;
|
||||
if (fr[0].matchWord("damping")) {
|
||||
if (fr[1].getFloat(a.x()) && fr[2].getFloat(a.y()) && fr[3].getFloat(a.z())) {
|
||||
dp.setDamping(a);
|
||||
fr += 4;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
float low = 0.0f, high = FLT_MAX;
|
||||
if (fr[0].matchWord("cutoff")) {
|
||||
if (fr[1].getFloat(low) && fr[2].getFloat(high)) {
|
||||
dp.setCutoff(low, high);
|
||||
fr += 3;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
bool DampingOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const osgParticle::DampingOperator &dp = static_cast<const osgParticle::DampingOperator &>(obj);
|
||||
osg::Vec3 a = dp.getDamping();
|
||||
fw.indent() << "damping " << a.x() << " " << a.y() << " " << a.z() << std::endl;
|
||||
|
||||
float low = dp.getCutoffLow(), high = dp.getCutoffHigh();
|
||||
fw.indent() << "cutoff " << low << " " << high << std::endl;
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
|
||||
#include <osgParticle/DomainOperator>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
#include <osg/Vec3>
|
||||
#include <osg/io_utils>
|
||||
#include <iostream>
|
||||
|
||||
bool DomainOperator_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool DomainOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
REGISTER_DOTOSGWRAPPER(DomainOperator_Proxy)
|
||||
(
|
||||
new osgParticle::DomainOperator,
|
||||
"DomainOperator",
|
||||
"Object Operator DomainOperator",
|
||||
DomainOperator_readLocalData,
|
||||
DomainOperator_writeLocalData
|
||||
);
|
||||
|
||||
bool DomainOperator_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgParticle::DomainOperator &dp = static_cast<osgParticle::DomainOperator &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
std::string typeName;
|
||||
while (fr.matchSequence("domain %s {"))
|
||||
{
|
||||
if (fr[1].getStr()) typeName = fr[1].getStr();
|
||||
fr += 3;
|
||||
|
||||
osgParticle::DomainOperator::Domain::Type type = osgParticle::DomainOperator::Domain::UNDEFINED_DOMAIN;
|
||||
if (typeName == "point") type = osgParticle::DomainOperator::Domain::POINT_DOMAIN;
|
||||
else if (typeName == "line") type = osgParticle::DomainOperator::Domain::LINE_DOMAIN;
|
||||
else if (typeName == "triangle") type = osgParticle::DomainOperator::Domain::TRI_DOMAIN;
|
||||
else if (typeName == "rectangle") type = osgParticle::DomainOperator::Domain::RECT_DOMAIN;
|
||||
else if (typeName == "plane") type = osgParticle::DomainOperator::Domain::PLANE_DOMAIN;
|
||||
else if (typeName == "sphere") type = osgParticle::DomainOperator::Domain::SPHERE_DOMAIN;
|
||||
else if (typeName == "box") type = osgParticle::DomainOperator::Domain::BOX_DOMAIN;
|
||||
else if (typeName == "disk") type = osgParticle::DomainOperator::Domain::DISK_DOMAIN;
|
||||
|
||||
osgParticle::DomainOperator::Domain domain(type);
|
||||
if (fr[0].matchWord("plane")) {
|
||||
if (fr[1].getFloat(domain.plane[0]) && fr[2].getFloat(domain.plane[1]) &&
|
||||
fr[3].getFloat(domain.plane[2]) && fr[4].getFloat(domain.plane[3]))
|
||||
{
|
||||
fr += 5;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("vertices1")) {
|
||||
if (fr[1].getFloat(domain.v1[0]) && fr[2].getFloat(domain.v1[1]) && fr[3].getFloat(domain.v1[2]))
|
||||
{
|
||||
fr += 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("vertices2")) {
|
||||
if (fr[1].getFloat(domain.v2[0]) && fr[2].getFloat(domain.v2[1]) && fr[3].getFloat(domain.v2[2]))
|
||||
{
|
||||
fr += 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("vertices3")) {
|
||||
if (fr[1].getFloat(domain.v3[0]) && fr[2].getFloat(domain.v3[1]) && fr[3].getFloat(domain.v3[2]))
|
||||
{
|
||||
fr += 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("basis1")) {
|
||||
if (fr[1].getFloat(domain.s1[0]) && fr[2].getFloat(domain.s1[1]) && fr[3].getFloat(domain.s1[2]))
|
||||
{
|
||||
fr += 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("basis2")) {
|
||||
if (fr[1].getFloat(domain.s2[0]) && fr[2].getFloat(domain.s2[1]) && fr[3].getFloat(domain.s2[2]))
|
||||
{
|
||||
fr += 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("factors")) {
|
||||
if (fr[1].getFloat(domain.r1) && fr[2].getFloat(domain.r2))
|
||||
{
|
||||
fr += 3;
|
||||
}
|
||||
}
|
||||
dp.addDomain(domain);
|
||||
|
||||
++fr;
|
||||
itAdvanced = true;
|
||||
}
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
bool DomainOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const osgParticle::DomainOperator &dp = static_cast<const osgParticle::DomainOperator &>(obj);
|
||||
|
||||
for(unsigned int i=0;i<dp.getNumDomains();++i)
|
||||
{
|
||||
const osgParticle::DomainOperator::Domain& domain = dp.getDomain(i);
|
||||
|
||||
switch (domain.type)
|
||||
{
|
||||
case osgParticle::DomainOperator::Domain::POINT_DOMAIN:
|
||||
fw.indent() << "domain point {" << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::LINE_DOMAIN:
|
||||
fw.indent() << "domain line {" << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::TRI_DOMAIN:
|
||||
fw.indent() << "domain triangle {" << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::RECT_DOMAIN:
|
||||
fw.indent() << "domain rectangle {" << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::PLANE_DOMAIN:
|
||||
fw.indent() << "domain plane {" << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::SPHERE_DOMAIN:
|
||||
fw.indent() << "domain sphere {" << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::BOX_DOMAIN:
|
||||
fw.indent() << "domain box {" << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::DISK_DOMAIN:
|
||||
fw.indent() << "domain disk {" << std::endl; break;
|
||||
default:
|
||||
fw.indent() << "domain undefined {" << std::endl; break;
|
||||
}
|
||||
|
||||
fw.moveIn();
|
||||
fw.indent() << "plane " << domain.plane << std::endl;
|
||||
fw.indent() << "vertices1 " << domain.v1 << std::endl;
|
||||
fw.indent() << "vertices2 " << domain.v2 << std::endl;
|
||||
fw.indent() << "vertices3 " << domain.v3 << std::endl;
|
||||
fw.indent() << "basis1 " << domain.s1 << std::endl;
|
||||
fw.indent() << "basis2 " << domain.s2 << std::endl;
|
||||
fw.indent() << "factors " << domain.r1 << " " << domain.r2 << std::endl;
|
||||
|
||||
fw.moveOut();
|
||||
fw.indent() << "}" << std::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
|
||||
#include <osgParticle/ExplosionOperator>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
#include <osg/Vec3>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
bool ExplosionOperator_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool ExplosionOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
REGISTER_DOTOSGWRAPPER(ExplosionOperator_Proxy)
|
||||
(
|
||||
new osgParticle::ExplosionOperator,
|
||||
"ExplosionOperator",
|
||||
"Object Operator ExplosionOperator",
|
||||
ExplosionOperator_readLocalData,
|
||||
ExplosionOperator_writeLocalData
|
||||
);
|
||||
|
||||
bool ExplosionOperator_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgParticle::ExplosionOperator &ep = static_cast<osgParticle::ExplosionOperator &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
osg::Vec3 a;
|
||||
if (fr[0].matchWord("center")) {
|
||||
if (fr[1].getFloat(a.x()) && fr[2].getFloat(a.y()) && fr[3].getFloat(a.z())) {
|
||||
ep.setCenter(a);
|
||||
fr += 4;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
float value = 0.0f;
|
||||
if (fr[0].matchWord("radius")) {
|
||||
if (fr[1].getFloat(value)) {
|
||||
ep.setRadius(value);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("magnitude")) {
|
||||
if (fr[1].getFloat(value)) {
|
||||
ep.setMagnitude(value);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("epsilon")) {
|
||||
if (fr[1].getFloat(value)) {
|
||||
ep.setEpsilon(value);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("sigma")) {
|
||||
if (fr[1].getFloat(value)) {
|
||||
ep.setSigma(value);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
bool ExplosionOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const osgParticle::ExplosionOperator &ep = static_cast<const osgParticle::ExplosionOperator &>(obj);
|
||||
osg::Vec3 a = ep.getCenter();
|
||||
fw.indent() << "center " << a.x() << " " << a.y() << " " << a.z() << std::endl;
|
||||
|
||||
fw.indent() << "radius " << ep.getRadius() << std::endl;
|
||||
fw.indent() << "magnitude " << ep.getMagnitude() << std::endl;
|
||||
fw.indent() << "epsilon " << ep.getEpsilon() << std::endl;
|
||||
fw.indent() << "sigma " << ep.getSigma() << std::endl;
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
|
||||
#include <osgParticle/OrbitOperator>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
#include <osg/Vec3>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
bool OrbitOperator_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool OrbitOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
REGISTER_DOTOSGWRAPPER(OrbitOperator_Proxy)
|
||||
(
|
||||
new osgParticle::OrbitOperator,
|
||||
"OrbitOperator",
|
||||
"Object Operator OrbitOperator",
|
||||
OrbitOperator_readLocalData,
|
||||
OrbitOperator_writeLocalData
|
||||
);
|
||||
|
||||
bool OrbitOperator_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgParticle::OrbitOperator &op = static_cast<osgParticle::OrbitOperator &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
osg::Vec3 a;
|
||||
if (fr[0].matchWord("center")) {
|
||||
if (fr[1].getFloat(a.x()) && fr[2].getFloat(a.y()) && fr[3].getFloat(a.z())) {
|
||||
op.setCenter(a);
|
||||
fr += 4;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
float value = 0.0f;
|
||||
if (fr[0].matchWord("magnitude")) {
|
||||
if (fr[1].getFloat(value)) {
|
||||
op.setMagnitude(value);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("epsilon")) {
|
||||
if (fr[1].getFloat(value)) {
|
||||
op.setEpsilon(value);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("maxRadius")) {
|
||||
if (fr[1].getFloat(value)) {
|
||||
op.setMaxRadius(value);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
bool OrbitOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const osgParticle::OrbitOperator &op = static_cast<const osgParticle::OrbitOperator &>(obj);
|
||||
osg::Vec3 a = op.getCenter();
|
||||
fw.indent() << "center " << a.x() << " " << a.y() << " " << a.z() << std::endl;
|
||||
|
||||
fw.indent() << "magnitude " << op.getMagnitude() << std::endl;
|
||||
fw.indent() << "epsilon " << op.getEpsilon() << std::endl;
|
||||
fw.indent() << "maxRadius " << op.getMaxRadius() << std::endl;
|
||||
return true;
|
||||
}
|
||||
@@ -34,6 +34,8 @@ bool read_particle(osgDB::Input &fr, osgParticle::Particle &P)
|
||||
P.setShape(osgParticle::Particle::QUAD_TRIANGLESTRIP);
|
||||
} else if (std::string(ptstr) == "LINE") {
|
||||
P.setShape(osgParticle::Particle::LINE);
|
||||
} else if (std::string(ptstr) == "USER") {
|
||||
P.setShape(osgParticle::Particle::USER);
|
||||
} else {
|
||||
osg::notify(osg::WARN) << "Particle reader warning: invalid shape: " << ptstr << std::endl;
|
||||
}
|
||||
@@ -163,6 +165,15 @@ bool read_particle(osgDB::Input &fr, osgParticle::Particle &P)
|
||||
}
|
||||
++fr;
|
||||
}
|
||||
if (fr[0].matchWord("drawable") && fr[1].matchString("{")) {
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
osg::Drawable *drawable = dynamic_cast<osg::Drawable *>(fr.readObject());
|
||||
if (drawable) {
|
||||
P.setDrawable(drawable);
|
||||
}
|
||||
++fr;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -181,8 +192,9 @@ void write_particle(const osgParticle::Particle &P, osgDB::Output &fw)
|
||||
case osgParticle::Particle::HEXAGON: fw << "HEXAGON" << std::endl; break;
|
||||
case osgParticle::Particle::QUAD_TRIANGLESTRIP: fw << "QUAD_TRIANGLESTRIP" << std::endl; break;
|
||||
case osgParticle::Particle::QUAD: fw << "QUAD" << std::endl; break;
|
||||
case osgParticle::Particle::LINE:
|
||||
default: fw << "LINE" << std::endl; break;
|
||||
case osgParticle::Particle::LINE: fw << "LINE" << std::endl; break;
|
||||
case osgParticle::Particle::USER:
|
||||
default: fw << "USER" << std::endl; break;
|
||||
}
|
||||
|
||||
fw.indent() << "lifeTime " << P.getLifeTime() << std::endl;
|
||||
@@ -237,6 +249,12 @@ void write_particle(const osgParticle::Particle &P, osgDB::Output &fw)
|
||||
fw.writeObject(*P.getColorInterpolator());
|
||||
fw.moveOut();
|
||||
fw.indent() << "}" << std::endl;
|
||||
|
||||
fw.indent() << "drawable {" << std::endl;
|
||||
fw.moveIn();
|
||||
fw.writeObject(*P.getDrawable());
|
||||
fw.moveOut();
|
||||
fw.indent() << "}" << std::endl;
|
||||
|
||||
fw.moveOut();
|
||||
fw.indent() << "}" << std::endl;
|
||||
|
||||
@@ -74,6 +74,30 @@ bool ParticleSystem_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("useVertexArray")) {
|
||||
if (fr[1].matchWord("TRUE")) {
|
||||
myobj.setUseVertexArray(true);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
} else if (fr[1].matchWord("FALSE")) {
|
||||
myobj.setUseVertexArray(false);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("useShaders")) {
|
||||
if (fr[1].matchWord("TRUE")) {
|
||||
myobj.setUseShaders(true);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
} else if (fr[1].matchWord("FALSE")) {
|
||||
myobj.setUseShaders(false);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("doublePassRendering")) {
|
||||
if (fr[1].matchWord("TRUE")) {
|
||||
myobj.setDoublePassRendering(true);
|
||||
@@ -124,6 +148,33 @@ bool ParticleSystem_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("sortMode")) {
|
||||
if (fr[1].matchWord("NO_SORT")) {
|
||||
myobj.setSortMode(osgParticle::ParticleSystem::NO_SORT);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
if (fr[1].matchWord("SORT_FRONT_TO_BACK")) {
|
||||
myobj.setSortMode(osgParticle::ParticleSystem::SORT_FRONT_TO_BACK);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
if (fr[1].matchWord("SORT_BACK_TO_FRONT")) {
|
||||
myobj.setSortMode(osgParticle::ParticleSystem::SORT_BACK_TO_FRONT);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("visibilityDistance")) {
|
||||
double distance;
|
||||
if (fr[1].getFloat(distance)) {
|
||||
myobj.setVisibilityDistance(distance);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("particleTemplate")) {
|
||||
++fr;
|
||||
itAdvanced = true;
|
||||
@@ -167,6 +218,18 @@ bool ParticleSystem_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
v = myobj.getAlignVectorY();
|
||||
fw.indent() << "alignVectorY " << v.x() << " " << v.y() << " " << v.z() << std::endl;
|
||||
|
||||
fw.indent() << "useVertexArray ";
|
||||
if (myobj.getUseVertexArray())
|
||||
fw << "TRUE" << std::endl;
|
||||
else
|
||||
fw << "FALSE" << std::endl;
|
||||
|
||||
fw.indent() << "useShaders ";
|
||||
if (myobj.getUseShaders())
|
||||
fw << "TRUE" << std::endl;
|
||||
else
|
||||
fw << "FALSE" << std::endl;
|
||||
|
||||
fw.indent() << "doublePassRendering ";
|
||||
if (myobj.getDoublePassRendering())
|
||||
fw << "TRUE" << std::endl;
|
||||
@@ -190,8 +253,23 @@ bool ParticleSystem_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
fw << bbox.xMin() << " " << bbox.yMin() << " " << bbox.zMin() << " ";
|
||||
fw << bbox.xMax() << " " << bbox.yMax() << " " << bbox.zMax() << std::endl;
|
||||
|
||||
fw.indent() << "sortMode ";
|
||||
switch (myobj.getSortMode()) {
|
||||
default:
|
||||
case osgParticle::ParticleSystem::NO_SORT:
|
||||
fw << "NO_SORT" << std::endl;
|
||||
break;
|
||||
case osgParticle::ParticleSystem::SORT_FRONT_TO_BACK:
|
||||
fw << "SORT_FRONT_TO_BACK" << std::endl;
|
||||
break;
|
||||
case osgParticle::ParticleSystem::SORT_BACK_TO_FRONT:
|
||||
fw << "SORT_BACK_TO_FRONT" << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
fw.indent() << "visibilityDistance " << myobj.getVisibilityDistance() << std::endl;
|
||||
|
||||
fw.indent() << "particleTemplate ";
|
||||
write_particle(myobj.getDefaultParticleTemplate(), fw);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ REGISTER_DOTOSGWRAPPER(PSU_Proxy)
|
||||
(
|
||||
new osgParticle::ParticleSystemUpdater,
|
||||
"ParticleSystemUpdater",
|
||||
"Object Node ParticleSystemUpdater",
|
||||
"Object Node Geode ParticleSystemUpdater",
|
||||
PSU_readLocalData,
|
||||
PSU_writeLocalData
|
||||
);
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
|
||||
#include <osgParticle/SinkOperator>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
#include <osg/Vec3>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
bool SinkOperator_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool SinkOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
REGISTER_DOTOSGWRAPPER(SinkOperator_Proxy)
|
||||
(
|
||||
new osgParticle::SinkOperator,
|
||||
"SinkOperator",
|
||||
"Object Operator DomainOperator SinkOperator",
|
||||
SinkOperator_readLocalData,
|
||||
SinkOperator_writeLocalData
|
||||
);
|
||||
|
||||
bool SinkOperator_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgParticle::SinkOperator &sp = static_cast<osgParticle::SinkOperator &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
if (fr[0].matchWord("sinkTarget")) {
|
||||
const char *ptstr = fr[1].getStr();
|
||||
if (ptstr) {
|
||||
std::string str(ptstr);
|
||||
if (str == "position")
|
||||
sp.setSinkTarget(osgParticle::SinkOperator::SINK_POSITION);
|
||||
else if (str == "velocity")
|
||||
sp.setSinkTarget(osgParticle::SinkOperator::SINK_VELOCITY);
|
||||
else if (str == "angular_velocity")
|
||||
sp.setSinkTarget(osgParticle::SinkOperator::SINK_ANGULAR_VELOCITY);
|
||||
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("sinkStrategy")) {
|
||||
const char *ptstr = fr[1].getStr();
|
||||
if (ptstr) {
|
||||
std::string str(ptstr);
|
||||
if (str == "inside")
|
||||
sp.setSinkStrategy(osgParticle::SinkOperator::SINK_INSIDE);
|
||||
else if (str == "outside")
|
||||
sp.setSinkStrategy(osgParticle::SinkOperator::SINK_OUTSIDE);
|
||||
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
bool SinkOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const osgParticle::SinkOperator &sp = static_cast<const osgParticle::SinkOperator &>(obj);
|
||||
|
||||
fw.indent() << "sinkTarget ";
|
||||
switch (sp.getSinkTarget())
|
||||
{
|
||||
case osgParticle::SinkOperator::SINK_POSITION:
|
||||
fw << "position" << std::endl; break;
|
||||
case osgParticle::SinkOperator::SINK_VELOCITY:
|
||||
fw << "velocity" << std::endl; break;
|
||||
case osgParticle::SinkOperator::SINK_ANGULAR_VELOCITY:
|
||||
fw << "angular_velocity" << std::endl; break;
|
||||
default:
|
||||
fw << "undefined" << std::endl; break;
|
||||
}
|
||||
|
||||
fw.indent() << "sinkStrategy ";
|
||||
switch (sp.getSinkStrategy())
|
||||
{
|
||||
case osgParticle::SinkOperator::SINK_INSIDE:
|
||||
fw << "inside" << std::endl; break;
|
||||
case osgParticle::SinkOperator::SINK_OUTSIDE:
|
||||
fw << "outside" << std::endl; break;
|
||||
default:
|
||||
fw << "undefined" << std::endl; break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <osgParticle/AngularDampingOperator>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgParticleAngularDampingOperator,
|
||||
new osgParticle::AngularDampingOperator,
|
||||
osgParticle::AngularDampingOperator,
|
||||
"osg::Object osgParticle::Operator osgParticle::AngularDampingOperator" )
|
||||
{
|
||||
ADD_VEC3_SERIALIZER( Damping, osg::Vec3() ); // _damping
|
||||
ADD_FLOAT_SERIALIZER( CutoffLow, 0.0f ); // _cutoffLow
|
||||
ADD_FLOAT_SERIALIZER( CutoffHigh, FLT_MAX ); // _cutoffHigh
|
||||
}
|
||||
14
src/osgWrappers/serializers/osgParticle/BounceOperator.cpp
Normal file
14
src/osgWrappers/serializers/osgParticle/BounceOperator.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <osgParticle/BounceOperator>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgParticleBounceOperator,
|
||||
new osgParticle::BounceOperator,
|
||||
osgParticle::BounceOperator,
|
||||
"osg::Object osgParticle::Operator osgParticle::DomainOperator osgParticle::BounceOperator" )
|
||||
{
|
||||
ADD_FLOAT_SERIALIZER( Friction, 1.0f ); // _friction
|
||||
ADD_FLOAT_SERIALIZER( Resilience, 0.0f ); // _resilience
|
||||
ADD_FLOAT_SERIALIZER( Cutoff, 0.0f ); // _cutoff
|
||||
}
|
||||
14
src/osgWrappers/serializers/osgParticle/DampingOperator.cpp
Normal file
14
src/osgWrappers/serializers/osgParticle/DampingOperator.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <osgParticle/DampingOperator>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgParticleDampingOperator,
|
||||
new osgParticle::DampingOperator,
|
||||
osgParticle::DampingOperator,
|
||||
"osg::Object osgParticle::Operator osgParticle::DampingOperator" )
|
||||
{
|
||||
ADD_VEC3_SERIALIZER( Damping, osg::Vec3() ); // _damping
|
||||
ADD_FLOAT_SERIALIZER( CutoffLow, 0.0f ); // _cutoffLow
|
||||
ADD_FLOAT_SERIALIZER( CutoffHigh, FLT_MAX ); // _cutoffHigh
|
||||
}
|
||||
94
src/osgWrappers/serializers/osgParticle/DomainOperator.cpp
Normal file
94
src/osgWrappers/serializers/osgParticle/DomainOperator.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
#include <osgParticle/DomainOperator>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
static bool checkDomains( const osgParticle::DomainOperator& dp )
|
||||
{
|
||||
return dp.getNumDomains()>0;
|
||||
}
|
||||
|
||||
static bool readDomains( osgDB::InputStream& is, osgParticle::DomainOperator& dp )
|
||||
{
|
||||
osgParticle::DomainOperator::Domain::Type type = osgParticle::DomainOperator::Domain::UNDEFINED_DOMAIN;
|
||||
unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
|
||||
for ( unsigned int i=0; i<size; ++i )
|
||||
{
|
||||
std::string typeName;
|
||||
is >> osgDB::PROPERTY("Domain") >> typeName >> osgDB::BEGIN_BRACKET;
|
||||
if (typeName=="POINT") type = osgParticle::DomainOperator::Domain::POINT_DOMAIN;
|
||||
else if (typeName=="LINE") type = osgParticle::DomainOperator::Domain::LINE_DOMAIN;
|
||||
else if (typeName=="TRIANGLE") type = osgParticle::DomainOperator::Domain::TRI_DOMAIN;
|
||||
else if (typeName=="RECTANGLE") type = osgParticle::DomainOperator::Domain::RECT_DOMAIN;
|
||||
else if (typeName=="PLANE") type = osgParticle::DomainOperator::Domain::PLANE_DOMAIN;
|
||||
else if (typeName=="SPHERE") type = osgParticle::DomainOperator::Domain::SPHERE_DOMAIN;
|
||||
else if (typeName=="BOX") type = osgParticle::DomainOperator::Domain::BOX_DOMAIN;
|
||||
else if (typeName=="DISK") type = osgParticle::DomainOperator::Domain::DISK_DOMAIN;
|
||||
|
||||
osgParticle::DomainOperator::Domain domain(type);
|
||||
is >> osgDB::PROPERTY("Plane") >> domain.plane;
|
||||
is >> osgDB::PROPERTY("Vertices1") >> domain.v1;
|
||||
is >> osgDB::PROPERTY("Vertices2") >> domain.v2;
|
||||
is >> osgDB::PROPERTY("Vertices3") >> domain.v3;
|
||||
is >> osgDB::PROPERTY("Basis1") >> domain.s1;
|
||||
is >> osgDB::PROPERTY("Basis2") >> domain.s2;
|
||||
is >> osgDB::PROPERTY("Factors") >> domain.r1 >> domain.r2;
|
||||
dp.addDomain(domain);
|
||||
|
||||
is >> osgDB::END_BRACKET;
|
||||
}
|
||||
is >> osgDB::END_BRACKET;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool writeDomains( osgDB::OutputStream& os, const osgParticle::DomainOperator& dp )
|
||||
{
|
||||
unsigned int size = dp.getNumDomains();
|
||||
os << size << osgDB::BEGIN_BRACKET << std::endl;
|
||||
for ( unsigned int i=0; i<size; ++i )
|
||||
{
|
||||
const osgParticle::DomainOperator::Domain& domain = dp.getDomain(i);
|
||||
|
||||
os << osgDB::PROPERTY("Domain");
|
||||
switch (domain.type)
|
||||
{
|
||||
case osgParticle::DomainOperator::Domain::POINT_DOMAIN:
|
||||
os << std::string("POINT") << osgDB::BEGIN_BRACKET << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::LINE_DOMAIN:
|
||||
os << std::string("LINE") << osgDB::BEGIN_BRACKET << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::TRI_DOMAIN:
|
||||
os << std::string("TRIANGLE") << osgDB::BEGIN_BRACKET << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::RECT_DOMAIN:
|
||||
os << std::string("RECTANGLE") << osgDB::BEGIN_BRACKET << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::PLANE_DOMAIN:
|
||||
os << std::string("PLANE") << osgDB::BEGIN_BRACKET << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::SPHERE_DOMAIN:
|
||||
os << std::string("SPHERE") << osgDB::BEGIN_BRACKET << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::BOX_DOMAIN:
|
||||
os << std::string("BOX") << osgDB::BEGIN_BRACKET << std::endl; break;
|
||||
case osgParticle::DomainOperator::Domain::DISK_DOMAIN:
|
||||
os << std::string("DISK") << osgDB::BEGIN_BRACKET << std::endl; break;
|
||||
default:
|
||||
os << std::string("UNDEFINED") << osgDB::BEGIN_BRACKET << std::endl; break;
|
||||
}
|
||||
|
||||
os << osgDB::PROPERTY("Plane") << domain.plane << std::endl;
|
||||
os << osgDB::PROPERTY("Vertices1") << domain.v1 << std::endl;
|
||||
os << osgDB::PROPERTY("Vertices2") << domain.v2 << std::endl;
|
||||
os << osgDB::PROPERTY("Vertices3") << domain.v3 << std::endl;
|
||||
os << osgDB::PROPERTY("Basis1") << domain.s1 << std::endl;
|
||||
os << osgDB::PROPERTY("Basis2") << domain.s2 << std::endl;
|
||||
os << osgDB::PROPERTY("Factors") << domain.r1 << domain.r2 << std::endl;
|
||||
os << osgDB::END_BRACKET << std::endl;
|
||||
}
|
||||
os << osgDB::END_BRACKET << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgParticleDomainOperator,
|
||||
new osgParticle::DomainOperator,
|
||||
osgParticle::DomainOperator,
|
||||
"osg::Object osgParticle::Operator osgParticle::DomainOperator" )
|
||||
{
|
||||
ADD_USER_SERIALIZER( Domains ); // _placers
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <osgParticle/ExplosionOperator>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgParticleExplosionOperator,
|
||||
new osgParticle::ExplosionOperator,
|
||||
osgParticle::ExplosionOperator,
|
||||
"osg::Object osgParticle::Operator osgParticle::ExplosionOperator" )
|
||||
{
|
||||
ADD_VEC3_SERIALIZER( Center, osg::Vec3() ); // _center
|
||||
ADD_FLOAT_SERIALIZER( Radius, 1.0f ); // _radius
|
||||
ADD_FLOAT_SERIALIZER( Magnitude, 1.0f ); // _magnitude
|
||||
ADD_FLOAT_SERIALIZER( Epsilon, 1e-3 ); // _epsilon
|
||||
ADD_FLOAT_SERIALIZER( Sigma, 1.0f ); // _sigma
|
||||
}
|
||||
15
src/osgWrappers/serializers/osgParticle/OrbitOperator.cpp
Normal file
15
src/osgWrappers/serializers/osgParticle/OrbitOperator.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <osgParticle/OrbitOperator>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgParticleOrbitOperator,
|
||||
new osgParticle::OrbitOperator,
|
||||
osgParticle::OrbitOperator,
|
||||
"osg::Object osgParticle::Operator osgParticle::OrbitOperator" )
|
||||
{
|
||||
ADD_VEC3_SERIALIZER( Center, osg::Vec3() ); // _center
|
||||
ADD_FLOAT_SERIALIZER( Magnitude, 1.0f ); // _magnitude
|
||||
ADD_FLOAT_SERIALIZER( Epsilon, 1e-3 ); // _epsilon
|
||||
ADD_FLOAT_SERIALIZER( MaxRadius, FLT_MAX ); // _maxRadius
|
||||
}
|
||||
@@ -9,6 +9,7 @@ BEGIN_USER_TABLE( Shape, osgParticle::Particle );
|
||||
ADD_USER_VALUE( QUAD_TRIANGLESTRIP );
|
||||
ADD_USER_VALUE( HEXAGON );
|
||||
ADD_USER_VALUE( LINE );
|
||||
ADD_USER_VALUE( USER );
|
||||
END_USER_TABLE()
|
||||
|
||||
USER_READ_FUNC( Shape, readShapeValue )
|
||||
@@ -68,6 +69,14 @@ bool readParticle( osgDB::InputStream& is, osgParticle::Particle& p )
|
||||
p.setAngularVelocity( angleV );
|
||||
p.setTextureTile( s, t, num );
|
||||
|
||||
bool hasObject = false; is >> osgDB::PROPERTY("Drawable") >> hasObject;
|
||||
if ( hasObject )
|
||||
{
|
||||
is >> osgDB::BEGIN_BRACKET;
|
||||
p.setDrawable( dynamic_cast<osg::Drawable*>(is.readObject()) );
|
||||
is >> osgDB::END_BRACKET;
|
||||
}
|
||||
|
||||
is >> osgDB::END_BRACKET;
|
||||
return true;
|
||||
}
|
||||
@@ -102,6 +111,15 @@ bool writeParticle( osgDB::OutputStream& os, const osgParticle::Particle& p )
|
||||
os << osgDB::PROPERTY("AngularVelocity") << osg::Vec3d(p.getAngularVelocity()) << std::endl;
|
||||
os << osgDB::PROPERTY("TextureTile") << p.getTileS() << p.getTileT() << p.getNumTiles() << std::endl;
|
||||
|
||||
os << osgDB::PROPERTY("Drawable") << (p.getDrawable()!=NULL);
|
||||
if ( p.getDrawable()!=NULL )
|
||||
{
|
||||
os << osgDB::BEGIN_BRACKET << std::endl;
|
||||
os.writeObject( p.getDrawable() );
|
||||
os << osgDB::END_BRACKET;
|
||||
}
|
||||
os << std::endl;
|
||||
|
||||
os << osgDB::END_BRACKET << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -75,8 +75,18 @@ REGISTER_OBJECT_WRAPPER( osgParticleParticleSystem,
|
||||
ADD_ENUM_VALUE( WORLD_COORDINATES );
|
||||
END_ENUM_SERIALIZER(); // _particleScaleReferenceFrame
|
||||
|
||||
ADD_BOOL_SERIALIZER( UseVertexArray, false ); // _useVertexArray
|
||||
ADD_BOOL_SERIALIZER( UseShaders, false ); // _useShaders
|
||||
ADD_BOOL_SERIALIZER( DoublePassRendering, false ); // _doublepass
|
||||
ADD_BOOL_SERIALIZER( Frozen, false ); // _frozen
|
||||
ADD_USER_SERIALIZER( DefaultParticleTemplate ); // _def_ptemp
|
||||
ADD_BOOL_SERIALIZER( FreezeOnCull, false ); // _freeze_on_cull
|
||||
|
||||
BEGIN_ENUM_SERIALIZER( SortMode, NO_SORT );
|
||||
ADD_ENUM_VALUE( NO_SORT );
|
||||
ADD_ENUM_VALUE( SORT_FRONT_TO_BACK );
|
||||
ADD_ENUM_VALUE( SORT_BACK_TO_FRONT );
|
||||
END_ENUM_SERIALIZER(); // _sortMode
|
||||
|
||||
ADD_DOUBLE_SERIALIZER( VisibilityDistance, -1.0 ); // _visibilityDistance
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ static bool writeParticleSystems( osgDB::OutputStream& os, const osgParticle::Pa
|
||||
REGISTER_OBJECT_WRAPPER( osgParticleParticleSystemUpdater,
|
||||
new osgParticle::ParticleSystemUpdater,
|
||||
osgParticle::ParticleSystemUpdater,
|
||||
"osg::Object osg::Node osgParticle::ParticleSystemUpdater" )
|
||||
"osg::Object osg::Node osg::Geode osgParticle::ParticleSystemUpdater" )
|
||||
{
|
||||
ADD_USER_SERIALIZER( ParticleSystems ); // _psv
|
||||
}
|
||||
|
||||
21
src/osgWrappers/serializers/osgParticle/SinkOperator.cpp
Normal file
21
src/osgWrappers/serializers/osgParticle/SinkOperator.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <osgParticle/SinkOperator>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgParticleSinkOperator,
|
||||
new osgParticle::SinkOperator,
|
||||
osgParticle::SinkOperator,
|
||||
"osg::Object osgParticle::Operator osgParticle::DomainOperator osgParticle::SinkOperator" )
|
||||
{
|
||||
BEGIN_ENUM_SERIALIZER( SinkTarget, SINK_POSITION );
|
||||
ADD_ENUM_VALUE( SINK_POSITION );
|
||||
ADD_ENUM_VALUE( SINK_VELOCITY );
|
||||
ADD_ENUM_VALUE( SINK_ANGULAR_VELOCITY );
|
||||
END_ENUM_SERIALIZER(); // _sinkTarget
|
||||
|
||||
BEGIN_ENUM_SERIALIZER( SinkStrategy, SINK_INSIDE );
|
||||
ADD_ENUM_VALUE( SINK_INSIDE );
|
||||
ADD_ENUM_VALUE( SINK_OUTSIDE );
|
||||
END_ENUM_SERIALIZER(); // _sinkStrategy
|
||||
}
|
||||
Reference in New Issue
Block a user