/// <summary> /// Creates a new 3D object consiting of the provided octree. /// After creation, its transformation matrices reflect its position and /// orientation in the world space coordinate system. /// </summary> /// <param name="representation">The raw 3d data which represents the object in form of a BFSOctree.</param> /// <param name="rightHandedCoordinateSystem">Indicates whether the calling /// framework uses a right-handed coordinate system and if therefore the /// object needs to be translated into this system, if false nothing happens as /// octree data is always provided in a left-handed manner.</param> public Object3D(BFSOctree representation, bool rightHandedCoordinateSystem) { this._representation = representation; _rotation = _translation = Matrix.Identity; if (rightHandedCoordinateSystem) _rotation.M33 = -1.0f; updateTransformation(); }
/// <summary> /// Converts this trianlge mesh into a BFSOctree. /// </summary> /// <param name="maxLevel">The maximum node level/depth of any node in /// the created DynamicOctree.</param> /// <returns>A BFSOctree representing this triangle mesh.</returns> public BFSOctree toBFSOctree(byte maxLevel) { System.Collections.Generic.IEnumerator<AnimationClip> enum1; System.Collections.Generic.IEnumerator<AnimationChannel> enum2; enum1 = _model.AnimationClips.Values.GetEnumerator(); enum1.MoveNext(); enum2 = enum1.Current.Channels.Values.GetEnumerator(); enum2.MoveNext(); Matrix[,] animation = new Matrix[enum2.Current.Count, enum1.Current.Channels.Count]; AnimationClip clip; _model.AnimationClips.TryGetValue("Take 001", out clip); AnimationController c = new AnimationController(_model.SkeletonBones); c.StartClip(clip); for (long i = 0; i < enum2.Current.Count; ++i) { c.Update(new TimeSpan(clip.Duration.Ticks / enum2.Current.Count), Matrix.Identity); for (int j = 0; j < enum1.Current.Channels.Count; ++j) animation[i, j] = c.SkinnedBoneTransforms[j]; } _model = null; BFSOctree result = new BFSOctree(toDynamicOctree(maxLevel)); result._animation = animation; result.frameCount = (uint)enum2.Current.Count; result.boneCount = (uint)enum1.Current.Channels.Count; return result; }