示例#1
0
        public void Write(SceneWriter writer, object component)
        {
            ParticleRenderer pr = component as ParticleRenderer;

            if (pr == null)
            {
                throw new Exception(GetType() + " cannot export components of type " + component.GetType());
            }
            writer.WriteElement("enabled", pr.enabled);
            writer.WriteElement("sharedMaterials", pr.sharedMaterials);
            //writer.WriteElement("stretchParticles", pr.);
            writer.WriteElement("lengthScale", pr.lengthScale);
            writer.WriteElement("velocityScale", pr.velocityScale);
            //writer.WriteElement("cameraVelocityScale", pr.cameraVelocityScale);
            writer.WriteElement("maxParticleSize", pr.maxParticleSize);
            writer.WriteElement("uvAnimation", new Vector3(pr.uvAnimationXTile, pr.uvAnimationYTile, pr.uvAnimationCycles));

            Component c = pr.GetComponent("FFWD_EllipsoidParticleEmitterExport");

            if (c == null)
            {
                // Added for backwards compatibility
                c = pr.GetComponent("XNAEllipsoidParticleEmitter");
            }
            if (c != null)
            {
                writeValue <object>(writer, c, "stretchParticles");
            }
        }
示例#2
0
    void WheelPosition()
    {
        RaycastHit hit;
        Vector3    wheelPos = new Vector3();

        //Calculate if the wheels touche the floor.
        if (Physics.Raycast(WheelLF.transform.position, -WheelLF.transform.up, out hit, WheelLF.radius + WheelLF.suspensionDistance))
        {
            //The wheel touches the floor, hit correspond to the contact point
            //Calculate the position of the Wheel to display properly
            wheelPos             = hit.point + WheelLF.transform.up * WheelLF.radius;
            ElevationLF          = hit.distance;
            prLF.maxParticleSize = currentSpeed / 100 * particleSize;
            //If the vehicle is braking and the wheel touches the floor, the smog becomes heavier
            if (isbraking)
            {
                prLF.maxParticleSize *= brakeSmogFactor;
                peLF.maxSize          = 6;
            }
            //If the vehicle is not braking, the particule have a normal size
            else
            {
                peLF.maxSize = 3;
            }
            prLF.GetComponent <ParticleEmitter>().emit = true;
        }
        //If the Wheel does not touch the floor, the wheel is placed at the maximum suspension distance, and does not emit smog
        else
        {
            wheelPos    = WheelLF.transform.position - WheelLF.transform.up * WheelLF.suspensionDistance;
            ElevationLF = WheelLF.suspensionDistance + WheelLF.radius;
            prLF.GetComponent <ParticleEmitter>().emit = false;
        }
        WheelLFTransform.position = wheelPos;

        if (Physics.Raycast(WheelRF.transform.position, -WheelRF.transform.up, out hit, WheelRF.radius + WheelRF.suspensionDistance))
        {
            wheelPos             = hit.point + WheelRF.transform.up * WheelRF.radius;
            ElevationRF          = hit.distance;
            prRF.maxParticleSize = currentSpeed / 100 * particleSize;
            if (isbraking)
            {
                prRF.maxParticleSize *= brakeSmogFactor;
                peRF.maxSize          = 6;
            }
            else
            {
                peRF.maxSize = 3;
            }
            prRF.GetComponent <ParticleEmitter>().emit = true;
        }
        else
        {
            wheelPos    = WheelRF.transform.position - WheelRF.transform.up * WheelRF.suspensionDistance;
            ElevationRF = WheelRF.suspensionDistance + WheelRF.radius;
            prRF.GetComponent <ParticleEmitter>().emit = false;
        }
        WheelRFTransform.position = wheelPos;

        if (Physics.Raycast(WheelLB.transform.position, -WheelLB.transform.up, out hit, WheelLB.radius + WheelLB.suspensionDistance))
        {
            wheelPos             = hit.point + WheelLB.transform.up * WheelLB.radius;
            ElevationLB          = hit.distance;
            prLB.maxParticleSize = currentSpeed / 100 * particleSize;
            prLB.GetComponent <ParticleEmitter>().emit = true;
        }
        else
        {
            wheelPos    = WheelLB.transform.position - WheelLB.transform.up * WheelLB.suspensionDistance;
            ElevationLB = WheelLB.suspensionDistance + WheelLB.radius;
            prLB.GetComponent <ParticleEmitter>().emit = false;
        }
        WheelLBTransform.position = wheelPos;

        if (Physics.Raycast(WheelRB.transform.position, -WheelRB.transform.up, out hit, WheelRB.radius + WheelRB.suspensionDistance))
        {
            wheelPos             = hit.point + WheelRB.transform.up * WheelRB.radius;
            ElevationRB          = hit.distance;
            prRB.maxParticleSize = currentSpeed / 100 * particleSize;
            prRB.GetComponent <ParticleEmitter>().emit = true;
        }
        else
        {
            wheelPos    = WheelRB.transform.position - WheelRB.transform.up * WheelRB.suspensionDistance;
            ElevationRB = WheelRB.suspensionDistance + WheelRB.radius;
            prRB.GetComponent <ParticleEmitter>().emit = false;
        }
        WheelRBTransform.position = wheelPos;
    }