void ProcessStartSpatialPropAnim(ThnEvent ev) { var obj = Objects[(string)ev.Targets[0]]; var props = (LuaTable)ev.Properties["spatialprops"]; Matrix4?orient = null; object tmp; if (ev.Properties.TryGetValue("orient", out tmp)) { orient = ThnScript.GetMatrix((LuaTable)tmp); } if (obj.Camera != null) { if (orient != null) { obj.Camera.Orientation = orient.Value; } if (ev.Duration > 0) { FLLog.Error("Thn", "spatialpropanim.duration > 0 - unimplemented"); //return; } } if (obj.Camera == null) { FLLog.Error("Thn", "StartSpatialPropAnim unimplemented"); } }
public void Process(ThnEvent ev, Cutscene cs) { if (ev.Targets.Capacity == 0) { return; } ThnObject objA; if (!cs.Objects.TryGetValue((string)ev.Targets[0], out objA)) { FLLog.Error("Thn", "Object does not exist " + (string)ev.Targets[0]); return; } bool hasPos = false; Quaternion?q_orient = null; if (ev.Targets.Capacity >= 1) { var props = (LuaTable)ev.Properties["spatialprops"]; Vector3 pos; object tmp; if (props.TryGetValue("q_orient", out tmp)) { var tb = (LuaTable)tmp; q_orient = new Quaternion((float)tb[1], (float)tb[2], (float)tb[3], (float)tb[0]); } if (props.TryGetValue("orient", out tmp)) { var orient = ThnScript.GetMatrix((LuaTable)tmp); q_orient = orient.ExtractRotation(); } AxisRotation axisRotation = null; if (props.TryGetValue("axisrot", out tmp)) { var axisRot_Table = (LuaTable)tmp; axisRotation = new AxisRotation(); if (!axisRot_Table.TryGetVector3(1, out axisRotation.Axis)) { FLLog.Error("Thn", "invalid axisrot"); return; } axisRotation.Axis = Vector3.TransformNormal(axisRotation.Axis, objA.Rotate); axisRotation.Degrees = (float)axisRot_Table[0]; axisRotation.OriginalRotate = objA.Rotate; } hasPos = props.TryGetVector3("pos", out pos); if (ev.Targets.Capacity > 1) { ThnObject objB; if (!cs.Objects.TryGetValue((string)ev.Targets[1], out objB)) { FLLog.Error("Thn", "Object does not exist " + (string)ev.Targets[1]); return; } if (ev.Duration < float.Epsilon) { objA.Translate = objB.Translate; objA.Rotate = objB.Rotate; } else { cs.Coroutines.Add(new FollowSpatialRoutine() { Duration = ev.Duration, HasPos = hasPos, HasQuat = q_orient != null, This = objA, Follow = objB }); } } else { if (ev.Duration < float.Epsilon) { if (hasPos) { objA.Translate = pos; } if (q_orient != null) { objA.Rotate = Matrix4x4.CreateFromQuaternion(q_orient.Value); } } else { cs.Coroutines.Add(new StaticSpatialRoutine() { Duration = ev.Duration, HasPos = hasPos, HasQuat = q_orient != null, EndPos = pos, EndQuat = q_orient ?? Quaternion.Identity, This = objA, AxisRot = axisRotation }); } } } }
public void Process(ThnEvent ev, Cutscene cs) { if (ev.Targets.Capacity == 0) { return; } ThnObject objA; if (!cs.Objects.TryGetValue((string)ev.Targets[0], out objA)) { FLLog.Error("Thn", "Object does not exist " + (string)ev.Targets[0]); return; } if (ev.Targets.Capacity == 1) { var props = (LuaTable)ev.Properties["spatialprops"]; Quaternion?q_orient = null; Vector3 pos; object tmp; if (props.TryGetValue("q_orient", out tmp)) { var tb = (LuaTable)tmp; q_orient = new Quaternion((float)tb[1], (float)tb[2], (float)tb[3], (float)tb[0]); } if (props.TryGetValue("orient", out tmp)) { var orient = ThnScript.GetMatrix((LuaTable)tmp); q_orient = orient.ExtractRotation(); } bool hasPos = props.TryGetVector3("pos", out pos); if (ev.Duration < float.Epsilon) { if (hasPos) { objA.Translate = pos; } if (q_orient != null) { objA.Rotate = Matrix4.CreateFromQuaternion(q_orient.Value); } } else { cs.Coroutines.Add(new StaticSpatialRoutine() { Duration = ev.Duration, HasPos = hasPos, HasQuat = q_orient != null, EndPos = pos, EndQuat = q_orient ?? Quaternion.Identity, This = objA }); } } else { ThnObject objB; if (!cs.Objects.TryGetValue((string)ev.Targets[1], out objB)) { FLLog.Error("Thn", "Object does not exist " + (string)ev.Targets[1]); return; } if (ev.Duration < float.Epsilon) { objA.Translate = objB.Translate; objA.Rotate = objB.Rotate; } else { cs.Coroutines.Add(new FollowSpatialRoutine() { Duration = ev.Duration, HasPos = true, HasQuat = true, This = objA, Follow = objB }); } } }