Esempio n. 1
0
        //actor must be an Actor
        public static Matrix GetLocalToWorld(ExportEntry actor)
        {
            PropertyCollection props = actor.GetProperties();
            var rotationProp         = props.GetProp <StructProperty>("Rotation");
            var locationsProp        = props.GetProp <StructProperty>("location");
            var drawScale3DProp      = props.GetProp <StructProperty>("DrawScale3D");
            var prePivotProp         = props.GetProp <StructProperty>("PrePivot");

            float drawScale = props.GetProp <FloatProperty>("DrawScale")?.Value ?? 1;

            Vector3 location = locationsProp != null?CommonStructs.GetVector3(locationsProp) : Vector3.Zero;

            Vector3 scale = drawScale * (drawScale3DProp != null ? CommonStructs.GetVector3(drawScale3DProp) : Vector3.One);
            Vector3 pivot = prePivotProp != null?CommonStructs.GetVector3(prePivotProp) : Vector3.Zero;

            Rotator rotator = rotationProp != null?CommonStructs.GetRotator(rotationProp) : new Rotator(0, 0, 0);

            return(ComposeLocalToWorld(location, rotator, scale, pivot));
        }
Esempio n. 2
0
        public static Matrix GetWorldToLocal(ExportEntry actor)
        {
            PropertyCollection props = actor.GetProperties();
            var rotationProp         = props.GetProp <StructProperty>("Rotation");
            var locationsProp        = props.GetProp <StructProperty>("location");
            var drawScale3DProp      = props.GetProp <StructProperty>("DrawScale3D");
            var prePivotProp         = props.GetProp <StructProperty>("PrePivot");

            float drawScale = props.GetProp <FloatProperty>("DrawScale")?.Value ?? 1;

            Vector3 location = locationsProp != null?CommonStructs.GetVector3(locationsProp) : Vector3.Zero;

            (float scaleX, float scaleY, float scaleZ) = drawScale3DProp != null?CommonStructs.GetVector3(drawScale3DProp) : Vector3.One;

            Vector3 prePivot = prePivotProp != null?CommonStructs.GetVector3(prePivotProp) : Vector3.Zero;

            Rotator rotation = rotationProp != null?CommonStructs.GetRotator(rotationProp) : new Rotator(0, 0, 0);

            return(Matrix.Translation(-location) *
                   InverseRotation(rotation) *
                   Matrix.Scaling(new Vector3(1f / scaleX, 1f / scaleY, 1f / scaleZ) / drawScale) *
                   Matrix.Translation(prePivot));
        }
Esempio n. 3
0
 public static StructProperty ToGuidStructProp(this Guid guid, NameReference propName) => CommonStructs.GuidProp(guid, propName);