Inheritance: MonoBehaviour
Exemplo n.º 1
0
        public static void Main(String[] args)
        {
            RenderWindow window = new RenderWindow(new VideoMode(1000, 700), "title");
            RenderTexture tex = new RenderTexture(1000, 700);
            Sprite texSprite = new Sprite(tex.Texture);

            Fractal fractal = new Fractal();

            fractal.CreateTreeFractal(500, 700, 3, 100, 0);
            Console.WriteLine(fractal.Nodes.Count);

            while (window.IsOpen())
            {
                window.Clear();
                tex.Clear(new Color(0, 0, 0, 200
                    ));
                foreach (Shape s in fractal.Nodes)
                {
                    window.Draw(s);
                }
                tex.Display();
                window.Draw(texSprite);
                window.Display();
                Image img = window.Capture();
                img.SaveToFile("C:/i.png");
                Console.ReadLine();
            }
        }
Exemplo n.º 2
0
 // method that actual creates the child
 private void Initialize(Fractal parent, Vector3 direction, Quaternion orientation)
 {
     mesh = parent.mesh;
     material = parent.material;
     maxDepth = parent.maxDepth; // child will inherit parent shape, material, maxDept
     depth = parent.depth + 1; // create set local variable to parent + 1
     childScale = parent.childScale; // inherit public childscale from parent
     transform.parent = parent.transform; // nests the gameObjects as children
     transform.localScale = Vector3.one * childScale; // changes scale of each child
     transform.localPosition = direction * (0.5f + 0.5f * childScale); // chnages z-pos of each child while considering size change
 }
Exemplo n.º 3
0
	private void Initialize (Fractal parent, int childIndex) {
		mesh = parent.mesh;
		materials = parent.materials;
		maxDepth = parent.maxDepth;
		depth = parent.depth + 1;
		childScale = parent.childScale;
		transform.parent = parent.transform;
		transform.localScale = Vector3.one * childScale;
		transform.localPosition =
			childDirections[childIndex] * (0.5f + 0.5f * childScale);
		transform.localRotation = childOrientations[childIndex];
	}
Exemplo n.º 4
0
 private void Initialize(Fractal parent, int childIndex)
 {
     meshes = parent.meshes;
     materials = parent.materials;
     maxDepth = parent.maxDepth;
     depth = parent.depth + 1;
     childScale = parent.childScale;
     transform.parent = parent.transform;
     spawnProbability = parent.spawnProbability;
     maxRotationSpeed = parent.maxRotationSpeed;
     maxTwist = parent.maxTwist;
     transform.localScale = Vector3.one * childScale;
     transform.localPosition = childDirections[childIndex] * (0.5f + 0.5f * childScale);
     transform.localRotation = childOrientations[childIndex];
 }
Exemplo n.º 5
0
    private void Initialize(Fractal parent,
                            Vector3 direction,
                            Quaternion orientation) {
        meshes = parent.meshes;
        maxDepth = parent.maxDepth;
        childScale = parent.childScale;
        spawnProbability = parent.spawnProbability;
        maxRotationSpeed = parent.maxRotationSpeed;
        maxTwist = parent.maxTwist;
        _depth = parent._depth + 1;
        _materials = parent._materials;

        transform.parent = parent.transform;
        transform.localScale = Vector3.one * childScale;
        transform.localPosition = direction * (0.5f + 0.5f * childScale);
        transform.localRotation = orientation;
    }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Fractal frm = new Fractal();

            if (selectedcolor != null)
            {
                Fractal.HSBColor.FromHSB(new Fractal.HSBColor(red, green, blue));
                this.Close();
                //MessageBox.Show(Convert.ToString(red));
            }
            else
            {
                //ignore
                this.Close();
            }
        }
Exemplo n.º 7
0
		public void CreateFractal()
		{
			fractal = new Fractal();
		}
Exemplo n.º 8
0
 private void Initialize(Fractal parent, int childIndex)
 {
     childCount++;
     //		int index = childThresholds.BinarySearch(childCount);
     //		int highest = index < 0 ? ~index : index;
     //		depthResult = childThresholds[highest];
     tag = "Fractal";
     Rigidbody sr = this.gameObject.AddComponent<Rigidbody>();
     TrailRenderer ptr = parent.GetComponent<TrailRenderer>();
     TrailRenderer tr = this.gameObject.AddComponent<TrailRenderer>();
     tr.materials = ptr.materials;
     sr.isKinematic = false;
     sr.useGravity = true;
     mesh = parent.mesh;
     BoxCollider bc = this.gameObject.AddComponent<BoxCollider>();
     materials = parent.materials;
     maxDepth = parent.maxDepth;
     depth = parent.depth + 1;
     childScale = parent.childScale;
     tr.startWidth = childScale * 4;
     tr.endWidth = childScale * 2;
     transform.parent = parent.transform;
     transform.localScale = Vector3.one * childScale;
     transform.localPosition = childDirections[childIndex] * (0.5f + 0.5f * childScale);
     transform.localRotation = childOrientations[childIndex];
     sr.AddForce(childDirections[childIndex] * 1000, ForceMode.Acceleration);
 }
Exemplo n.º 9
0
    void Start()
    {
        #if !UNITY_EDITOR
        Cursor.visible = false;
        #endif

        // Filters attached on camera
        filterArray = cameraEffect.GetComponents<Filter>();
        for (int i = 0; i < filterArray.Length; ++i) {
            Filter filter = filterArray[i];
            if (filter.enabled) {
                currentFilter = i;
                currentFilterType = filter.GetType();
                break;
            }
        }

        kaleido = GameObject.FindObjectOfType<Kaleido>();
        kaleido3DManager = GameObject.FindObjectOfType<Kaleido3DManager>();
        wireframe = GameObject.FindObjectOfType<Wireframe>();
        planet = GameObject.FindObjectOfType<Planet>();
        splashes = GameObject.FindObjectOfType<Splashes>();
        fractal = GameObject.FindObjectOfType<Fractal>();
        warband = GameObject.FindObjectOfType<WarbandManager>();
        glitchyCam = GameObject.FindObjectOfType<GlitchyCam>();

        kaleido3DManager.transform.parent.gameObject.SetActive(false);
        planet.transform.parent.gameObject.SetActive(false);
        wireframe.transform.parent.gameObject.SetActive(false);
        // warband.transform.parent.gameObject.SetActive(false);
    }
Exemplo n.º 10
0
Arquivo: Home.cs Projeto: jackwren/ASA
 private void runToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Fractal frmchild = new Fractal();
     frmchild.MdiParent = this;
     frmchild.Show();
 }
Exemplo n.º 11
0
 private double adjustCurrentHigh(int index, Fractal highFractal, double highestHighValue, Fractal lowFractal, ref double lowestLowValue)
 {
     for (int i = highFractal.index; i < index; i++)
     {
         if (MarketSeries.High[i] > highestHighValue)
         {
             highestHighValue = MarketSeries.High[i];
         }
     }
     for (int i = lowFractal.index; i < index; i++)
     {
         if (MarketSeries.Low[i] < lowestLowValue)
         {
             lowestLowValue = MarketSeries.Low[i];
         }
     }
     return(highestHighValue);
 }
Exemplo n.º 12
0
	public IEnumerator Create () {
		if (materials == null) {
			InitializeMaterials();
		}
		if(depth > 0)
			transform.Rotate(Random.Range (-maxTwist, maxTwist), 0f, 0f);
		if(this.GetComponent<MeshFilter>() == null) {
			gameObject.AddComponent<MeshFilter>().mesh = mesh;
			gameObject.AddComponent<MeshRenderer>().material = materials[usedColor];
		}
		if(depth < maxDepth) {
			for (int i = 0; i < childDirections.Length; i++) {
				if(Random.value < spawnProbability || depth == 0) {
					Fractal go = new GameObject("Fractal Child").AddComponent<Fractal>();
					go.Initialize(this, i);
					Vector3 scale = go.transform.localScale;
					go.transform.scaleFrom(.2f,Vector3.zero);
					yield return new WaitForSeconds(.2f);
				}
			}
		}
		if(depth == 0) {		
			FractalMaster = this;
		} else {
			NonMasterFractals.Add(this);
		}
		usedColor ++;
		if(usedColor >= materials.Length) {
			usedColor = 0;
		}
	}
Exemplo n.º 13
0
 public FractalEvent(int index, Fractal fractal)
 {
     this.fractal = fractal;
     this.index   = index;
 }
Exemplo n.º 14
0
 private static string getCircleLabel(Fractal fractal)
 {
     return("circle-" + (fractal.high ? "H" : "L") + "-" + fractal.index);
 }
Exemplo n.º 15
0
        public override void Execute(ref WooState state)
        {
            if (state._Objects > 0)
            {
                state._Objects--;
                Vector3 val = new Vector3(0.0, 0.5, 0.0);
                val.y *= state._Scale.y;
                val.Mul(state._Rotation);

                Fractal newFractal = new Fractal(new Vector3(state._Position.x + val.x, state._Position.y + val.y, state._Position.z + val.z),
                    state._Scale * 0.5,
                    state._Rotation,
                    state._DistanceMinimum,
                    state._DistanceScale,
                    state._DistanceOffset,
                    state._DistanceIterations,
                    state._DistanceExtents,
                    state._StepSize,
                    state._FractalIterations,
                    state._FractalIterationCount,
                    state._ColourIterationCount,
                    state._DEMode);
                newFractal._Material = GenerateMaterial(state);
                newFractal.CreateElement(state._Preview, state._Parent);
            }
        }
Exemplo n.º 16
0
        private Bitmap Draw()
        {
            int iters = iterations + 2 * steps;

            return(Fractal.createImage(currSrc * scale, currMvX * scale, currMvY * scale, iters));
        }
Exemplo n.º 17
0
 private static string getArrowLabel(Fractal fractal)
 {
     return("arrow-" + (fractal.high ? "high" : "low") + "-" + fractal.index);
 }
Exemplo n.º 18
0
	private void Initialize(Fractal parent, int childIndex) {
		fractalColors = parent.fractalColors;
		gameObject.layer = parent.gameObject.layer;
		mesh = parent.mesh;
		RotateSpeed = parent.RotateSpeed;
		spawnProbability = parent.spawnProbability;
		materials = parent.materials;
		maxDepth = parent.maxDepth;
		depth = parent.depth + 1;
		maxTwist = parent.maxTwist;
		childScale = parent.childScale;
		transform.parent = parent.transform;
		transform.localScale = Vector3.one * childScale;
		transform.localPosition = childDirections[childIndex] * (0.5f + 0.5f * childScale);
		transform.localRotation = childOrientations[childIndex];
	}
Exemplo n.º 19
0
    private static Color[] RenderNebulaFace(Color[] dest,Nebula neb,Fractal.Face face,int size)
    {
        Color[] source = neb.Render(face,size);

        for(int i=0;i<dest.Length;i++){

            switch (neb.nebulaMode){
            case Nebula.NebulaMode.Color:
                dest[i] += source[i];
                break;
            case Nebula.NebulaMode.ColorMask:
                    float grey  = (source[i].r +  source[i].g + source[i].b)/3f;
                    dest[i] = dest[i] * (Color.white - new Color(grey,grey,grey)*2)  +  source[i]*1.5f;
                break;
            case Nebula.NebulaMode.Mask:
                dest[i] = (dest[i] * source[i])*2;
                break;
            }

            // Original
            //dest[i] = source[i] * TextureTools.GetBlendingFactor( TextureTools.BlendingMode.Color, source[i] , dest[i]) + dest[i] * TextureTools.GetBlendingFactor( TextureTools.BlendingMode.Color, source[i] , dest[i]);
            dest[i].a = (dest[i].r + dest[i].g + dest[i].b)/3f;

        }

        return dest;
    }