Esempio n. 1
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());
        }
    }
Esempio n. 2
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());
        }
    }
Esempio n. 3
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());
        }
    }
Esempio n. 4
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());
        }
    }
Esempio n. 5
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());
        }
    }
Esempio n. 6
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());
        }
    }