⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 particlesystem.java

📁 java 3d game jme 工程开发源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    /**
     * Remove an influence from the particle controller for this mesh.
     * 
     * @param influence
     *            ParticleInfluence
     * @return true if found and removed.
     */
    public boolean removeInfluence(ParticleInfluence influence) {
        return controller.removeInfluence(influence);
    }

    /**
     * Returns the list of influences acting on this particle controller.
     * 
     * @return ArrayList
     */
    public ArrayList<ParticleInfluence> getInfluences() {
        return controller.getInfluences();
    }

    public void clearInfluences() {
        controller.clearInfluences();
    }

    public void setParticleMass(float mass) {
        startMass = endMass = mass;
    }

    /**
     * Set the minimum angle (in radians) that particles can be emitted away
     * from the emission direction. Any angle less than 0 is trimmed to 0.
     * 
     * @param f
     *            The new emission minimum angle.
     */
    public void setMinimumAngle(float f) {
        minimumAngle = f >= 0.0f ? f : 0.0f;
    }

    /**
     * getEmissionMinimumAngle returns the minimum emission angle.
     * 
     * @return The minimum emission angle.
     */
    public float getMinimumAngle() {
        return minimumAngle;
    }

    /**
     * Set the maximum angle (in radians) that particles can be emitted away
     * from the emission direction. Any angle less than 0 is trimmed to 0.
     * 
     * @param f
     *            The new emission maximum angle.
     */
    public void setMaximumAngle(float f) {
        maximumAngle = f >= 0.0f ? f : 0.0f;
    }

    /**
     * getEmissionMaximumAngle returns the maximum emission angle.
     * 
     * @return The maximum emission angle.
     */
    public float getMaximumAngle() {
        return maximumAngle;
    }

    /**
     * Set the minimum lifespan of new particles (or recreated) managed by this
     * manager. if a value less than zero is given, 1.0f is used.
     * 
     * @param lifeSpan
     *            in ms
     */
    public void setMinimumLifeTime(float lifeSpan) {
        minimumLifeTime = lifeSpan >= 0.0f ? lifeSpan : 1.0f;
    }

    /**
     * getParticlesMinimumLifeTime returns the minimum life time of a particle.
     * 
     * @return The current minimum life time in ms.
     */
    public float getMinimumLifeTime() {
        return minimumLifeTime;
    }

    /**
     * Set the maximum lifespan of new particles (or recreated) managed by this
     * manager. if a value less than zero is given, 1.0f is used.
     * 
     * @param lifeSpan
     *            in ms
     */
    public void setMaximumLifeTime(float lifeSpan) {
        maximumLifeTime = lifeSpan >= 0.0f ? lifeSpan : 1.0f;
    }

    /**
     * getParticlesMaximumLifeTime returns the maximum life time of a particle.
     * 
     * @return The current maximum life time in ms.
     */
    public float getMaximumLifeTime() {
        return maximumLifeTime;
    }

    public Matrix3f getRotMatrix() {
        return rotMatrix;
    }

    public void setRotMatrix(Matrix3f rotMatrix) {
        this.rotMatrix = rotMatrix;
    }

    public TransformMatrix getEmitterTransform() {
        return emitterTransform;
    }

    public void setEmitterTransform(TransformMatrix emitterTransform) {
        this.emitterTransform = emitterTransform;
    }

    public float getParticleOrientation() {
        return particleOrientation;
    }

    public void setParticleOrientation(float orient) {
        this.particleOrientation = orient;
    }

    /**
     * Set the acceleration for any new particles created (or recreated) by this
     * manager.
     * 
     * @param velocity
     *            particle v0
     */
    public void setInitialVelocity(float velocity) {
        this.initialVelocity = velocity;
    }

    /**
     * Get the acceleration set in this manager.
     * 
     * @return The initialVelocity
     */
    public float getInitialVelocity() {
        return initialVelocity;
    }

    /**
     * Set the offset for any new particles created (or recreated) by this
     * manager. This is applicable only to managers generating from a point (not
     * a line, rectangle, etc..)
     * 
     * @param offset
     *            new offset position
     */
    public void setOriginOffset(Vector3f offset) {
        originOffset.set(offset);
    }

    /**
     * Get the offset point set in this manager.
     * 
     * @return origin
     */
    public Vector3f getOriginOffset() {
        return originOffset;
    }

    public Vector3f getWorldEmit() {
        return worldEmit;
    }

    public void setWorldEmit(Vector3f worldEmit) {
        this.worldEmit = worldEmit;
    }

    /**
     * Get the number of particles the manager should release per second.
     * 
     * @return The number of particles that should be released per second.
     */
    public int getReleaseRate() {
        return releaseRate;
    }

    /**
     * Set the number of particles the manager should release per second.
     * 
     * @param particlesPerSecond
     *            number of particles per second
     */
    public void setReleaseRate(int particlesPerSecond) {
        int oldRate = releaseRate;
        this.releaseRate = particlesPerSecond;
        if (controller != null && !controller.isActive()
                && controller.isControlFlow() && oldRate == 0) {
            controller.setActive(true);
        }
    }

    public float getEndMass() {
        return endMass;
    }

    public void setEndMass(float endMass) {
        this.endMass = endMass;
    }

    public float getEndSpin() {
        return endSpin;
    }

    public void setEndSpin(float endSpin) {
        this.endSpin = endSpin;
    }

    public float getStartMass() {
        return startMass;
    }

    public void setStartMass(float startMass) {
        this.startMass = startMass;
    }

    public float getStartSpin() {
        return startSpin;
    }

    public void setStartSpin(float startSpin) {
        this.startSpin = startSpin;
    }

    public int getTexQuantity() {
        return texQuantity;
    }

    public void setTexQuantity(int quantity) {
        this.texQuantity = quantity;
    }

    public int getStartTexIndex() {
        return startTexIndex;
    }

    public void setStartTexIndex(int startTexIndex) {
        this.startTexIndex = startTexIndex;
    }

    /**
     * Get which emittype method is being used by the underlying system. One of
     * EmitType.Point, EmitType.Line, EmitType.Rectangle, EmitType.Ring,
     * EmitType.GeomMesh
     * 
     * @return An int representing the current geometry method being used.
     */
    public EmitType getEmitType() {
        return emitType;
    }

    /**
     * Set which emittype method is being used by the underlying system. This is
     * already done by setGeometry(Line) and setGeometry(Rectangle) You should
     * not need to use this method unless you are switching between geometry
     * already set by those methods.
     * 
     * @param type
     *            emit type to use
     */
    public void setEmitType(EmitType type) {
        emitType = type;
    }

    /**
     * Get which emittype method is being used by the underlying system. One of
     * ParticleType.Quad, ParticleType.Triangle, ParticleType.Point,
     * ParticleType.Line, ParticleType.GeomMesh
     * 
     * @return An int representing the type of particle we are emitting.
     */
    public ParticleType getParticleType() {
        return particleType;
    }

    /**
     * Set what type of particle to emit from this sytem. Does not have an
     * effect unless recreate is called.
     * 
     * @param type
     *            particle type to use, should be one of ParticleType.Quad,
     *            ParticleType.Triangle, ParticleType.Point, ParticleType.Line,
     *            ParticleType.GeomMesh
     */
    public void setParticleType(ParticleType type) {
        particleType = type;
    }

    /**
     * Set a line segment to be used as the "emittor".
     * 
     * @param line
     *            New emittor line segment.
     */
    public void setGeometry(Line line) {
        psLine = line;
        emitType = EmitType.Line;
    }

    /**
     * Set a rectangular patch to be used as the "emittor".
     * 
     * @param rect
     *            New rectangular patch.
     */
    public void setGeometry(Rectangle rect) {
        psRect = rect;
        emitType = EmitType.Rectangle;
    }

    /**
     * Set a ring or disk to be used as the "emittor".
     * 
     * @param ring
     *            The new ring area.
     */
    public void setGeometry(Ring ring) {
        psRing = ring;
        emitType = EmitType.Ring;
    }

    /**
     * Set a Geometry's verts to be the random emission points
     * 
     * @param geom
     *            The new geometry random verts.
     */
    public void setGeometry(Geometry geom) {
        psGeom = geom;
        emitType = EmitType.Geometry;
    }

    /**
     * getLine returns the currently set line segment.
     * 
     * @return current line segment.
     */
    public Line getLine() {
        return psLine;
    }

    /**
     * getRectangle returns the currently set rectangle segment.
     * 
     * @return current rectangle segment.
     */
    public Rectangle getRectangle() {
        return psRect;
    }

    /**
     * getRing returns the currently set ring emission area.
     * 
     * @return current ring.
     */
    public Ring getRing() {
        return psRing;
    }

    /**
     * getGeometry returns the currently set Geometry emitter.
     * 
     * @return current Geometry emitter.
     */
    public Geometry getGeometry() {
        return psGeom;
    }

    public void initAllParticlesLocation() {
        for (int i = particles.length; --i >= 0;) {
            initParticleLocation(i);
            particles[i].updateVerts(null);
        }
    }

    public void initParticleLocation(int index) {
        Particle p = particles[index];
        if (particleType == ParticleType.GeomMesh) {
            // Update the triangle model on each new particle creation.
            Vector3f[] vertices = new Vector3f[3];
            ((TriMesh) psGeom).getTriangle(index, vertices);
            Triangle t = p.getTriangleModel();
            if (t == null)
                t = new Triangle(vertices[0], vertices[1], vertices[2]);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -