コード例 #1
0
ファイル: MaterialModifier.cs プロジェクト: sikora507/OpenC1
        public void UpdateWheelShape(VehicleChassis chassis, VehicleWheel wheel)
        {
            if (Bumpiness > 0)
            {
                if (wheel.Index == _nextWheel && chassis.Speed > 5 && _lastBump + 0.3f < Engine.TotalSeconds && !wheel.InAir)
                {
                    chassis.Actor.AddForceAtLocalPosition(new Vector3(0, Bumpiness * 65, 0), wheel.Shape.LocalPosition, ForceMode.Impulse, true);
                    _lastBump = Engine.TotalSeconds;
                    _nextWheel = Engine.Random.Next(0, chassis.Wheels.Count - 1);
                }
            }

            if (SmokeParticles != null)
            {
                wheel.SmokeEmitter.ParticleSystem = SmokeParticles;
                wheel.SmokeEmitter.Enabled = chassis.Speed > 5;
            }
            else
                wheel.SmokeEmitter.ParticleSystem = _defaultTyreSmokeSystem;

            if (SkidMaterial != null)
                chassis.Vehicle.SkidMarkBuffer.SetTexture(SkidMaterial.Texture);
            else
                chassis.Vehicle.SkidMarkBuffer.Enabled = false;
        }
コード例 #2
0
ファイル: VehicleWheel.cs プロジェクト: q4a/OpenC1
        public VehicleWheel(VehicleChassis chassis, CWheelActor cactor, WheelShape wheel, float axleOffset)
        {
            Shape       = wheel;
            _chassis    = chassis;
            _axleOffset = axleOffset;
            CActor      = cactor;

            SmokeEmitter = new ParticleEmitter(null, 15, Vector3.Zero);

            IsRear = !CActor.IsFront;

            _latTireFn          = Shape.LateralTireForceFunction;
            _lngTireFn          = Shape.LongitudalTireForceFunction;
            _defaultLatExtremum = _latTireFn.ExtremumValue;
            _defaultLngExtremum = _lngTireFn.ExtremumValue;
        }
コード例 #3
0
ファイル: RevCounter.cs プロジェクト: sikora507/OpenC1
        public RevCounter(VehicleChassis vehicle)
        {
            _chassis = vehicle;

            x = 0.01f;
            y = 0.8f;
            if (GameVars.Emulation == EmulationMode.Demo)
            {
                PixFile pix = new PixFile("tacho.pix");
                _speedoTexture = pix.PixMaps[0].Texture;
            }
            else
            {
                PixFile pix = new PixFile("hirestch.pix");
                _speedoTexture = pix.PixMaps[0].Texture;
            }
            _speedoLineTexture = TextureGenerator.Generate(new Color(255, 0, 0));
        }
コード例 #4
0
ファイル: Vehicle.cs プロジェクト: sikora507/OpenC1
        public Vehicle(string filename, IDriver driver)
        {
            Driver = driver;
            Driver.Vehicle = this;

            Config = new VehicleFile(filename);

            if (driver is PlayerDriver)
            {
                if (Config.WindscreenMaterial != "none")
                    Config.Funks.Add(new WindscreenFunk(Config.WindscreenMaterial, this));
            }

            _model = new VehicleModel(Config, false);

            Audio = new VehicleAudio(this);

            Chassis = new VehicleChassis(this);

            CActor actor2 = _model.GetActor(Path.GetFileNameWithoutExtension(_model.ModelName));
            if (actor2 != null)
            {
                _deformableModel = (CDeformableModel)actor2.Model;
                _deformableModel._actor = Chassis.Actor;
                _deformableModel._carFile = Config;
            }

            _crushSection = Config.CrushSections[1];

            CMaterial crashMat = ResourceCache.GetMaterial(Config.CrashMaterialFiles[0]);
            _vehicleBitsEmitter = new ParticleEmitter(new VehicleBitsParticleSystem(crashMat), 3, Vector3.Zero);
            _vehicleBitsEmitter.DumpsPerSecond = 0.7f;

            DamageSmokeEmitter = new ParticleEmitter(new DamageSmokeParticleSystem(Color.Gray), 5, Vector3.Zero);
            DamageSmokeEmitter.Enabled = false;

            _flames = new PixmapBillboard(new Vector2(0.7f, 0.25f), "flames.pix");
            SkidMarkBuffer = new SkidMarkBuffer(this, 150);
        }
コード例 #5
0
ファイル: ModelShadow.cs プロジェクト: sikora507/OpenC1
        public static void Render(BoundingBox bb, VehicleChassis chassis)
        {
            Vector3[] points = new Vector3[4];

            Matrix pose = chassis.Actor.GlobalPose;
            float shadowWidth = 0.0f;
            Vector3 pos = new Vector3(bb.Min.X - shadowWidth, 0, bb.Min.Z);
            points[0] = Vector3.Transform(pos, pose);
            pos = new Vector3(bb.Max.X + shadowWidth, 0, bb.Min.Z);
            points[1] = Vector3.Transform(pos, pose);
            pos = new Vector3(bb.Min.X - shadowWidth, 0, bb.Max.Z);
            points[2] = Vector3.Transform(pos, pose);
            pos = new Vector3(bb.Max.X + shadowWidth, 0, bb.Max.Z);
            points[3] = Vector3.Transform(pos, pose);

            StillDesign.PhysX.Scene scene = chassis.Actor.Scene;
            Vector3 offset = new Vector3(0, 0.1f, 0);
            for (int i = 0; i < 4; i++)
            {
                StillDesign.PhysX.RaycastHit hit = scene.RaycastClosestShape(
                    new StillDesign.PhysX.Ray(points[i], Vector3.Down), StillDesign.PhysX.ShapesType.Static);
                points[i] = hit.WorldImpact + offset;
            }

            Color shadowColor = new Color(10, 10, 10, 100);
            VertexPositionColor[] verts = new VertexPositionColor[points.Length];
            int i2 = 0;
            for (int i = points.Length-1; i >= 0; i--)
            {
                verts[i2++] = new VertexPositionColor(points[i], shadowColor);
            }

            GraphicsDevice device = Engine.Device;
            CullMode oldCullMode = Engine.Device.RenderState.CullMode;
            Engine.Device.RenderState.CullMode = CullMode.None;

            GameVars.CurrentEffect.World = Matrix.Identity;
            GameVars.CurrentEffect.TextureEnabled = false;
            GameVars.CurrentEffect.VertexColorEnabled = true;
            VertexDeclaration oldVertDecl = device.VertexDeclaration;
            device.VertexDeclaration = _vertexDeclaration;
            Engine.Device.RenderState.AlphaTestEnable = false;
            GameVars.CurrentEffect.PreferPerPixelLighting = false;
            //GameVars.CurrentEffect.LightingEnabled = false;

            device.RenderState.AlphaBlendEnable = true;
            device.RenderState.AlphaBlendOperation = BlendFunction.Add;
            device.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
            device.RenderState.SourceBlend = Blend.SourceAlpha;
            device.RenderState.DepthBufferWriteEnable = false;

            GameVars.CurrentEffect.CurrentTechnique.Passes[0].Begin();
            device.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, verts, 0, 2);
            GameVars.CurrentEffect.CurrentTechnique.Passes[0].End();

            GameVars.CurrentEffect.VertexColorEnabled = false;
            device.RenderState.AlphaBlendEnable = false;
            device.RenderState.DepthBufferWriteEnable = true;
            device.VertexDeclaration = oldVertDecl;
            Engine.Device.RenderState.CullMode = oldCullMode;

            GameVars.CurrentEffect.PreferPerPixelLighting = true;
            Engine.Device.RenderState.AlphaTestEnable = true;
            GameVars.CurrentEffect.TextureEnabled = true;
        }