Search in sources :

Example 16 with ParticleController

use of com.badlogic.gdx.graphics.g3d.particles.ParticleController in project libgdx by libgdx.

the class DynamicsInfluencerPanel method createVelocity.

protected void createVelocity(Object selectedItem) {
    //Add the velocity to the table and to the influencer
    ParticleController controller = editor.getEmitter();
    DynamicsInfluencer influencer = (DynamicsInfluencer) controller.findInfluencer(DynamicsInfluencer.class);
    VelocityWrapper wrapper = new VelocityWrapper(createVelocityValue(selectedItem), true);
    velocities.add(wrapper);
    influencer.velocities.add(wrapper.velocityValue);
    int index = velocities.size - 1;
    velocityTableModel.addRow(new Object[] { "Velocity " + index, true });
    //Reinit
    editor.restart();
    //Select new velocity
    velocityTable.getSelectionModel().setSelectionInterval(index, index);
    revalidate();
    repaint();
}
Also used : DynamicsInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsInfluencer) ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController)

Example 17 with ParticleController

use of com.badlogic.gdx.graphics.g3d.particles.ParticleController in project libgdx by libgdx.

the class ParticleControllerFinalizerInfluencer method update.

@Override
public void update() {
    for (int i = 0, positionOffset = 0, c = controller.particles.size; i < c; ++i, positionOffset += positionChannel.strideSize) {
        ParticleController particleController = controllerChannel.data[i];
        float scale = hasScale ? scaleChannel.data[i] : 1;
        float qx = 0, qy = 0, qz = 0, qw = 1;
        if (hasRotation) {
            int rotationOffset = i * rotationChannel.strideSize;
            qx = rotationChannel.data[rotationOffset + ParticleChannels.XOffset];
            qy = rotationChannel.data[rotationOffset + ParticleChannels.YOffset];
            qz = rotationChannel.data[rotationOffset + ParticleChannels.ZOffset];
            qw = rotationChannel.data[rotationOffset + ParticleChannels.WOffset];
        }
        particleController.setTransform(positionChannel.data[positionOffset + ParticleChannels.XOffset], positionChannel.data[positionOffset + ParticleChannels.YOffset], positionChannel.data[positionOffset + ParticleChannels.ZOffset], qx, qy, qz, qw, scale);
        particleController.update();
    }
}
Also used : ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController)

Example 18 with ParticleController

use of com.badlogic.gdx.graphics.g3d.particles.ParticleController in project libgdx by libgdx.

the class ParticleControllerTest method addEmitter.

private void addEmitter(float[] colors, Texture particleTexture, Vector3 translation, Vector3 actionAxis, float actionRotation) {
    ParticleController controller = createBillboardController(colors, particleTexture);
    controller.init();
    controller.start();
    emitters.add(controller);
    controller.translate(translation);
    ui.addAction(new RotationAction(controller, actionAxis, actionRotation));
}
Also used : ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController)

Example 19 with ParticleController

use of com.badlogic.gdx.graphics.g3d.particles.ParticleController in project libgdx by libgdx.

the class ParticleControllerTest method createBillboardController.

private ParticleController createBillboardController(float[] colors, Texture particleTexture) {
    //Emission
    RegularEmitter emitter = new RegularEmitter();
    emitter.getDuration().setLow(3000);
    emitter.getEmission().setHigh(2900);
    emitter.getLife().setHigh(1000);
    emitter.setMaxParticleCount(3000);
    //Spawn
    PointSpawnShapeValue pointSpawnShapeValue = new PointSpawnShapeValue();
    pointSpawnShapeValue.xOffsetValue.setLow(0, 1f);
    pointSpawnShapeValue.xOffsetValue.setActive(true);
    pointSpawnShapeValue.yOffsetValue.setLow(0, 1f);
    pointSpawnShapeValue.yOffsetValue.setActive(true);
    pointSpawnShapeValue.zOffsetValue.setLow(0, 1f);
    pointSpawnShapeValue.zOffsetValue.setActive(true);
    SpawnInfluencer spawnSource = new SpawnInfluencer(pointSpawnShapeValue);
    //Scale
    ScaleInfluencer scaleInfluencer = new ScaleInfluencer();
    scaleInfluencer.value.setTimeline(new float[] { 0, 1 });
    scaleInfluencer.value.setScaling(new float[] { 1, 0 });
    scaleInfluencer.value.setLow(0);
    scaleInfluencer.value.setHigh(1);
    //Color
    ColorInfluencer.Single colorInfluencer = new ColorInfluencer.Single();
    colorInfluencer.colorValue.setColors(new float[] { colors[0], colors[1], colors[2], 0, 0, 0 });
    colorInfluencer.colorValue.setTimeline(new float[] { 0, 1 });
    colorInfluencer.alphaValue.setHigh(1);
    colorInfluencer.alphaValue.setTimeline(new float[] { 0, 0.5f, 0.8f, 1 });
    colorInfluencer.alphaValue.setScaling(new float[] { 0, 0.15f, 0.5f, 0 });
    //Dynamics
    DynamicsInfluencer dynamicsInfluencer = new DynamicsInfluencer();
    BrownianAcceleration modifier = new BrownianAcceleration();
    modifier.strengthValue.setTimeline(new float[] { 0, 1 });
    modifier.strengthValue.setScaling(new float[] { 0, 1 });
    modifier.strengthValue.setHigh(80);
    modifier.strengthValue.setLow(1, 5);
    dynamicsInfluencer.velocities.add(modifier);
    return new ParticleController("Billboard Controller", emitter, new BillboardRenderer(billboardParticleBatch), new RegionInfluencer.Single(particleTexture), spawnSource, scaleInfluencer, colorInfluencer, dynamicsInfluencer);
}
Also used : DynamicsInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsInfluencer) BillboardRenderer(com.badlogic.gdx.graphics.g3d.particles.renderers.BillboardRenderer) RegularEmitter(com.badlogic.gdx.graphics.g3d.particles.emitters.RegularEmitter) Single(com.badlogic.gdx.graphics.g3d.particles.influencers.ColorInfluencer.Single) BrownianAcceleration(com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsModifier.BrownianAcceleration) PointSpawnShapeValue(com.badlogic.gdx.graphics.g3d.particles.values.PointSpawnShapeValue) ScaleInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.ScaleInfluencer) Single(com.badlogic.gdx.graphics.g3d.particles.influencers.ColorInfluencer.Single) ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController) ColorInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.ColorInfluencer) RegionInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.RegionInfluencer) SpawnInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.SpawnInfluencer)

Example 20 with ParticleController

use of com.badlogic.gdx.graphics.g3d.particles.ParticleController in project libgdx by libgdx.

the class FlameMain method initializeComponents.

private void initializeComponents() {
    splitPane = new JSplitPane();
    splitPane.setUI(new BasicSplitPaneUI() {

        public void paint(Graphics g, JComponent jc) {
        }
    });
    splitPane.setDividerSize(4);
    getContentPane().add(splitPane, BorderLayout.CENTER);
    {
        JSplitPane rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        rightSplit.setUI(new BasicSplitPaneUI() {

            public void paint(Graphics g, JComponent jc) {
            }
        });
        rightSplit.setDividerSize(4);
        splitPane.add(rightSplit, JSplitPane.RIGHT);
        {
            JPanel propertiesPanel = new JPanel(new GridBagLayout());
            rightSplit.add(propertiesPanel, JSplitPane.TOP);
            propertiesPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(3, 0, 6, 6), BorderFactory.createTitledBorder("Editor Properties")));
            {
                JScrollPane scroll = new JScrollPane();
                propertiesPanel.add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
                scroll.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
                {
                    editorPropertiesPanel = new JPanel(new GridBagLayout());
                    scroll.setViewportView(editorPropertiesPanel);
                    scroll.getVerticalScrollBar().setUnitIncrement(70);
                }
            }
        }
        {
            JSplitPane rightSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
            rightSplitPane.setUI(new BasicSplitPaneUI() {

                public void paint(Graphics g, JComponent jc) {
                }
            });
            rightSplitPane.setDividerSize(4);
            rightSplitPane.setDividerLocation(100);
            rightSplit.add(rightSplitPane, JSplitPane.BOTTOM);
            JPanel propertiesPanel = new JPanel(new GridBagLayout());
            rightSplitPane.add(propertiesPanel, JSplitPane.TOP);
            propertiesPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(3, 0, 6, 6), BorderFactory.createTitledBorder("Influencers")));
            {
                JScrollPane scroll = new JScrollPane();
                propertiesPanel.add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
                scroll.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
                {
                    JPanel influencersPanel = new JPanel(new GridBagLayout());
                    influencerBox = new JComboBox(new DefaultComboBoxModel());
                    JButton addInfluencerButton = new JButton("Add");
                    addInfluencerButton.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            InfluencerWrapper wrapper = (InfluencerWrapper) influencerBox.getSelectedItem();
                            ParticleController controller = getEmitter();
                            if (controller != null)
                                addInfluencer(wrapper.type, controller);
                        }
                    });
                    influencersPanel.add(influencerBox, new GridBagConstraints(0, 0, 1, 1, 0, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                    influencersPanel.add(addInfluencerButton, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                    scroll.setViewportView(influencersPanel);
                    scroll.getVerticalScrollBar().setUnitIncrement(70);
                }
            }
            propertiesPanel = new JPanel(new GridBagLayout());
            rightSplitPane.add(propertiesPanel, JSplitPane.BOTTOM);
            propertiesPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(3, 0, 6, 6), BorderFactory.createTitledBorder("Particle Controller Components")));
            {
                JScrollPane scroll = new JScrollPane();
                propertiesPanel.add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
                scroll.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
                {
                    controllerPropertiesPanel = new JPanel(new GridBagLayout());
                    scroll.setViewportView(controllerPropertiesPanel);
                    scroll.getVerticalScrollBar().setUnitIncrement(70);
                }
            }
        }
        rightSplit.setDividerLocation(250);
    }
    {
        JSplitPane leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        leftSplit.setUI(new BasicSplitPaneUI() {

            public void paint(Graphics g, JComponent jc) {
            }
        });
        leftSplit.setDividerSize(4);
        splitPane.add(leftSplit, JSplitPane.LEFT);
        {
            JPanel spacer = new JPanel(new BorderLayout());
            leftSplit.add(spacer, JSplitPane.TOP);
            spacer.add(lwjglCanvas.getCanvas());
            spacer.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 4));
        }
        {
            JPanel emittersPanel = new JPanel(new BorderLayout());
            leftSplit.add(emittersPanel, JSplitPane.BOTTOM);
            emittersPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(0, 6, 6, 0), BorderFactory.createTitledBorder("Particle Controllers")));
            {
                effectPanel = new EffectPanel(this);
                emittersPanel.add(effectPanel);
            }
        }
        leftSplit.setDividerLocation(625);
    }
    splitPane.setDividerLocation(500);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Graphics(java.awt.Graphics) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController) CompoundBorder(javax.swing.border.CompoundBorder) BasicSplitPaneUI(javax.swing.plaf.basic.BasicSplitPaneUI) JSplitPane(javax.swing.JSplitPane)

Aggregations

ParticleController (com.badlogic.gdx.graphics.g3d.particles.ParticleController)26 DynamicsInfluencer (com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsInfluencer)8 ParticleEffect (com.badlogic.gdx.graphics.g3d.particles.ParticleEffect)7 RegularEmitter (com.badlogic.gdx.graphics.g3d.particles.emitters.RegularEmitter)6 SpawnInfluencer (com.badlogic.gdx.graphics.g3d.particles.influencers.SpawnInfluencer)6 ColorInfluencer (com.badlogic.gdx.graphics.g3d.particles.influencers.ColorInfluencer)5 DynamicsModifier (com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsModifier)4 RegionInfluencer (com.badlogic.gdx.graphics.g3d.particles.influencers.RegionInfluencer)4 ScaleInfluencer (com.badlogic.gdx.graphics.g3d.particles.influencers.ScaleInfluencer)4 BillboardRenderer (com.badlogic.gdx.graphics.g3d.particles.renderers.BillboardRenderer)4 PointSpawnShapeValue (com.badlogic.gdx.graphics.g3d.particles.values.PointSpawnShapeValue)4 GridBagConstraints (java.awt.GridBagConstraints)3 Insets (java.awt.Insets)3 SaveData (com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData)2 ModelInstanceRenderer (com.badlogic.gdx.graphics.g3d.particles.renderers.ModelInstanceRenderer)2 ParticleControllerControllerRenderer (com.badlogic.gdx.graphics.g3d.particles.renderers.ParticleControllerControllerRenderer)2 PointSpriteRenderer (com.badlogic.gdx.graphics.g3d.particles.renderers.PointSpriteRenderer)2 EllipseSpawnShapeValue (com.badlogic.gdx.graphics.g3d.particles.values.EllipseSpawnShapeValue)2 Array (com.badlogic.gdx.utils.Array)2 IntArray (com.badlogic.gdx.utils.IntArray)2