Search in sources :

Example 6 with LevelEditorEntityParticleSystem

use of net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem in project tdme by andreasdr.

the class ParticleSystemScreenController method setParticleSystemEmitter.

/**
	 * Set particle system emitter
	 */
public void setParticleSystemEmitter() {
    particleSystemEmitter.getActiveConditions().removeAll();
    LevelEditorEntityParticleSystem particleSystem = view.getEntity().getParticleSystem();
    switch(particleSystem.getEmitter()) {
        case NONE:
            {
                particleSystemEmitters.getController().setValue(value.set(EMITTER_NONE));
                particleSystemEmitter.getActiveConditions().add(EMITTER_NONE);
                break;
            }
        case POINT_PARTICLE_EMITTER:
            {
                particleSystemEmitters.getController().setValue(value.set(EMITTER_POINTPARTICLEEMITTER));
                particleSystemEmitter.getActiveConditions().add(EMITTER_POINTPARTICLEEMITTER);
                PointParticleEmitter emitter = particleSystem.getPointParticleEmitter();
                ppeCount.getController().setValue(value.set(emitter.getCount()));
                ppeLifeTime.getController().setValue(value.set((int) emitter.getLifeTime()));
                ppeLifeTimeRnd.getController().setValue(value.set((int) emitter.getLifeTimeRnd()));
                ppeMass.getController().setValue(value.set(emitter.getMass(), 4));
                ppeMassRnd.getController().setValue(value.set(emitter.getMassRnd(), 4));
                ppePosition.getController().setValue(value.set(Tools.formatVector3(emitter.getPosition())));
                ppeVelocity.getController().setValue(value.set(Tools.formatVector3(emitter.getVelocity())));
                ppeVelocityRnd.getController().setValue(value.set(Tools.formatVector3(emitter.getVelocityRnd())));
                ppeColorStart.getController().setValue(value.set(Tools.formatColor4(emitter.getColorStart())));
                ppeColorEnd.getController().setValue(value.set(Tools.formatColor4(emitter.getColorEnd())));
                break;
            }
        case BOUNDINGBOX_PARTICLE_EMITTER:
            {
                particleSystemEmitters.getController().setValue(value.set(EMITTER_BOUNDINGBOXPARTICLEEMITTER));
                particleSystemEmitter.getActiveConditions().add(EMITTER_BOUNDINGBOXPARTICLEEMITTER);
                BoundingBoxParticleEmitter emitter = particleSystem.getBoundingBoxParticleEmitters();
                bbpeCount.getController().setValue(value.set(emitter.getCount()));
                bbpeLifeTime.getController().setValue(value.set((int) emitter.getLifeTime()));
                bbpeLifeTimeRnd.getController().setValue(value.set((int) emitter.getLifeTimeRnd()));
                bbpeMass.getController().setValue(value.set(emitter.getMass(), 4));
                bbpeMassRnd.getController().setValue(value.set(emitter.getMassRnd(), 4));
                bbpeVelocity.getController().setValue(value.set(Tools.formatVector3(emitter.getVelocity())));
                bbpeVelocityRnd.getController().setValue(value.set(Tools.formatVector3(emitter.getVelocityRnd())));
                bbpeColorStart.getController().setValue(value.set(Tools.formatColor4(emitter.getColorStart())));
                bbpeColorEnd.getController().setValue(value.set(Tools.formatColor4(emitter.getColorEnd())));
                bbpeObbCenter.getController().setValue(value.set(Tools.formatVector3(emitter.getObbCenter())));
                bbpeObbHalfextension.getController().setValue(value.set(Tools.formatVector3(emitter.getObbHalfextension())));
                // set up rotation matrix to extract euler angles
                Vector3 rotation = new Vector3();
                Matrix4x4 rotationMatrix = new Matrix4x4().identity();
                rotationMatrix.setAxes(emitter.getObbAxis0(), emitter.getObbAxis1(), emitter.getObbAxis2());
                rotationMatrix.computeEulerAngles(rotation);
                // set up rotation
                bbpeObbRotationX.getController().setValue(value.set(Tools.formatFloat(rotation.getX())));
                bbpeObbRotationY.getController().setValue(value.set(Tools.formatFloat(rotation.getY())));
                bbpeObbRotationZ.getController().setValue(value.set(Tools.formatFloat(rotation.getZ())));
                break;
            }
        case CIRCLE_PARTICLE_EMITTER:
            {
                particleSystemEmitters.getController().setValue(value.set(EMITTER_CIRCLEPARTICLEEMITTER));
                particleSystemEmitter.getActiveConditions().add(EMITTER_CIRCLEPARTICLEEMITTER);
                CircleParticleEmitter emitter = particleSystem.getCircleParticleEmitter();
                cpeCount.getController().setValue(value.set(emitter.getCount()));
                cpeLifeTime.getController().setValue(value.set((int) emitter.getLifeTime()));
                cpeLifeTimeRnd.getController().setValue(value.set((int) emitter.getLifeTimeRnd()));
                cpeMass.getController().setValue(value.set(emitter.getMass(), 4));
                cpeMassRnd.getController().setValue(value.set(emitter.getMassRnd(), 4));
                cpeVelocity.getController().setValue(value.set(Tools.formatVector3(emitter.getVelocity())));
                cpeVelocityRnd.getController().setValue(value.set(Tools.formatVector3(emitter.getVelocityRnd())));
                cpeColorStart.getController().setValue(value.set(Tools.formatColor4(emitter.getColorStart())));
                cpeColorEnd.getController().setValue(value.set(Tools.formatColor4(emitter.getColorEnd())));
                cpeCenter.getController().setValue(value.set(Tools.formatVector3(emitter.getCenter())));
                cpeRadius.getController().setValue(value.set(emitter.getRadius(), 4));
                // set up rotation matrix to extract euler angles
                Vector3 rotation = new Vector3();
                Matrix4x4 rotationMatrix = new Matrix4x4().identity();
                rotationMatrix.setAxes(emitter.getAxis0(), Vector3.computeCrossProduct(emitter.getAxis0(), emitter.getAxis1()), emitter.getAxis1());
                rotationMatrix.computeEulerAngles(rotation);
                // set up rotation
                cpeRotationX.getController().setValue(value.set(Tools.formatFloat(rotation.getX())));
                cpeRotationY.getController().setValue(value.set(Tools.formatFloat(rotation.getY())));
                cpeRotationZ.getController().setValue(value.set(Tools.formatFloat(rotation.getZ())));
                break;
            }
        case CIRCLE_PARTICLE_EMITTER_PLANE_VELOCITY:
            {
                particleSystemEmitters.getController().setValue(value.set(EMITTER_CIRCLEPARTICLEEMITTERPLANEVELOCITY));
                particleSystemEmitter.getActiveConditions().add(EMITTER_CIRCLEPARTICLEEMITTERPLANEVELOCITY);
                CircleParticleEmitterPlaneVelocity emitter = particleSystem.getCircleParticleEmitterPlaneVelocity();
                cpepvCount.getController().setValue(value.set(emitter.getCount()));
                cpepvLifeTime.getController().setValue(value.set((int) emitter.getLifeTime()));
                cpepvLifeTimeRnd.getController().setValue(value.set((int) emitter.getLifeTimeRnd()));
                cpepvMass.getController().setValue(value.set(emitter.getMass(), 4));
                cpepvMassRnd.getController().setValue(value.set(emitter.getMassRnd(), 4));
                cpepvVelocity.getController().setValue(value.set(emitter.getVelocity(), 4));
                cpepvVelocityRnd.getController().setValue(value.set(emitter.getVelocityRnd(), 4));
                cpepvColorStart.getController().setValue(value.set(Tools.formatColor4(emitter.getColorStart())));
                cpepvColorEnd.getController().setValue(value.set(Tools.formatColor4(emitter.getColorEnd())));
                cpepvCenter.getController().setValue(value.set(Tools.formatVector3(emitter.getCenter())));
                cpepvRadius.getController().setValue(value.set(emitter.getRadius(), 4));
                // set up rotation matrix to extract euler angles
                Vector3 rotation = new Vector3();
                Matrix4x4 rotationMatrix = new Matrix4x4().identity();
                rotationMatrix.setAxes(emitter.getAxis0(), Vector3.computeCrossProduct(emitter.getAxis0(), emitter.getAxis1()), emitter.getAxis1());
                rotationMatrix.computeEulerAngles(rotation);
                // set up rotation
                cpepvRotationX.getController().setValue(value.set(Tools.formatFloat(rotation.getX())));
                cpepvRotationY.getController().setValue(value.set(Tools.formatFloat(rotation.getY())));
                cpepvRotationZ.getController().setValue(value.set(Tools.formatFloat(rotation.getZ())));
                break;
            }
        case SPHERE_PARTICLE_EMITTER:
            {
                particleSystemEmitters.getController().setValue(value.set(EMITTER_SPHEREPARTICLEEMITTER));
                particleSystemEmitter.getActiveConditions().add(EMITTER_SPHEREPARTICLEEMITTER);
                SphereParticleEmitter emitter = particleSystem.getSphereParticleEmitter();
                speCount.getController().setValue(value.set(emitter.getCount()));
                speLifeTime.getController().setValue(value.set((int) emitter.getLifeTime()));
                speLifeTimeRnd.getController().setValue(value.set((int) emitter.getLifeTimeRnd()));
                speMass.getController().setValue(value.set(emitter.getMass(), 4));
                speMassRnd.getController().setValue(value.set(emitter.getMassRnd(), 4));
                speVelocity.getController().setValue(value.set(Tools.formatVector3(emitter.getVelocity())));
                speVelocityRnd.getController().setValue(value.set(Tools.formatVector3(emitter.getVelocityRnd())));
                speColorStart.getController().setValue(value.set(Tools.formatColor4(emitter.getColorStart())));
                speColorEnd.getController().setValue(value.set(Tools.formatColor4(emitter.getColorEnd())));
                speCenter.getController().setValue(value.set(Tools.formatVector3(emitter.getCenter())));
                speRadius.getController().setValue(value.set(emitter.getRadius(), 4));
                break;
            }
        default:
            System.out.println("ParticleSystemScreenController::onParticleSystemEmitterApply(): unknown particle system emitter '" + particleSystem.getEmitter() + "'");
    }
    // re init entity in view
    view.initParticleSystem();
}
Also used : CircleParticleEmitterPlaneVelocity(net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.CircleParticleEmitterPlaneVelocity) CircleParticleEmitter(net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.CircleParticleEmitter) BoundingBoxParticleEmitter(net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.BoundingBoxParticleEmitter) Vector3(net.drewke.tdme.math.Vector3) LevelEditorEntityParticleSystem(net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem) Matrix4x4(net.drewke.tdme.math.Matrix4x4) SphereParticleEmitter(net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.SphereParticleEmitter) PointParticleEmitter(net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.PointParticleEmitter)

Aggregations

LevelEditorEntityParticleSystem (net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem)6 Vector3 (net.drewke.tdme.math.Vector3)3 BoundingBoxParticleEmitter (net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.BoundingBoxParticleEmitter)3 CircleParticleEmitter (net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.CircleParticleEmitter)3 CircleParticleEmitterPlaneVelocity (net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.CircleParticleEmitterPlaneVelocity)3 PointParticleEmitter (net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.PointParticleEmitter)3 SphereParticleEmitter (net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.SphereParticleEmitter)3 File (java.io.File)2 IOException (java.io.IOException)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 Model (net.drewke.tdme.engine.model.Model)1 BoundingBox (net.drewke.tdme.engine.primitives.BoundingBox)1 BoundingVolume (net.drewke.tdme.engine.primitives.BoundingVolume)1 Capsule (net.drewke.tdme.engine.primitives.Capsule)1 ConvexMesh (net.drewke.tdme.engine.primitives.ConvexMesh)1 OrientedBoundingBox (net.drewke.tdme.engine.primitives.OrientedBoundingBox)1 PrimitiveModel (net.drewke.tdme.engine.primitives.PrimitiveModel)1 Sphere (net.drewke.tdme.engine.primitives.Sphere)1 Triangle (net.drewke.tdme.engine.primitives.Triangle)1