public void RenderSingle(CActor actor) { Matrix m = actor.Matrix; m.Translation = Vector3.Zero; GameVars.CurrentEffect.World = m * GameVars.CurrentEffect.World; actor.Model.Render(actor.Material); }
public void RecalculateActorParent(CActor actor) { actor.Parent.Children.Remove(actor); //remove it from current parent bool found = false; for (int i = 0; i < _actors.Count; i++) { MoveChildren(actor, _actors[i], null, ref found); } }
private void ScaleTransformations(Vector3 scale, CActor actor) { if (actor.IsAnimated) { return; } actor.Matrix = actor.Matrix * Matrix.CreateScale(scale); foreach (CActor child in actor.Children) { ScaleTransformations(scale, child); } }
private void ResolveTransformations(Matrix world, CActor actor, List <BaseGroove> grooves) { if (grooves != null && grooves.Exists(g => g.ActorName == actor.Name)) { actor.ParentMatrix = world; actor.IsAnimated = true; return; } //Debug.WriteLine(actor.Name + ", " + actor.ModelName + ", " + actor.Flags[0] + ":" + actor.Flags[1] + "Animated: " + actor.IsAnimated); actor.Matrix = world * actor.Matrix; foreach (CActor child in actor.Children) { ResolveTransformations(actor.Matrix, child, grooves); } }
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); }
private void MoveChildren(CActor actorToMove, CActor parent, CActor parentParent, ref bool found) { if (found || parent.BoundingBox.Max.X == 0) { return; } if (parent.BoundingBox.Contains(actorToMove.PhysXActor.GlobalPosition) == ContainmentType.Contains) { foreach (CActor child in parent.Children) { MoveChildren(actorToMove, child, parent, ref found); } if (!found) { if (!parent.Children.Contains(actorToMove)) { parent.Children.Add(actorToMove); } found = true; } } }
private void ScaleTransformations(Vector3 scale, CActor actor) { if (actor.IsAnimated) return; actor.Matrix = actor.Matrix * Matrix.CreateScale(scale); foreach (CActor child in actor.Children) ScaleTransformations(scale, child); }
private void ResolveTransformations(Matrix world, CActor actor, List<BaseGroove> grooves) { if (grooves != null && grooves.Exists(g => g.ActorName == actor.Name)) { actor.ParentMatrix = world; actor.IsAnimated = true; return; } //Debug.WriteLine(actor.Name + ", " + actor.ModelName + ", " + actor.Flags[0] + ":" + actor.Flags[1] + "Animated: " + actor.IsAnimated); actor.Matrix = world * actor.Matrix; foreach (CActor child in actor.Children) ResolveTransformations(actor.Matrix, child, grooves); }
private void RenderChildren(BoundingFrustum frustum, CActor actor, Matrix world, bool parentAnimated) { if (RenderWheelsSeparately && actor.IsWheel) return; bool intersects; if (frustum == null) { intersects = true; } else { intersects = actor.BoundingBox.Max.X == 0; if (!intersects) { frustum.Intersects(ref actor.BoundingBox, out intersects); GameVars.NbrSectionsChecked++; } } if (intersects) { Matrix m = actor.GetDynamicMatrix(); if (actor.IsAnimated || parentAnimated) { if (actor.IsAnimated && !parentAnimated) { world = m * actor.ParentMatrix * GameVars.ScaleMatrix * world; } else { world = m * world; } GameVars.CurrentEffect.World = world; parentAnimated = true; } else { GameVars.CurrentEffect.World = m * world; } GameVars.CurrentEffect.CommitChanges(); if (actor.Model != null) { actor.Model.Render(actor.Material); if (actor.Model is CDeformableModel) { Models.SetupRender(); } } GameVars.NbrSectionsRendered++; foreach (CActor child in actor.Children) RenderChildren(frustum, child, world, parentAnimated); } }
private void MoveChildren(CActor actorToMove, CActor parent, CActor parentParent, ref bool found) { if (found || parent.BoundingBox.Max.X == 0) { return; } if (parent.BoundingBox.Contains(actorToMove.PhysXActor.GlobalPosition) == ContainmentType.Contains) { foreach (CActor child in parent.Children) MoveChildren(actorToMove, child, parent, ref found); if (!found) { if (!parent.Children.Contains(actorToMove)) { parent.Children.Add(actorToMove); } found = true; } } }
public void RenderSingle(CActor actor) { Matrix m = actor.Matrix; m.Translation = Vector3.Zero; GameVars.CurrentEffect.World = m * GameVars.CurrentEffect.World; GameVars.CurrentEffect.CommitChanges(); actor.Model.Render(actor.Material); }
public void RenderSinglePart(CActor actor) { _actors.RenderSingle(actor); }
public CWheelActor(CActor actor, bool driven, bool steerable) { Actor = actor; IsDriven = driven; IsSteerable = steerable; }
public void Add(CActor actor) { _actors.Add(actor); }
private void RenderChildren(BoundingFrustum frustum, CActor actor, Matrix world, bool parentAnimated) { if (RenderWheelsSeparately && actor.IsWheel) { return; } bool intersects; if (frustum == null) { intersects = true; } else { intersects = actor.BoundingBox.Max.X == 0; if (!intersects) { frustum.Intersects(ref actor.BoundingBox, out intersects); GameVars.NbrSectionsChecked++; } } if (intersects) { Matrix m = actor.GetDynamicMatrix(); if (actor.IsAnimated || parentAnimated) { if (actor.IsAnimated && !parentAnimated) { world = m * actor.ParentMatrix * GameVars.ScaleMatrix * world; } else { world = m * world; } GameVars.CurrentEffect.World = world; parentAnimated = true; } else { GameVars.CurrentEffect.World = m * world; } GameVars.CurrentEffect.CommitChanges(); if (actor.Model != null) { actor.Model.Render(actor.Material); if (actor.Model is CDeformableModel) { Models.SetupRender(); } } GameVars.NbrSectionsRendered++; foreach (CActor child in actor.Children) { RenderChildren(frustum, child, world, parentAnimated); } } }
public VehicleModel(VehicleFile file, bool forDisplayOnly) { Config = file; if (file.DrivenWheelRefs.Count == 0 || file.NonDrivenWheelRefs.Count == 0) { throw new Exception("No wheel refs specified"); } foreach (string pixFileName in file.PixFiles) { PixFile pixFile = new PixFile(pixFileName); ResourceCache.Add(pixFile); } foreach (string matFileName in file.MaterialFiles) { MatFile matFile = new MatFile(matFileName); ResourceCache.Add(matFile); } foreach (string matFileName in file.CrashMaterialFiles) { MatFile matFile = new MatFile(matFileName); ResourceCache.Add(matFile); } ResourceCache.ResolveMaterials(); _grooves = new List <BaseGroove>(); foreach (BaseGroove g in file.Grooves) { if (!g.IsWheelActor) { _grooves.Add(g); } } ActFile actFile = new ActFile(file.ActorFile); _actors = actFile.Hierarchy; DatFile modelFile = new DatFile(_actors.Root.ModelName, !forDisplayOnly); ModelName = _actors.Root.ModelName; _actors.AttachModels(modelFile.Models); _actors.ResolveTransforms(!forDisplayOnly, _grooves); foreach (BaseGroove g in _grooves) { g.SetActor(_actors.GetByName(g.ActorName)); } // link the funks and materials foreach (BaseFunk f in file.Funks) { f.Resolve(); } Vector3 tireWidth = new Vector3(0.034f, 0, 0) * GameVars.Scale; foreach (int id in file.DrivenWheelRefs) { BaseGroove g = file.Grooves.Find(a => a.Id == id); if (g == null) { continue; } CActor actor = _actors.GetByName(g.ActorName); CWheelActor ca = new CWheelActor(actor, true, false); ca.Position = actor.Matrix.Translation + (ca.IsLeft ? -1 * tireWidth : tireWidth); file.WheelActors.Add(ca); } foreach (int id in file.NonDrivenWheelRefs) { BaseGroove g = file.Grooves.Find(a => a.Id == id); CActor actor = _actors.GetByName(g.ActorName); if (actor == null) { continue; //BUSTER.TXT does some weird shit for cockpit view of the front wheels } CWheelActor ca = new CWheelActor(actor, false, true); ca.Position = actor.Matrix.Translation + (ca.IsLeft ? -1 * tireWidth : tireWidth); file.WheelActors.Add(ca); } if (forDisplayOnly) { _actors.RenderWheelsSeparately = false; } }