void Generate() { // modify the origin by adding the normal vector with a magnitude; Vector3 origin = particleOrigin + (1.0f*particleOriginNormal); Vector3 mirroredOrigin = particleOrigin - (1.0f*particleOriginNormal); // create the object particles ObjectParticle objPart = new ObjectParticle(origin, particleTrajectory, 1000.0f); ObjectParticle mirObjPart = new ObjectParticle(mirroredOrigin, particleTrajectory, 1000.0f); // set the mainTexture as the webCamMaterial objPart.geometry.GetComponent<Renderer>().material.mainTexture = mCamera; mirObjPart.geometry.GetComponent<Renderer>().material.mainTexture = mCamera; // add the particles to the objectParticles list objectParticles.Add (objPart); objectParticles.Add (mirObjPart); // Debug.Log ("ballz"); // yield return new WaitForSeconds(25.0f); }
void Start() { // grab the webCam material from the event system mCamera = eventSys.GetComponent<WebCamSrc>().camTexture; startCount = 2; objectParticles = new List<ObjectParticle>(); destructionList = new List<int> (); // get the origin of the particle emitter particleOrigin = new Vector3 (transform.position.x, transform.position.y, transform.position.z); // used to calculate the velocity vector particleDestination = new Vector3 (mainCamera.transform.position.x, mainCamera.transform.position.y, mainCamera.transform.position.z); particleTrajectory = particleOrigin-particleDestination; // find the cross-product (normal) of that vector and the 'up' vector, normalize it // this produces a vector that is 90 degrees from the trajectory vector on the XY plane particleOriginNormal = Vector3.Normalize(Vector3.Cross (particleTrajectory, Vector3.up)); // start by creating two cubes for (int i=1; i<startCount; i++) { // modify the origin by adding the normal vector with a magnitude; Vector3 origin = particleOrigin + (i*1.0f*particleOriginNormal); Vector3 mirroredOrigin = particleOrigin - (i*1.0f*particleOriginNormal); // create the object particles ObjectParticle objPart = new ObjectParticle(origin, particleTrajectory, 1000.0f); ObjectParticle mirObjPart = new ObjectParticle(mirroredOrigin, particleTrajectory, 1000.0f); // set the mainTexture as the webCamMaterial objPart.geometry.GetComponent<Renderer>().material.mainTexture = mCamera; mirObjPart.geometry.GetComponent<Renderer>().material.mainTexture = mCamera; // add the particles to the objectParticles list objectParticles.Add (objPart); objectParticles.Add (mirObjPart); } }