/// <inheritdoc/> public override void CreateObject(Vector3 Position, Transformation BaseTransformation, Transformation AuxTransformation, int SectionIndex, bool AccurateObjectDisposal, double StartingDistance, double EndingDistance, double BlockLength, double TrackPosition, double Brightness, bool DuplicateMaterials) { bool[] free = new bool[Objects.Length]; bool anyfree = false; bool allfree = true; for (int i = 0; i < Objects.Length; i++) { free[i] = Objects[i].IsFreeOfFunctions(); if (free[i]) { anyfree = true; } else { allfree = false; } } if (anyfree && !allfree && Objects.Length > 1) { //Optimise a little: If *all* are free of functions, this can safely be converted into a static object without regard to below if (AuxTransformation.X != Vector3.Right || AuxTransformation.Y != Vector3.Down || AuxTransformation.Z != Vector3.Forward) { //HACK: //An animated object containing a mix of functions and non-functions and using yaw, pitch or roll must not be converted into a mix //of animated and static objects, as this causes rounding differences.... anyfree = false; } } if (anyfree) { for (int i = 0; i < Objects.Length; i++) { if (Objects[i].States.Length != 0) { if (free[i]) { Transformation FinalTransformation = new Transformation(BaseTransformation, AuxTransformation); Matrix4D mat = Matrix4D.Identity; mat *= Objects[i].States[0].Translation; mat *= (Matrix4D) new Transformation(FinalTransformation.Z, FinalTransformation.Y, FinalTransformation.X); double zOffset = Objects[i].States[0].Translation.ExtractTranslation().Z * -1.0; //To calculate the Z-offset within the object, we want the untransformed co-ordinates, not the world co-ordinates currentHost.CreateStaticObject(Objects[i].States[0].Prototype, AuxTransformation, mat, Matrix4D.CreateTranslation(Position.X, Position.Y, -Position.Z), AccurateObjectDisposal, zOffset, StartingDistance, EndingDistance, BlockLength, TrackPosition, Brightness); } else { Objects[i].CreateObject(Position, BaseTransformation, AuxTransformation, SectionIndex, TrackPosition, Brightness); } } } } else { for (int i = 0; i < Objects.Length; i++) { if (Objects[i].States.Length != 0) { Objects[i].CreateObject(Position, BaseTransformation, AuxTransformation, SectionIndex, TrackPosition, Brightness); } } } if (this.Sounds == null) { return; } for (int i = 0; i < Sounds.Length; i++) { if (this.Sounds[i] == null) { continue; } var snd = this.Sounds[i] as WorldSound; if (snd != null) { snd.CreateSound(Sounds[i].Position, BaseTransformation, AuxTransformation, SectionIndex, TrackPosition); } var snd2 = this.Sounds[i] as AnimatedWorldObjectStateSound; if (snd2 != null) { snd2.Create(Position, BaseTransformation, AuxTransformation, SectionIndex, TrackPosition, Brightness); } } }
/// <summary>Callback function to create the object within the world</summary> public override void CreateObject(Vector3 Position, Transformation WorldTransformation, Transformation LocalTransformation, int SectionIndex, double StartingDistance, double EndingDistance, double TrackPosition, double Brightness, bool DuplicateMaterials = false) { currentHost.CreateStaticObject(this, Position, WorldTransformation, LocalTransformation, 0.0, StartingDistance, EndingDistance, TrackPosition, Brightness); }