Exemplo n.º 1
0
    public void mutateBranch(List <IStack> stacks,
                             int offset,
                             IFormConfiguration formConfig,
                             ColourConfiguration colourConfig,
                             Vector3 branchStartPosition,
                             Vector3 branchStartTwist,
                             Vector3 origin,
                             FormBounds formBounds)
    {
        Vector3 position   = origin;
        Vector3 stackTwist = formConfig.getStackStartTwist();

        float radius     = formConfig.getBranchPositionDelta().x * 20;
        float rhumbAngle = formConfig.getStartRotation().x * 0.032f;

        //colour stuff
        int   iterations  = formConfig.getStackIterations();
        Color modelColour = new Color(colourConfig.getBaseRed(),
                                      colourConfig.getBaseGreen(),
                                      colourConfig.getBaseBlue(),
                                      1);

        //if cycling override base colour
        if (colourConfig.getCycle())
        {
            modelColour = colourConfig.getCycleColour();
        }

        int i = offset;

        foreach (IStack stack in stacks)
        {
            position.x = formConfig.getStartPosition().x + (radius * (float)Math.Cos(i) / (float)Math.Cosh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle)));
            position.y = formConfig.getStartPosition().y + (radius * (float)Math.Sin(i) / (float)Math.Cosh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle)));
            position.z = formConfig.getStartPosition().z + (radius * (float)Math.Tanh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle)));

            formBounds.calculateNewBounds(position);

            //colour stuff order is important
            Color stackColour = modelColour;
            if (colourConfig.getFadeColour())
            {
                //fade colour in
                stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i - offset);
            }
            if (colourConfig.getPulse())
            {
                //do pulse
                stackColour = colourConfig.getPulseColourForStack(stackColour, i - offset);
            }

            stack.mutateTo(position, stackTwist, 0.5f, stackColour);

            stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta());

            i++;
        }
    }
Exemplo n.º 2
0
 public ColourConfiguration(ColourConfiguration config)
 {
     this.cycleColour = config.getCycleColour();
     //this.currentColour
     this.cycle      = config.getCycle();
     this.pulseCount = config.getPulseCount();
     //this.pulseLength
     this.pulse      = config.getPulse();
     this.pulseSpeed = config.getPulseSpeed();
     //this.pulseSpeedCount
     this.fadeColour     = config.getFadeColour();
     this.baseRed        = config.getBaseRed();
     this.baseGreen      = config.getBaseGreen();
     this.baseBlue       = config.getBaseBlue();
     this.backgroundType = config.getBackgroundType();
 }
Exemplo n.º 3
0
 public ColourConfiguration(ColourConfiguration config)
 {
     this.cycleColour = config.getCycleColour ();
     //this.currentColour
     this.cycle = config.getCycle ();
     this.pulseCount = config.getPulseCount ();
     //this.pulseLength
     this.pulse = config.getPulse ();
     this.pulseSpeed = config.getPulseSpeed ();
     //this.pulseSpeedCount
     this.fadeColour = config.getFadeColour ();
     this.baseRed = config.getBaseRed ();
     this.baseGreen = config.getBaseGreen ();
     this.baseBlue = config.getBaseBlue ();
     this.backgroundType = config.getBackgroundType ();
 }
Exemplo n.º 4
0
    public void createBranch(List <IStack> stacks,
                             int offset,
                             IFormConfiguration formConfig,
                             ColourConfiguration colourConfig,
                             Vector3 branchStartPosition,
                             Vector3 branchStartTwist,
                             Vector3 origin,
                             FormBounds formBounds)
    {
        float   scale      = formConfig.getStartScale();
        Vector3 stackTwist = formConfig.getStackStartTwist();
        Vector3 position   = branchStartPosition;
        Vector3 twist      = branchStartTwist;

        //rotate position araound previous branch start position
        position = GeometryUtility.rotateCoordinateAboutPoint(origin,
                                                              position,
                                                              branchStartTwist);

        //colour stuff
        int   iterations  = formConfig.getStackIterations();
        Color modelColour = new Color(colourConfig.getBaseRed(),
                                      colourConfig.getBaseGreen(),
                                      colourConfig.getBaseBlue(),
                                      1);

        //if cycling override base colour
        if (colourConfig.getCycle())
        {
            modelColour = colourConfig.getCycleColour();
        }

        for (int i = 0; i < iterations; i++)
        {
            formBounds.calculateNewBounds(position);

            //Stack Shape
            IStack stack = new SimpleStack();             //default
            if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere)
            {
                //spehere
                stack = new SimpleStack();
            }
            else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box)
            {
                //box
                stack = new SimpleBoxStack();
            }
            else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1)
            {
                //complex 1
                stack = new ComplexStack();
            }
            else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2)
            {
                //complex 2
                stack = new ComplexStack2();
            }
            else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus)
            {
                //simple Torus
                stack = new SimpleTorusStack();
            }

            //colour stuff order is important
            Color stackColour = modelColour;
            if (colourConfig.getFadeColour())
            {
                //fade colour in
                stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i);
            }
            if (colourConfig.getPulse())
            {
                //do pulse
                stackColour = colourConfig.getPulseColourForStack(stackColour, i);
            }

            stack.initialise(position, stackTwist, scale, stackColour);
            stacks.Add(stack);

            scale = scale * formConfig.getScaleDelta();
            Vector3 newPosition = GeometryUtility.addDeltaToPosition(position, formConfig.getBranchPositionDelta(), scale);
            position   = GeometryUtility.rotateCoordinateAboutPoint(position, newPosition, twist);
            twist      = GeometryUtility.addDeltaToRotation(twist, formConfig.getBranchTwistDelta());
            stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta());
        }
    }
Exemplo n.º 5
0
    public void mutateBranch(List <IStack> stacks,
                             int offset,
                             IFormConfiguration formConfig,
                             ColourConfiguration colourConfig,
                             Vector3 branchStartPosition,
                             Vector3 branchStartTwist,
                             Vector3 origin,
                             FormBounds formBounds)
    {
        float   scale      = formConfig.getStartScale();
        Vector3 stackTwist = formConfig.getStackStartTwist();
        Vector3 position   = branchStartPosition;
        Vector3 twist      = branchStartTwist;

        //rotate position araound previous branch start position
        position = GeometryUtility.rotateCoordinateAboutPoint(origin,
                                                              position,
                                                              branchStartTwist);

        //colour stuff
        int   iterations  = formConfig.getStackIterations();
        Color modelColour = new Color(colourConfig.getBaseRed(),
                                      colourConfig.getBaseGreen(),
                                      colourConfig.getBaseBlue(),
                                      1);

        //if cycling override base colour
        if (colourConfig.getCycle())
        {
            modelColour = colourConfig.getCycleColour();
        }

        int i = 0;

        foreach (IStack stack in stacks)
        {
            formBounds.calculateNewBounds(position);

            //colour stuff order is important
            Color stackColour = modelColour;
            if (colourConfig.getFadeColour())
            {
                //fade colour in
                stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i);
            }
            if (colourConfig.getPulse())
            {
                //do pulse
                stackColour = colourConfig.getPulseColourForStack(stackColour, i);
            }

            stack.mutateTo(position, stackTwist, scale, stackColour);

            scale = scale * formConfig.getScaleDelta();

            float positionScale = scale;
            if (!formConfig.getScaleBranch())
            {
                //ignore scale
                positionScale = 1;
            }
            Vector3 newPosition = GeometryUtility.addDeltaToPosition(position,
                                                                     formConfig.getBranchPositionDelta(),
                                                                     positionScale);
            position   = GeometryUtility.rotateCoordinateAboutPoint(position, newPosition, twist);
            twist      = GeometryUtility.addDeltaToRotation(twist, formConfig.getBranchTwistDelta());
            stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta());
            i++;
        }
    }
Exemplo n.º 6
0
    public void displayColourPalette(ColourConfiguration colourConfig)
    {
        Color guiColour = GUI.color;

        // Make a background box
        GUI.Box(new Rect(Screen.width - 210, 10, 200, 450), "Colour Palette");

        // pulsate colour button
        if (colourConfig.getPulse()) {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 40, 180, 20), "Pulsate Colour")) {
            colourConfig.setPulse(!colourConfig.getPulse());
            callback.updateColourConfig(colourConfig);
        }
        GUI.color = guiColour;

        //pulsate speed slider
        GUI.Label (new Rect (Screen.width - 146, 70, 180, 20), "Pulse Speed");

        colourConfig.setPulseSpeed (GUI.HorizontalSlider (new Rect (Screen.width - 200, 100, 180, 20), colourConfig.getPulseSpeed(), 10.0f, 0.0f));

        // colour cycle button
        if (colourConfig.getCycle()) {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 130, 180, 20), "Cycle Colour")) {
            colourConfig.setCycle(!colourConfig.getCycle());
            callback.updateColourConfig(colourConfig);
        }
        GUI.color = guiColour;

        // Base colour button
        if (colourConfig.getFadeColour()) {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 160, 180, 20), "Fade Colour")) {
            colourConfig.setFadeColour(!colourConfig.getFadeColour());
            callback.updateColourConfig(colourConfig);
        }
        GUI.color = guiColour;

        //rgb colour sliders
        GUI.Label (new Rect (Screen.width - 160, 190, 180, 20), "Red, Green, Blue");

        colourConfig.setBaseRed(GUI.HorizontalSlider (new Rect (Screen.width - 200, 220, 180, 20), colourConfig.getBaseRed(), 0.0f, 1.0f));

        colourConfig.setBaseGreen(GUI.HorizontalSlider (new Rect (Screen.width - 200, 250, 180, 20), colourConfig.getBaseGreen(), 0.0f, 1.0f));

        colourConfig.setBaseBlue(GUI.HorizontalSlider (new Rect (Screen.width - 200, 280, 180, 20), colourConfig.getBaseBlue(), 0.0f, 1.0f));

        for (int i = 0; i < 200; i++) {
            for (int j = 0; j < 20; j++) {
                Color currentColor = new Color (colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1.0f);
                texture.SetPixel (i, j, currentColor);
            }
        }
        texture.Apply();
        GUI.Box(new Rect(Screen.width - 200, 310, 180, 20), texture);

        if (colourConfig.getBackgroundType () == ColourConfiguration.BackgroundType.Dawn) {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 340, 180, 20), "Dawn Skybox")) {
            colourConfig.setBackgroundType(ColourConfiguration.BackgroundType.Dawn);
            callback.setBackground(colourConfig);
        }
        GUI.color = guiColour;

        if (colourConfig.getBackgroundType () == ColourConfiguration.BackgroundType.Eerie) {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 370, 180, 20), "Eerie Skybox")) {
            colourConfig.setBackgroundType(ColourConfiguration.BackgroundType.Eerie);
            callback.setBackground(colourConfig);
        }
        GUI.color = guiColour;

        if (colourConfig.getBackgroundType () == ColourConfiguration.BackgroundType.Night) {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 400, 180, 20), "Night Skybox")) {
            colourConfig.setBackgroundType(ColourConfiguration.BackgroundType.Night);
            callback.setBackground(colourConfig);
        }
        GUI.color = guiColour;

        /*
        //NOT IN USE
        if (colourConfig.getBackgroundType () == ColourConfiguration.BackgroundType.Julia) {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 430, 180, 20), "Julia")) {
            colourConfig.setBackgroundType(ColourConfiguration.BackgroundType.Julia);
            callback.setBackground(colourConfig);
        }
        GUI.color = guiColour;
        //*/
        if (colourConfig.getBackgroundType () == ColourConfiguration.BackgroundType.None) {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 430, 180, 20), "None")) {
            colourConfig.setBackgroundType(ColourConfiguration.BackgroundType.None);
            callback.setBackground(colourConfig);
        }
        GUI.color = guiColour;
    }
Exemplo n.º 7
0
    public void mutateBranch(List<IStack> stacks,
	                  int offset,
	                  IFormConfiguration formConfig, 
	                  ColourConfiguration colourConfig, 
	                  Vector3 branchStartPosition, 
	                  Vector3 branchStartTwist,
	                  Vector3 origin,
	                  FormBounds formBounds)
    {
        Vector3 position = origin;
        Vector3 stackTwist = formConfig.getStackStartTwist();

        float radius = formConfig.getBranchPositionDelta ().x * 20;
        float rhumbAngle = formConfig.getStartRotation().x * 0.032f;

        //colour stuff
        int iterations = formConfig.getStackIterations();
        Color modelColour = new Color (colourConfig.getBaseRed(),
                                       colourConfig.getBaseGreen(),
                                       colourConfig.getBaseBlue(),
                                       1);
        //if cycling override base colour
        if (colourConfig.getCycle ()) {
            modelColour = colourConfig.getCycleColour();
        }

        int i = offset;
        foreach (IStack stack in stacks) {

            position.x = formConfig.getStartPosition().x + (radius * (float) Math.Cos(i) / (float) Math.Cosh (Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle)));
            position.y = formConfig.getStartPosition().y + (radius * (float) Math.Sin(i) / (float) Math.Cosh (Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle)));
            position.z = formConfig.getStartPosition().z + (radius * (float) Math.Tanh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle)));

            formBounds.calculateNewBounds(position);

            //colour stuff order is important
            Color stackColour = modelColour;
            if (colourConfig.getFadeColour()) {
                //fade colour in
                stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i - offset);
            }
            if (colourConfig.getPulse()) {
                //do pulse
                stackColour = colourConfig.getPulseColourForStack(stackColour, i - offset);
            }

            stack.mutateTo(position, stackTwist, 0.5f, stackColour);

            stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta());

            i++;
        }
    }
Exemplo n.º 8
0
    public void createBranch(List<IStack> stacks,
	                  int offset,
	                  IFormConfiguration formConfig, 
	                  ColourConfiguration colourConfig, 
	                  Vector3 branchStartPosition, 
	                  Vector3 branchStartTwist,
	                  Vector3 origin,
	                  FormBounds formBounds)
    {
        Vector3 position = origin;
        Vector3 stackTwist = formConfig.getStackStartTwist();

        float radius = formConfig.getBranchPositionDelta ().x * 20;
        float rhumbAngle = formConfig.getStartRotation().x * 0.032f;

        //colour stuff
        int iterations = formConfig.getStackIterations();
        Color modelColour = new Color (colourConfig.getBaseRed(),
                                       colourConfig.getBaseGreen(),
                                       colourConfig.getBaseBlue(),
                                       1);
        //if cycling override base colour
        if (colourConfig.getCycle ()) {
            modelColour = colourConfig.getCycleColour();
        }

        for (int i = offset; i < offset + iterations; i++) {

            position.x = formConfig.getStartPosition().x + (radius * (float) Math.Cos(i) / (float) Math.Cosh (Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle)));
            position.y = formConfig.getStartPosition().y + (radius * (float) Math.Sin(i) / (float) Math.Cosh (Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle)));
            position.z = formConfig.getStartPosition().z + (radius * (float) Math.Tanh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle)));

            formBounds.calculateNewBounds(position);

            //Stack Shape
            IStack stack = new SimpleStack(); //default
            if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere) {
                //spehere
                stack = new SimpleStack();
            } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box) {
                //box
                stack = new SimpleBoxStack();
            } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1) {
                //complex 1
                stack = new ComplexStack();
            } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2) {
                //complex 2
                stack = new ComplexStack2();
            } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus) {
                //simple Torus
                stack = new SimpleTorusStack();
            }

            //colour stuff order is important
            Color stackColour = modelColour;
            if (colourConfig.getFadeColour()) {
                //fade colour in
                stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i);
            }
            if (colourConfig.getPulse()) {
                //do pulse
                stackColour = colourConfig.getPulseColourForStack(stackColour, i);
            }

            stack.initialise(position, stackTwist, 0.5f, stackColour);
            stacks.Add(stack);

            stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta());
        }
    }
Exemplo n.º 9
0
    public void displayColourPalette(ColourConfiguration colourConfig)
    {
        Color guiColour = GUI.color;

        // Make a background box
        GUI.Box(new Rect(Screen.width - 210, 10, 200, 450), "Colour Palette");

        // pulsate colour button
        if (colourConfig.getPulse())
        {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 40, 180, 20), "Pulsate Colour"))
        {
            colourConfig.setPulse(!colourConfig.getPulse());
            callback.updateColourConfig(colourConfig);
        }
        GUI.color = guiColour;

        //pulsate speed slider
        GUI.Label(new Rect(Screen.width - 146, 70, 180, 20), "Pulse Speed");

        colourConfig.setPulseSpeed(GUI.HorizontalSlider(new Rect(Screen.width - 200, 100, 180, 20), colourConfig.getPulseSpeed(), 10.0f, 0.0f));

        // colour cycle button
        if (colourConfig.getCycle())
        {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 130, 180, 20), "Cycle Colour"))
        {
            colourConfig.setCycle(!colourConfig.getCycle());
            callback.updateColourConfig(colourConfig);
        }
        GUI.color = guiColour;

        // Base colour button
        if (colourConfig.getFadeColour())
        {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 160, 180, 20), "Fade Colour"))
        {
            colourConfig.setFadeColour(!colourConfig.getFadeColour());
            callback.updateColourConfig(colourConfig);
        }
        GUI.color = guiColour;

        //rgb colour sliders
        GUI.Label(new Rect(Screen.width - 160, 190, 180, 20), "Red, Green, Blue");

        colourConfig.setBaseRed(GUI.HorizontalSlider(new Rect(Screen.width - 200, 220, 180, 20), colourConfig.getBaseRed(), 0.0f, 1.0f));

        colourConfig.setBaseGreen(GUI.HorizontalSlider(new Rect(Screen.width - 200, 250, 180, 20), colourConfig.getBaseGreen(), 0.0f, 1.0f));

        colourConfig.setBaseBlue(GUI.HorizontalSlider(new Rect(Screen.width - 200, 280, 180, 20), colourConfig.getBaseBlue(), 0.0f, 1.0f));

        for (int i = 0; i < 200; i++)
        {
            for (int j = 0; j < 20; j++)
            {
                Color currentColor = new Color(colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1.0f);
                texture.SetPixel(i, j, currentColor);
            }
        }
        texture.Apply();
        GUI.Box(new Rect(Screen.width - 200, 310, 180, 20), texture);

        if (colourConfig.getBackgroundType() == ColourConfiguration.BackgroundType.Dawn)
        {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 340, 180, 20), "Dawn Skybox"))
        {
            colourConfig.setBackgroundType(ColourConfiguration.BackgroundType.Dawn);
            callback.setBackground(colourConfig);
        }
        GUI.color = guiColour;

        if (colourConfig.getBackgroundType() == ColourConfiguration.BackgroundType.Eerie)
        {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 370, 180, 20), "Eerie Skybox"))
        {
            colourConfig.setBackgroundType(ColourConfiguration.BackgroundType.Eerie);
            callback.setBackground(colourConfig);
        }
        GUI.color = guiColour;

        if (colourConfig.getBackgroundType() == ColourConfiguration.BackgroundType.Night)
        {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 400, 180, 20), "Night Skybox"))
        {
            colourConfig.setBackgroundType(ColourConfiguration.BackgroundType.Night);
            callback.setBackground(colourConfig);
        }
        GUI.color = guiColour;

/*
 * //NOT IN USE
 *              if (colourConfig.getBackgroundType () == ColourConfiguration.BackgroundType.Julia) {
 *                      GUI.color = Color.green;
 *              }
 *              if (GUI.Button(new Rect(Screen.width - 200, 430, 180, 20), "Julia")) {
 *                      colourConfig.setBackgroundType(ColourConfiguration.BackgroundType.Julia);
 *                      callback.setBackground(colourConfig);
 *              }
 *              GUI.color = guiColour;
 * //*/
        if (colourConfig.getBackgroundType() == ColourConfiguration.BackgroundType.None)
        {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(Screen.width - 200, 430, 180, 20), "None"))
        {
            colourConfig.setBackgroundType(ColourConfiguration.BackgroundType.None);
            callback.setBackground(colourConfig);
        }
        GUI.color = guiColour;
    }
Exemplo n.º 10
0
    public void createBranch(List <IStack> stacks,
                             int offset,
                             IFormConfiguration formConfig,
                             ColourConfiguration colourConfig,
                             Vector3 branchStartPosition,
                             Vector3 branchStartTwist,
                             Vector3 origin,
                             FormBounds formBounds)
    {
        int iterations = formConfig.getStackIterations();

        float scale = formConfig.getStartScale();

        for (int o = 0; o < offset; o++)
        {
            scale *= formConfig.getScaleDelta();
        }

        //centre of ring
        Vector3 position = branchStartPosition;

        //add radius of ring
        float ringRadius = formConfig.getBranchPositionDelta().x * 10 * scale;

        //angle to calculate ring
        float zAngle           = branchStartTwist.z * Mathf.Deg2Rad;
        float yAngle           = branchStartTwist.y * Mathf.Deg2Rad;
        float ringSegmentAngle = 360 / iterations * Mathf.Deg2Rad;

        Vector3 stackTwist = formConfig.getStackStartTwist();

        //colour stuff
        Color modelColour = new Color(colourConfig.getBaseRed(),
                                      colourConfig.getBaseGreen(),
                                      colourConfig.getBaseBlue(),
                                      1);

        //if cycling override base colour
        if (colourConfig.getCycle())
        {
            modelColour = colourConfig.getCycleColour();
        }

        for (int i = offset; i < offset + iterations; i++)
        {
            position.x = (ringRadius * Mathf.Cos(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.x;
            position.y = (ringRadius * Mathf.Sin(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.y;
            position.z = (ringRadius * Mathf.Cos(yAngle)) + branchStartPosition.z;

            formBounds.calculateNewBounds(position);

            //Stack Shape
            IStack stack = new SimpleStack();             //default
            if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere)
            {
                //spehere
                stack = new SimpleStack();
            }
            else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box)
            {
                //box
                stack = new SimpleBoxStack();
            }
            else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1)
            {
                //complex 1
                stack = new ComplexStack();
            }
            else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2)
            {
                //complex 2
                stack = new ComplexStack2();
            }
            else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus)
            {
                //simple Torus
                stack = new SimpleTorusStack();
            }

            //colour stuff order is important
            Color stackColour = modelColour;
            if (colourConfig.getFadeColour())
            {
                //fade colour in
                stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i);
            }
            if (colourConfig.getPulse())
            {
                //do pulse
                stackColour = colourConfig.getPulseColourForStack(stackColour, i);
            }

            stack.initialise(position, stackTwist, 0.5f * scale, stackColour);
            stacks.Add(stack);

            yAngle    += ringSegmentAngle;
            stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta());
        }
    }
Exemplo n.º 11
0
    public void mutateBranch(List <IStack> stacks,
                             int offset,
                             IFormConfiguration formConfig,
                             ColourConfiguration colourConfig,
                             Vector3 branchStartPosition,
                             Vector3 branchStartTwist,
                             Vector3 origin,
                             FormBounds formBounds)
    {
        int iterations = formConfig.getStackIterations();

        float scale = formConfig.getStartScale();

        for (int o = 0; o < offset; o++)
        {
            scale *= formConfig.getScaleDelta();
        }

        //centre of ring
        Vector3 position = branchStartPosition;

        //add radius of ring
        float ringRadius = formConfig.getBranchPositionDelta().x * 10 * scale;

        //first element of ring on radius
        float zAngle = branchStartTwist.z * Mathf.Deg2Rad;
        float yAngle = branchStartTwist.y * Mathf.Deg2Rad;

        float ringSegmentAngle = 360 / iterations * Mathf.Deg2Rad;

        Vector3 stackTwist = formConfig.getStackStartTwist();

        //colour stuff
        Color modelColour = new Color(colourConfig.getBaseRed(),
                                      colourConfig.getBaseGreen(),
                                      colourConfig.getBaseBlue(),
                                      1);

        //if cycling override base colour
        if (colourConfig.getCycle())
        {
            modelColour = colourConfig.getCycleColour();
        }

        int i = 0;

        foreach (IStack stack in stacks)
        {
            position.x = (ringRadius * Mathf.Cos(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.x;
            position.y = (ringRadius * Mathf.Sin(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.y;
            position.z = (ringRadius * Mathf.Cos(yAngle)) + branchStartPosition.z;

            formBounds.calculateNewBounds(position);

            //colour stuff order is important
            Color stackColour = modelColour;
            if (colourConfig.getFadeColour())
            {
                //fade colour in
                stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i);
            }
            if (colourConfig.getPulse())
            {
                //do pulse
                stackColour = colourConfig.getPulseColourForStack(stackColour, i);
            }

            stack.mutateTo(position, stackTwist, 0.5f * scale, stackColour);

            yAngle += ringSegmentAngle;

            yAngle    += ringSegmentAngle;
            stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta());
            i++;
        }
    }
Exemplo n.º 12
0
    public void createBranch(List <IStack> stacks,
                             int offset,
                             IFormConfiguration formConfig,
                             ColourConfiguration colourConfig,
                             Vector3 branchStartPosition,
                             Vector3 branchStartTwist,
                             Vector3 origin,
                             FormBounds formBounds)
    {
        Vector3 position   = origin;
        Vector3 stackTwist = formConfig.getStackStartTwist();

        float radius     = formConfig.getBranchPositionDelta().x * 20;
        float rhumbAngle = formConfig.getStartRotation().x * 0.032f;

        //colour stuff
        int   iterations  = formConfig.getStackIterations();
        Color modelColour = new Color(colourConfig.getBaseRed(),
                                      colourConfig.getBaseGreen(),
                                      colourConfig.getBaseBlue(),
                                      1);

        //if cycling override base colour
        if (colourConfig.getCycle())
        {
            modelColour = colourConfig.getCycleColour();
        }

        for (int i = offset; i < offset + iterations; i++)
        {
            position.x = formConfig.getStartPosition().x + (radius * (float)Math.Cos(i) / (float)Math.Cosh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle)));
            position.y = formConfig.getStartPosition().y + (radius * (float)Math.Sin(i) / (float)Math.Cosh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle)));
            position.z = formConfig.getStartPosition().z + (radius * (float)Math.Tanh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle)));

            formBounds.calculateNewBounds(position);

            //Stack Shape
            IStack stack = new SimpleStack();             //default
            if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere)
            {
                //spehere
                stack = new SimpleStack();
            }
            else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box)
            {
                //box
                stack = new SimpleBoxStack();
            }
            else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1)
            {
                //complex 1
                stack = new ComplexStack();
            }
            else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2)
            {
                //complex 2
                stack = new ComplexStack2();
            }
            else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus)
            {
                //simple Torus
                stack = new SimpleTorusStack();
            }

            //colour stuff order is important
            Color stackColour = modelColour;
            if (colourConfig.getFadeColour())
            {
                //fade colour in
                stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i);
            }
            if (colourConfig.getPulse())
            {
                //do pulse
                stackColour = colourConfig.getPulseColourForStack(stackColour, i);
            }

            stack.initialise(position, stackTwist, 0.5f, stackColour);
            stacks.Add(stack);

            stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta());
        }
    }
Exemplo n.º 13
0
    public void createBranch(List<IStack> stacks, 
	                  int offset,
	                  IFormConfiguration formConfig, 
	                  ColourConfiguration colourConfig, 
	                  Vector3 branchStartPosition, 
	                  Vector3 branchStartTwist,
	                  Vector3 origin,
	                  FormBounds formBounds)
    {
        float scale = formConfig.getStartScale();
        Vector3 stackTwist = formConfig.getStackStartTwist();
        Vector3 position = branchStartPosition;
        Vector3 twist = branchStartTwist;
        //rotate position araound previous branch start position
        position = GeometryUtility.rotateCoordinateAboutPoint(origin,
                                                              position,
                                                              branchStartTwist);

        //colour stuff
        int iterations = formConfig.getStackIterations();
        Color modelColour = new Color (colourConfig.getBaseRed(),
                                       colourConfig.getBaseGreen(),
                                       colourConfig.getBaseBlue(),
                                       1);
        //if cycling override base colour
        if (colourConfig.getCycle ()) {
            modelColour = colourConfig.getCycleColour();
        }

        for (int i = 0; i < iterations; i++) {

            formBounds.calculateNewBounds(position);

            //Stack Shape
            IStack stack = new SimpleStack(); //default
            if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere) {
                //spehere
                stack = new SimpleStack();
            } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box) {
                //box
                stack = new SimpleBoxStack();
            } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1) {
                //complex 1
                stack = new ComplexStack();
            } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2) {
                //complex 2
                stack = new ComplexStack2();
            } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus) {
                //simple Torus
                stack = new SimpleTorusStack();
            }

            //colour stuff order is important
            Color stackColour = modelColour;
            if (colourConfig.getFadeColour()) {
                //fade colour in
                stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i);
            }
            if (colourConfig.getPulse()) {
                //do pulse
                stackColour = colourConfig.getPulseColourForStack(stackColour, i);
            }

            stack.initialise(position, stackTwist, scale, stackColour);
            stacks.Add(stack);

            scale = scale * formConfig.getScaleDelta();
            Vector3 newPosition = GeometryUtility.addDeltaToPosition(position, formConfig.getBranchPositionDelta(), scale);
            position = GeometryUtility.rotateCoordinateAboutPoint(position, newPosition, twist);
            twist = GeometryUtility.addDeltaToRotation(twist, formConfig.getBranchTwistDelta());
            stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta());
        }
    }
Exemplo n.º 14
0
    public void mutateBranch(List<IStack> stacks,
	                  int offset,
	                  IFormConfiguration formConfig, 
	                  ColourConfiguration colourConfig, 
	                  Vector3 branchStartPosition, 
	                  Vector3 branchStartTwist,
	                  Vector3 origin,
	                  FormBounds formBounds)
    {
        float scale = formConfig.getStartScale();
        Vector3 stackTwist = formConfig.getStackStartTwist();
        Vector3 position = branchStartPosition;
        Vector3 twist = branchStartTwist;
        //rotate position araound previous branch start position
        position = GeometryUtility.rotateCoordinateAboutPoint(origin,
                                                              position,
                                                              branchStartTwist);

        //colour stuff
        int iterations = formConfig.getStackIterations();
        Color modelColour = new Color (colourConfig.getBaseRed(),
                                       colourConfig.getBaseGreen(),
                                       colourConfig.getBaseBlue(),
                                       1);
        //if cycling override base colour
        if (colourConfig.getCycle ()) {
            modelColour = colourConfig.getCycleColour();
        }

        int i = 0;
        foreach (IStack stack in stacks) {

            formBounds.calculateNewBounds(position);

            //colour stuff order is important
            Color stackColour = modelColour;
            if (colourConfig.getFadeColour()) {
                //fade colour in
                stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i);
            }
            if (colourConfig.getPulse()) {
                //do pulse
                stackColour = colourConfig.getPulseColourForStack(stackColour, i);
            }

            stack.mutateTo(position, stackTwist, scale, stackColour);

            scale = scale * formConfig.getScaleDelta();

            float positionScale = scale;
            if (!formConfig.getScaleBranch()) {
                //ignore scale
                positionScale = 1;
            }
            Vector3 newPosition = GeometryUtility.addDeltaToPosition(position,
                                                                     formConfig.getBranchPositionDelta(),
                                                                     positionScale);
            position = GeometryUtility.rotateCoordinateAboutPoint(position, newPosition, twist);
            twist = GeometryUtility.addDeltaToRotation(twist, formConfig.getBranchTwistDelta());
            stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta());
            i++;
        }
    }
Exemplo n.º 15
0
    public void createBranch(List<IStack> stacks,
	                         int offset,
	                         IFormConfiguration formConfig, 
	                         ColourConfiguration colourConfig, 
	                         Vector3 branchStartPosition, 
	                         Vector3 branchStartTwist,
	                         Vector3 origin,
	                         FormBounds formBounds)
    {
        int iterations = formConfig.getStackIterations();

        float scale = formConfig.getStartScale();
        for (int o = 0; o < offset; o++) {
            scale *= formConfig.getScaleDelta();
        }

        //centre of ring
        Vector3 position = branchStartPosition;

        //add radius of ring
        float ringRadius = formConfig.getBranchPositionDelta().x * 10 * scale;

        //angle to calculate ring
        float zAngle = branchStartTwist.z * Mathf.Deg2Rad;
        float yAngle = branchStartTwist.y * Mathf.Deg2Rad;
        float ringSegmentAngle = 360 / iterations * Mathf.Deg2Rad;

        Vector3 stackTwist = formConfig.getStackStartTwist();

        //colour stuff
        Color modelColour = new Color (colourConfig.getBaseRed(),
                                       colourConfig.getBaseGreen(),
                                       colourConfig.getBaseBlue(),
                                       1);
        //if cycling override base colour
        if (colourConfig.getCycle ()) {
            modelColour = colourConfig.getCycleColour();
        }

        for (int i = offset; i < offset + iterations; i++) {

            position.x = (ringRadius * Mathf.Cos(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.x;
            position.y = (ringRadius * Mathf.Sin(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.y;
            position.z = (ringRadius * Mathf.Cos(yAngle)) + branchStartPosition.z;

            formBounds.calculateNewBounds(position);

            //Stack Shape
            IStack stack = new SimpleStack(); //default
            if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere) {
                //spehere
                stack = new SimpleStack();
            } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box) {
                //box
                stack = new SimpleBoxStack();
            } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1) {
                //complex 1
                stack = new ComplexStack();
            } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2) {
                //complex 2
                stack = new ComplexStack2();
            } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus) {
                //simple Torus
                stack = new SimpleTorusStack();
            }

            //colour stuff order is important
            Color stackColour = modelColour;
            if (colourConfig.getFadeColour()) {
                //fade colour in
                stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i);
            }
            if (colourConfig.getPulse()) {
                //do pulse
                stackColour = colourConfig.getPulseColourForStack(stackColour, i);
            }

            stack.initialise(position, stackTwist, 0.5f * scale, stackColour);
            stacks.Add(stack);

            yAngle += ringSegmentAngle;
            stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta());
        }
    }
Exemplo n.º 16
0
    public void mutateBranch(List<IStack> stacks,
	                         int offset,
	                         IFormConfiguration formConfig, 
	                         ColourConfiguration colourConfig, 
	                         Vector3 branchStartPosition, 
	                         Vector3 branchStartTwist,
	                         Vector3 origin,
	                         FormBounds formBounds)
    {
        int iterations = formConfig.getStackIterations();

        float scale = formConfig.getStartScale();
        for (int o = 0; o < offset; o++) {
            scale *= formConfig.getScaleDelta();
        }

        //centre of ring
        Vector3 position = branchStartPosition;

        //add radius of ring
        float ringRadius = formConfig.getBranchPositionDelta().x * 10 * scale;

        //first element of ring on radius
        float zAngle = branchStartTwist.z * Mathf.Deg2Rad;
        float yAngle = branchStartTwist.y * Mathf.Deg2Rad;

        float ringSegmentAngle = 360 / iterations * Mathf.Deg2Rad;

        Vector3 stackTwist = formConfig.getStackStartTwist();

        //colour stuff
        Color modelColour = new Color (colourConfig.getBaseRed(),
                                       colourConfig.getBaseGreen(),
                                       colourConfig.getBaseBlue(),
                                       1);

        //if cycling override base colour
        if (colourConfig.getCycle ()) {
            modelColour = colourConfig.getCycleColour();
        }

        int i = 0;
        foreach (IStack stack in stacks) {

            position.x = (ringRadius * Mathf.Cos(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.x;
            position.y = (ringRadius * Mathf.Sin(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.y;
            position.z = (ringRadius * Mathf.Cos(yAngle)) + branchStartPosition.z;

            formBounds.calculateNewBounds(position);

            //colour stuff order is important
            Color stackColour = modelColour;
            if (colourConfig.getFadeColour()) {
                //fade colour in
                stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i);
            }
            if (colourConfig.getPulse()) {
                //do pulse
                stackColour = colourConfig.getPulseColourForStack(stackColour, i);
            }

            stack.mutateTo(position, stackTwist, 0.5f * scale, stackColour);

            yAngle += ringSegmentAngle;

            yAngle += ringSegmentAngle;
            stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta());
            i++;
        }
    }