/// <summary> /// Create a connected point between 2 points with rigidity (motions, rotations) and plastic limits (forces, moments). /// </summary> public ConnectedPoints(FdPoint3d firstPoint, FdPoint3d secondPoint, Motions motions, MotionsPlasticLimits motionsPlasticLimits, Rotations rotations, RotationsPlasticLimits rotationsPlasticLimits, IEnumerable <EntityBase> references, string identifier = "CP") { GuidListType[] refs = references.Select(r => new GuidListType(r)).ToArray(); RigidityDataType2 rigidity = new RigidityDataType2(motions, motionsPlasticLimits, rotations, rotationsPlasticLimits); Initialize(firstPoint, secondPoint, rigidity, refs, identifier); }
public CartesianTarget(Plane plane, RobotConfigurations?configuration = null, Motions motion = Motions.Joint, Tool?tool = null, Speed?speed = null, Zone?zone = null, Command?command = null, Frame?frame = null, IEnumerable <double>?external = null) : base(tool, speed, zone, command, frame, external) { Plane = plane; Motion = motion; Configuration = configuration; }
protected override void SolveInstance(IGH_DataAccess DA) { Curve curve = null; Motions motions = null; Rotations rotations = null; MotionsPlasticLimits motionsPlasticLimit = null; RotationsPlasticLimits rotationsPlasticLimit = null; bool movingLocal = false; if (!DA.GetData(0, ref curve)) { return; } if (!DA.GetData(1, ref motions)) { return; } if (!DA.GetData(2, ref rotations)) { return; } DA.GetData(3, ref motionsPlasticLimit); DA.GetData(4, ref rotationsPlasticLimit); DA.GetData(5, ref movingLocal); Vector3d v = Vector3d.Zero; DA.GetData(6, ref v); bool orientLCS = true; DA.GetData(7, ref orientLCS); string identifier = "S"; DA.GetData(8, ref identifier); if (curve == null || identifier == null) { return; } Geometry.Edge edge = Convert.FromRhinoLineOrArc1(curve); var obj = new Supports.LineSupport(edge, motions, motionsPlasticLimit, rotations, rotationsPlasticLimit, movingLocal, identifier); // Set local y-axis if (!v.Equals(Vector3d.Zero)) { obj.Group.LocalY = v.FromRhino(); } else // Orient coordinate system to GCS { if (orientLCS) { obj.Group.OrientCoordinateSystemToGCS(); } } DA.SetData(0, obj); }
Motions reform(Type EnTypeMotion, Transform[] tfBones) { var motions = new Motions(); motions.map(this, EnTypeMotion, tfBones); return(motions); }
public async Task LoadAsync() { IEnumerable <LookupItem> lookup = await _motionLookupService.GetMotionLookupAsync(); Motions.Clear(); foreach (LookupItem item in lookup) { Motions.Add(new NavigationItemViewModel(item.Id, item.DisplayMember, nameof(MotionDetailViewModel), _eventAggregator)); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Motions motions = Motions.ForMeeting(Meeting.FromIdentity(1)); this.RepeaterMotions.DataSource = motions; this.RepeaterMotions.DataBind(); } motionDesignations = new Dictionary <int, string>(); }
public void shiftTo(Motions motions, int motionId, bool isLoop) // 次のモーションにただちに遷移させる。 // 次のモーションは最初のフレームがタイムゼロならカットする。 { var stream = motions[motionId].getStream(streamId, enKeyMode); var nextKeyOffset = stream.times[0] == 0.0f ? 1 : 0; to = stream.getKeyLimitedMax(motionId, 0 + nextKeyOffset); next = stream.getKeyLimitedMax(motionId, 1 + nextKeyOffset); timeRate = to.time != from.time ? 1.0f / (to.time - from.time) : 0.0f; }
public YAMLNode ExportYAML() { YAMLMappingNode node = new YAMLMappingNode(); node.Add("m_Name", Name); node.Add("m_StateMachine", StateMachine.ExportYAML()); node.Add("m_Mask", Mask.ExportYAML()); node.Add("m_Motions", Motions.ExportYAML()); node.Add("m_Behaviours", Behaviours.ExportYAML()); node.Add("m_BlendingMode", BlendingMode); node.Add("m_SyncedLayerIndex", SyncedLayerIndex); node.Add("m_DefaultWeight", DefaultWeight); node.Add("m_IKPass", IKPass); node.Add("m_SyncedLayerAffectsTiming", SyncedLayerAffectsTiming); node.Add("m_Controller", Controller.ExportYAML()); return(node); }
protected override void SolveInstance(IGH_DataAccess DA) { Brep surface = null; Motions motions = null; MotionsPlasticLimits motionsPlasticLimit = null; Rhino.Geometry.Vector3d x = Vector3d.Zero; Rhino.Geometry.Vector3d z = Vector3d.Zero; string identifier = "S"; if (!DA.GetData(0, ref surface)) { return; } if (!DA.GetData(1, ref motions)) { return; } DA.GetData(2, ref motionsPlasticLimit); DA.GetData(3, ref x); DA.GetData(4, ref z); DA.GetData(5, ref identifier); if (surface == null || motions == null || identifier == null) { return; } Geometry.Region region = surface.FromRhino(); Supports.SurfaceSupport obj = new Supports.SurfaceSupport(region, motions, motionsPlasticLimit, identifier); // Set local x-axis if (!x.Equals(Vector3d.Zero)) { obj.CoordinateSystem.SetXAroundZ(x.FromRhino()); } // Set local z-axis if (!z.Equals(Vector3d.Zero)) { obj.CoordinateSystem.SetZAroundX(z.FromRhino()); } DA.SetData(0, obj); }
public YAMLNode ExportYAML(IExportContainer container) { YAMLMappingNode node = new YAMLMappingNode(); node.AddSerializedVersion(ToSerializedVersion(container.ExportVersion)); node.Add(NameName, Name); node.Add(StateMachineName, StateMachine.ExportYAML(container)); node.Add(MaskName, Mask.ExportYAML(container)); node.Add(MotionsName, Motions.ExportYAML(container)); node.Add(BehavioursName, Behaviours.ExportYAML(container)); node.Add(BlendingModeName, (int)BlendingMode); node.Add(SyncedLayerIndexName, SyncedLayerIndex); node.Add(DefaultWeightName, DefaultWeight); node.Add(IKPassName, IKPass); node.Add(SyncedLayerAffectsTimingName, SyncedLayerAffectsTiming); node.Add(ControllerName, Controller.ExportYAML(container)); return(node); }
public void Generate(EcologicalTypes ecologicalType, int terrainSubTypeDM, int terrainSizeDM, int motionSizeDM, Motions motion) { var pack = 0; var endurance = 0; var instinct = 0; var dexterity = 0; var strength = 0; EcologicalType = ecologicalType; Motion = motion; GenerateSubType(terrainSubTypeDM, ref pack, ref endurance, ref instinct, ref dexterity, ref strength); var sizeClass = GenerateSize(terrainSubTypeDM, terrainSizeDM, endurance, dexterity, strength); GenerateSocialProfile(pack, instinct); GeneratePackSize(); GenerateWeapons(); GenerateArmour(sizeClass); GenerateSkills(); }
public void progress(float time, Motions motions, bool isLoop) { while (time > to.time) { prev = from; from = to; to = next; if (to.keyCount > 0) { // 次のキーへ var stream = motions[to.motionId].getStream(streamId, enKeyMode); next = stream.getKeyNextCount(to.motionId, to.keyCount); timeRate = to.time != from.time ? 1.0f / (to.time - from.time) : 0.0f; } else if (isLoop) { // 先頭キーへ time -= from.time; var stream = motions[to.motionId].getStream(streamId, enKeyMode); var nextKeyOffset = stream.times[0] == 0.0f ? 1 : 0; next = stream.getKeyLimitedMax(to.motionId, 0 + nextKeyOffset); timeRate = to.time != from.time ? 1.0f / to.time : 0.0f; } else { // 最後のキーがずっと続く to.time = float.PositiveInfinity; } //if( streamId == 1 ) Debug.Log( streamId + " " + prev.keyCount + " " + from.keyCount + " " + to.keyCount + " " + next.keyCount ); } }
void build(_Action3 action, Type type, Type EnTypeMotion, EnStreamMode enMode) { act = action; var tfBones = getTfBonesFromRenderSystem(); motions = clips.getMotions(type, EnTypeMotion, tfBones); streamStates = new StreamKeyHolder(motions.streamLength, enMode); postures = new PostureUnit[tfBones.Length + 1]; //mtPostures = new Matrix4x4[ tfBones.Length + 1 ]; if (!streamStates.isReady) { boneLinks.scanLinks(tfBones, notRemveTransforms); } }
public static LineSupport Define(Autodesk.DesignScript.Geometry.Curve curve, Motions motions, [DefaultArgument("MotionsPlasticLimits.Default()")] MotionsPlasticLimits motionsPlasticLimits, Rotations rotations, [DefaultArgument("RotationsPlasticLimits.Default()")] RotationsPlasticLimits rotationsPlasticLimits, [DefaultArgument("false")] bool movingLocal, [DefaultArgument("Autodesk.DesignScript.Geometry.Vector.ByCoordinates(0,0,0)")] Autodesk.DesignScript.Geometry.Vector localY, [DefaultArgument("true")] bool orientLCS, [DefaultArgument("S")] string identifier) { Geometry.Edge edge = Geometry.Edge.FromDynamoLineOrArc1(curve); FemDesign.Supports.LineSupport obj = new LineSupport(edge, motions, motionsPlasticLimits, rotations, rotationsPlasticLimits, movingLocal, identifier); // set local y-axis if (!localY.Equals(Autodesk.DesignScript.Geometry.Vector.ByCoordinates(0, 0, 0))) { obj.Group.LocalY = FemDesign.Geometry.FdVector3d.FromDynamo(localY); } // else orient coordinate system to GCS else { if (orientLCS) { obj.Group.OrientCoordinateSystemToGCS(); } } return(obj); }
private void UpdateMotionsList(EdbotServerMessage edbotMessage) { if (!HasEdbots(edbotMessage)) { return; } Motions possibleMotions = edbotMessage.Edbots.First().Value.Motions; if (possibleMotions != null && possibleMotions.All != null) { Dictionary <string, int> allMotions = new Dictionary <string, int>(); foreach (Motion motion in possibleMotions.All) { allMotions.Add(motion.Name, motion.Id); } EdbotMotions = EdbotMotions.Union(allMotions).ToDictionary(k => k.Key, v => v.Value); ListedMotions?.Invoke(this, EventArgs.Empty); } }
public Motion(string _data, string topic, Delegation Proposer, bool isDefault = false) { if (!Motions.TryGetValue(_data, out var data)) { throw new MissingDataException($"Failed to load motion with id '{_data}'"); } Internal = data; Topic = topic; this.Proposer = Proposer; IsDefault = isDefault; var errMsg = "Missing Data: "; if (Internal.Topic && string.IsNullOrWhiteSpace(topic)) { errMsg += "Topic\n"; } if (errMsg != "Missing Data: ") { throw new MissingDataException(errMsg); } }
public void set(Motions motions, int motionId, bool isLoop) { var stream = motions[motionId].getStream(streamId, enKeyMode); prev = from = stream.getKey(motionId, 0); if (isLoop) { to = stream.getKeyLimitedMax(motionId, 1); // next = stream.getKeyLimitedMax(motionId, 2); // } else { to = stream.getKeyLimitedMax(motionId, 1); next = stream.getKeyLimitedMax(motionId, 2); } timeRate = to.time != from.time ? 1.0f / (to.time - from.time) : 0.0f; }
protected override void SolveInstance(IGH_DataAccess DA) { bool hasTarget = Params.Input.Any(x => x.Name == "Target"); bool hasJoints = Params.Input.Any(x => x.Name == "Joints"); bool hasPlane = Params.Input.Any(x => x.Name == "Plane"); bool hasConfig = Params.Input.Any(x => x.Name == "RobConf"); bool hasMotion = Params.Input.Any(x => x.Name == "Motion"); bool hasTool = Params.Input.Any(x => x.Name == "Tool"); bool hasSpeed = Params.Input.Any(x => x.Name == "Speed"); bool hasZone = Params.Input.Any(x => x.Name == "Zone"); bool hasCommand = Params.Input.Any(x => x.Name == "Command"); bool hasFrame = Params.Input.Any(x => x.Name == "Frame"); bool hasExternal = Params.Input.Any(x => x.Name == "External"); GH_Target sourceTarget = null; if (hasTarget) { if (!DA.GetData("Target", ref sourceTarget)) { return; } } double[] joints = null; var plane = new Plane(); RobotConfigurations?configuration = null; Motions motion = Motions.Joint; Tool tool = null; Speed speed = null; Zone zone = null; Command command = null; Frame frame = null; double[] external = null; if (hasJoints) { GH_String jointsGH = null; if (!DA.GetData("Joints", ref jointsGH)) { return; } string[] jointsText = jointsGH.Value.Split(','); if (jointsText.Length != 6) { return; } joints = new double[6]; for (int i = 0; i < 6; i++) { if (!GH_Convert.ToDouble_Secondary(jointsText[i], ref joints[i])) { return; } } } else if (sourceTarget != null) { if (sourceTarget.Value is JointTarget) { joints = (sourceTarget.Value as JointTarget).Joints; } } if (hasPlane) { GH_Plane planeGH = null; if (hasPlane) { if (!DA.GetData("Plane", ref planeGH)) { return; } } plane = planeGH.Value; } else if (sourceTarget != null) { if (sourceTarget.Value is CartesianTarget) { plane = (sourceTarget.Value as CartesianTarget).Plane; } } if (hasConfig) { GH_Integer configGH = null; if (hasConfig) { DA.GetData("RobConf", ref configGH); } configuration = (configGH == null) ? null : (RobotConfigurations?)configGH.Value; } else if (sourceTarget != null) { if (sourceTarget.Value is CartesianTarget) { configuration = (sourceTarget.Value as CartesianTarget).Configuration; } } if (hasMotion) { GH_String motionGH = null; DA.GetData("Motion", ref motionGH); motion = (motionGH == null) ? Motions.Joint : (Motions)Enum.Parse(typeof(Motions), motionGH.Value); } else if (sourceTarget != null) { if (sourceTarget.Value is CartesianTarget) { motion = (sourceTarget.Value as CartesianTarget).Motion; } } if (hasTool) { GH_Tool toolGH = null; DA.GetData("Tool", ref toolGH); tool = toolGH?.Value; } else if (sourceTarget != null) { tool = sourceTarget.Value.Tool; } if (hasSpeed) { GH_Speed speedGH = null; DA.GetData("Speed", ref speedGH); speed = speedGH?.Value; } else if (sourceTarget != null) { speed = sourceTarget.Value.Speed; } if (hasZone) { GH_Zone zoneGH = null; DA.GetData("Zone", ref zoneGH); zone = zoneGH?.Value; } else if (sourceTarget != null) { zone = sourceTarget.Value.Zone; } if (hasCommand) { GH_Command commandGH = null; DA.GetData("Command", ref commandGH); command = commandGH?.Value; } else if (sourceTarget != null) { command = sourceTarget.Value.Command; } if (hasFrame) { GH_Frame frameGH = null; DA.GetData("Frame", ref frameGH); frame = frameGH?.Value; } else if (sourceTarget != null) { frame = sourceTarget.Value.Frame; } if (hasExternal) { GH_String externalGH = null; if (!DA.GetData("External", ref externalGH)) { external = new double[0]; } else { string[] externalText = externalGH.Value.Split(','); int length = externalText.Length; external = new double[length]; for (int i = 0; i < length; i++) { if (!GH_Convert.ToDouble_Secondary(externalText[i], ref external[i])) { return; } } } } else if (sourceTarget != null) { external = sourceTarget.Value.External; } Target target; bool localCartesian = isCartesian; if (hasTarget && !hasPlane && !hasJoints) { localCartesian = sourceTarget.Value is CartesianTarget; } if (localCartesian) { target = new CartesianTarget(plane, configuration, motion, tool, speed, zone, command, frame, external); } else { target = new JointTarget(joints, tool, speed, zone, command, frame, external); } if (sourceTarget != null) { target.ExternalCustom = sourceTarget.Value.ExternalCustom; } DA.SetData(0, new GH_Target(target)); }
/// <summary> /// Constructor by edge and rigidity. Used to create group for point support /// </summary> internal Group(Geometry.FdVector3d localX, Geometry.FdVector3d localY, Motions motions, MotionsPlasticLimits motionsPlasticLimits, Rotations rotations, RotationsPlasticLimits rotationsPlasticLimits) { this._localX = localX; this._localY = localY; this.Rigidity = new RigidityDataType3(motions, motionsPlasticLimits, rotations, rotationsPlasticLimits); }
/// <summary> /// Constructor by vectors and rigidity. Used to create group for point support /// </summary> public Group(Geometry.FdVector3d localX, Geometry.FdVector3d localY, Motions motions, Rotations rotations) { this._localX = localX; this._localY = localY; this.Rigidity = new RigidityDataType3(motions, rotations); }
/// <summary> /// Create surface support with only translation rigidity and force plastic limits defined. /// </summary> public SurfaceSupport(Geometry.Region region, Motions motions, MotionsPlasticLimits motionsPlasticLimits, string identifier = "S") { var rigidity = new RigidityDataType1(motions, motionsPlasticLimits); Initialize(region, rigidity, identifier); }
public CartesianTarget(Plane plane, Target target, RobotConfigurations?configuration = null, Motions motion = Motions.Joint, IEnumerable <double> external = null) : this(plane, configuration, motion, target.Tool, target.Speed, target.Zone, target.Command, target.Frame, external ?? target.External) { }
public CartesianTarget(Plane plane, RobotConfigurations?configuration = null, Motions motion = Motions.Joint, Tool tool = null, Speed speed = null, Zone zone = null, Command command = null, Frame frame = null, IEnumerable <double> external = null) : base(tool, speed, zone, command, frame, external) { this.Plane = plane; this.Motion = motion; this.Configuration = configuration; }
public CartesianTarget(Plane plane, Target target, RobotConfigurations? configuration = null, Motions motion = Motions.Joint, IEnumerable<double> external = null) : this(plane, configuration, motion, target.Tool, target.Speed, target.Zone, target.Command, target.Frame, external ?? target.External) { }
public CartesianTarget(Plane plane, RobotConfigurations? configuration = null, Motions motion = Motions.Joint, Tool tool = null, Speed speed = null, Zone zone = null, Command command = null, Frame frame = null, IEnumerable<double> external = null) : base(tool, speed, zone, command, frame, external) { this.Plane = plane; this.Motion = motion; this.Configuration = configuration; }
/// <summary> /// Constructor by edge and rigidity. Used to create group for line support /// </summary> internal Group(Geometry.FdCoordinateSystem coordSystem, Motions motions, MotionsPlasticLimits motionsPlasticLimits, Rotations rotations, RotationsPlasticLimits rotationsPlasticLimits) { this.CoordinateSystem = coordSystem; this.Rigidity = new RigidityDataType3(motions, motionsPlasticLimits, rotations, rotationsPlasticLimits); }
public static SurfaceSupport SurfaceSupportDefine(Autodesk.DesignScript.Geometry.Surface surface, Motions motions, [DefaultArgument("MotionsPlasticLimits.Default()")] MotionsPlasticLimits motionsPlasticLimits, [DefaultArgument("Autodesk.DesignScript.Geometry.Vector.ByCoordinates(0,0,0)")] Autodesk.DesignScript.Geometry.Vector localX, [DefaultArgument("Autodesk.DesignScript.Geometry.Vector.ByCoordinates(0,0,0)")] Autodesk.DesignScript.Geometry.Vector localZ, [DefaultArgument("S")] string identifier) { // convert geometry Geometry.Region region = Geometry.Region.FromDynamo(surface); // create new surface support SurfaceSupport obj = new SurfaceSupport(region, motions, motionsPlasticLimits, identifier); // set local x-axis if (!localX.Equals(Autodesk.DesignScript.Geometry.Vector.ByCoordinates(0, 0, 0))) { obj.CoordinateSystem.SetXAroundZ(FemDesign.Geometry.FdVector3d.FromDynamo(localX)); } // set local z-axis if (!localZ.Equals(Autodesk.DesignScript.Geometry.Vector.ByCoordinates(0, 0, 0))) { obj.CoordinateSystem.SetZAroundX(FemDesign.Geometry.FdVector3d.FromDynamo(localZ)); } return(obj); }
public Critter(EcologicalTypes ecologicalType, int terrainSubTypeDM, int terrainSizeDM, int motionSizeDM, Motions motion) { Generate(ecologicalType, terrainSubTypeDM, terrainSizeDM, motionSizeDM, motion); }
public static PointSupport Define(Autodesk.DesignScript.Geometry.Point point, Motions motions, [DefaultArgument("MotionsPlasticLimits.Default()")] MotionsPlasticLimits motionsPlasticLimits, Rotations rotations, [DefaultArgument("RotationsPlasticLimits.Default()")] RotationsPlasticLimits rotationsPlasticLimits, [DefaultArgument("S")] string identifier) { return(new PointSupport(Geometry.FdPoint3d.FromDynamo(point), motions, motionsPlasticLimits, rotations, rotationsPlasticLimits, identifier)); }
public SongMetadata ParseFile() { string fileName = Metadata.ChartFullPath; Dictionary <int, int> holdIDlist = new Dictionary <int, int>(); Dictionary <int, SlideCollection> tempSlideDict = new Dictionary <int, SlideCollection>(); try { using (StreamReader sr = new StreamReader(new FileStream(fileName, FileMode.Open, FileAccess.Read))) { while (!sr.EndOfStream) { string line = sr.ReadLine(); // Whatever metadata stuff isn't covered in SongMetadata // Regex match for standard steps if (Regex.Match(line, "[#][0-9]{3}[1]").Success) { var parsed = ParseLine(line); double noteSub = 1.0 / parsed.Notes.Count; for (int i = 0; i < parsed.Notes.Count; i++) { switch (parsed.Notes[i].Item1) { case 1: // Left Step Steps.Add(new Note(4 * (parsed.Measure + i * noteSub), parsed.LaneIndex, parsed.Notes[i].Item2, Side.Left)); break; case 2: // Right Step Steps.Add(new Note(4 * (parsed.Measure + i * noteSub), parsed.LaneIndex, parsed.Notes[i].Item2, Side.Right)); break; case 3: // Motion Up Motions.Add(new Note(4 * (parsed.Measure + i * noteSub), 0, 16, Motion.Up)); break; case 4: // Motion Down Motions.Add(new Note(4 * (parsed.Measure + i * noteSub), 0, 16, Motion.Down)); break; default: // Rest notes / spacers (0) are ignored break; } } } // Regex match for hold/slides else if (Regex.IsMatch(line, "[#][0-9]{3}[2-3]")) { var parsed = ParseLine(line); double noteSub = 1.0 / parsed.Notes.Count; for (int i = 0; i < parsed.Notes.Count; i++) { Side side = parsed.NoteClass == 2 ? Side.Left : Side.Right; switch (parsed.Notes[i].Item1) { case 1: // Start a new note // Check to see if a hold is already active-- if so, commit it and start a new one if (tempSlideDict.ContainsKey(parsed.NoteIdentifier)) { CommitHold(tempSlideDict[parsed.NoteIdentifier]); tempSlideDict.Remove(parsed.NoteIdentifier); } // Create a collection tempSlideDict.Add(parsed.NoteIdentifier, new SlideCollection()); // Add this note to it tempSlideDict[parsed.NoteIdentifier].Notes.Add(new Tuple <NoteParse, int>(parsed, i)); break; case 2: // End a hold note with no shuffle case 3: // End a hold note with a shuffle case 4: // Add a midpoint with no shuffle case 5: // Add a midpoint with a shuffle if (!tempSlideDict.ContainsKey(parsed.NoteIdentifier)) { tempSlideDict.Add(parsed.NoteIdentifier, new SlideCollection()); // Add a new one (it will f**k up shit if this happens) } // Add this note to it tempSlideDict[parsed.NoteIdentifier].Notes.Add(new Tuple <NoteParse, int>(parsed, i)); break; default: // Rest notes / spacers (0) are ignored break; } } } // Parse BPM changes else if (Regex.IsMatch(line, "[#][0-9]{3}(08:)")) { //var parsed = ParseLine(line); var split = line.Replace(" ", string.Empty).Split(':'); var parsed = new NoteParse(); parsed.Measure = Convert.ToDouble(line.Substring(1, 3)); parsed.Notes = new List <Tuple <int, int> >(); for (int i = 0; i < split[1].Length; i += 2) { string id = split[1][i].ToString() + split[1][i + 1].ToString(); parsed.Notes.Add(new Tuple <int, int>(id.ParseBase36(), 0)); } double noteSub = 1.0 / parsed.Notes.Count; for (int i = 0; i < parsed.Notes.Count; i++) { if (parsed.Notes[i].Item1 == 0) { break; } else { Metadata.BpmEvents.Add(new BpmChangeEvent(Metadata.BpmIndex[parsed.Notes[i].Item1], 4 * (parsed.Measure + i * noteSub))); } } } } } // Close out any remaining hold notes foreach (var tempHold in tempSlideDict) { CommitHold(tempHold.Value); } // Sort holds for drawing later Holds = Holds.OrderBy(x => x.StartNote.BeatLocation).ToList(); // Add Beat Markers var noteLast = Steps.Count > 0 ? Steps.Max(x => x.BeatLocation) : 0; var holdLast = Holds.Count > 0 ? Holds.Max(x => x.Notes.Max(y => y.BeatLocation)) : 0; var motionLast = Motions.Count > 0 ? Motions.Max(x => x.BeatLocation) : 0; double lastBeat = Math.Max(noteLast, holdLast); lastBeat = Math.Ceiling(Math.Max(lastBeat, motionLast)); for (int i = 0; i <= (int)lastBeat; i += 4) { Markers.Add(new BeatMarker(i)); } TotalNotes += Steps.Count(); TotalNotes += Holds.Count(); foreach (var hold in Holds) { TotalNotes += hold.GradePoints.Count; // Additional beat counters for holds/slides TotalNotes += hold.Notes.Count(x => x.Type == NoteType.Shuffle); } TotalNotes += Motions.Count(); } catch (Exception e) { Logger.WriteEntry("Exception in NoteCollection.ParseFile() => Input: " + fileName + ", Exception: " + e.Message + ", Stack Trace: " + e.StackTrace + (e.InnerException != null ? ", Inner Exception: " + e.InnerException.Message : "")); } return(Metadata); }
public SongMetadata ParseFile() { string fileName = Metadata.ChartFullPath; // Used for v0.1 Dictionary <int, SlideCollection> tempSlideDict = new Dictionary <int, SlideCollection>(); // Used for v1.0 Dictionary <int, Hold> tempHoldDict = new Dictionary <int, Hold>(); // Temp parsing variables int beatsPerMeasure = 4; // Ultimately this should be tied to time signature int measure = -1; double subDiv; int noteClass, lane, width, id, endLane, endWidth; bool inNoteData = false; try { using (StreamReader sr = new StreamReader(new FileStream(fileName, FileMode.Open, FileAccess.Read))) { while (!sr.EndOfStream) { string line = sr.ReadLine(); // Whatever metadata stuff isn't covered in SongMetadata if (Metadata.Version.Major == 1 && Metadata.Version.Minor == 0) { // Look for BPM change tags if (Regex.Match(line, "^(#BPMC)").Success) { var bpmSplit = Regex.Split(line, @"[(#BPMC)\s:.]+").Where(s => !String.IsNullOrEmpty(s)); if (bpmSplit.Count() == 3) { id = bpmSplit.ElementAt(0).ParseBase36(); measure = int.Parse(bpmSplit.ElementAt(1)); subDiv = double.Parse(bpmSplit.ElementAt(2)) / 192.0; Metadata.BpmEvents.Add(new BpmChangeEvent(Metadata.BpmIndex[id], beatsPerMeasure * (measure + subDiv))); } else { Console.WriteLine("Failed to parse BPM Change: {0}", line); } } else { // Must have seen the "#NOTES" tag before parsing notes if (Regex.Match(line, "^(#NOTES)").Success) { inNoteData = true; } else if (Regex.Match(line, "^(#ENDNOTES)").Success) { inNoteData = false; } if (inNoteData) { if (Regex.Match(line, "^[0-9]{3}$").Success) { measure = int.Parse(line); } else if (Regex.Match(line, "^[0-9]{3}:").Success) { var timeSplit = Regex.Split(line, ":").Where(s => !String.IsNullOrEmpty(s)); if (timeSplit.Count() == 2) // It should only be 2 { subDiv = double.Parse(timeSplit.ElementAt(0)) / 192.0; var noteSplit = Regex.Split(timeSplit.ElementAt(1), ",").Where(s => !String.IsNullOrEmpty(s)); foreach (var note in noteSplit) { if (Regex.Match(note, "^[2-3]{1}").Success) // Motions { noteClass = note[0].ToString().ParseBase36(); Motions.Add(new Note(beatsPerMeasure * (measure + subDiv), 0, 16, noteClass == 2 ? Motion.Up : Motion.Down)); } else if (Regex.Match(note, "^[0-1]{1}[0-9a-fA-F]{2}$").Success) // Any step { noteClass = note[0].ToString().ParseBase36(); lane = note[1].ToString().ParseBase36(); width = note[2].ToString().ParseBase36() + 1; Steps.Add(new Note(beatsPerMeasure * (measure + subDiv), lane, width, noteClass == 0 ? Side.Left : Side.Right)); } else if (Regex.Match(note, "^[4-9a-bA-B]{1}[0-9a-fA-F]{2}[0-9a-zA-Z]{1}").Success) // Hold/Slides { noteClass = note[0].ToString().ParseBase36(); id = note[1].ToString().ParseBase36(); lane = note[2].ToString().ParseBase36(); width = note[3].ToString().ParseBase36() + 1; switch (noteClass) { case 4: // Left hold start case 5: // Right hold start // Check to see if a hold is already active-- if so, commit it and start a new one if (tempHoldDict.ContainsKey(id)) { CommitHold(tempHoldDict[id]); tempHoldDict.Remove(id); } // Create the new note tempHoldDict.Add(id, new Hold(beatsPerMeasure * (measure + subDiv), lane, width, noteClass == 4 ? Side.Left : Side.Right)); break; case 6: // Slide waypoint // Check to see this slide is still active if (tempHoldDict.ContainsKey(id)) { tempHoldDict[id].AddNote(new Note(beatsPerMeasure * (measure + subDiv), lane, width) { Type = NoteType.Hold }); } else { Console.WriteLine("Corresponding hold/slide for this waypoint is not active. Check file. Line: {0}", line); } break; case 7: // Hold / Slide end // Check to see this hold/slide is still active if (tempHoldDict.ContainsKey(id)) { tempHoldDict[id].AddNote(new Note(beatsPerMeasure * (measure + subDiv), lane, width) { Type = NoteType.Hold }); CommitHold(tempHoldDict[id]); tempHoldDict.Remove(id); } else { Console.WriteLine("Corresponding hold/slide for this endpoint is not active. Check file. Line: {0}", line); } break; case 8: // Simple Shuffle Waypoint // Check to see this hold/slide is still active if (tempHoldDict.ContainsKey(id)) { tempHoldDict[id].AddNote(new Note(beatsPerMeasure * (measure + subDiv), lane, width) { Type = NoteType.Shuffle }); } else { Console.WriteLine("Corresponding hold/slide for this shuffle is not active. Check file. Line: {0}", line); } break; case 9: // Complex Shuffle waypoint // Check to see this hold/slide is still active if (tempHoldDict.ContainsKey(id)) { // Check to see if there's enough parameters if (note.Length == 6) { endLane = note[4].ToString().ParseBase36(); endWidth = note[5].ToString().ParseBase36() + 1; tempHoldDict[id].AddNote(new Note(beatsPerMeasure * (measure + subDiv), lane, width, endLane, endWidth) { Type = NoteType.Shuffle }); } else { Console.WriteLine("Not enough parameters for this complex shuffle. Line: {0}", line); } } else { Console.WriteLine("Corresponding hold/slide for this shuffle is not active. Check file. Line: {0}", line); } break; case 10: // Simple Shuffle End // Check to see this hold/slide is still active if (tempHoldDict.ContainsKey(id)) { tempHoldDict[id].AddNote(new Note(beatsPerMeasure * (measure + subDiv), lane, width) { Type = NoteType.Shuffle }); CommitHold(tempHoldDict[id]); tempHoldDict.Remove(id); } else { Console.WriteLine("Corresponding hold/slide for this shuffle end is not active. Check file. Line: {0}", line); } break; case 11: // Complex shuffle end // Check to see this hold/slide is still active if (tempHoldDict.ContainsKey(id)) { // Check to see if there's enough parameters if (note.Length == 6) { endLane = note[4].ToString().ParseBase36(); endWidth = note[5].ToString().ParseBase36() + 1; tempHoldDict[id].AddNote(new Note(beatsPerMeasure * (measure + subDiv), lane, width, endLane, endWidth) { Type = NoteType.Shuffle }); CommitHold(tempHoldDict[id]); tempHoldDict.Remove(id); } else { Console.WriteLine("Not enough parameters for this complex shuffle end. Line: {0}", line); } } else { Console.WriteLine("Corresponding hold/slide for this shuffle end is not active. Check file. Line: {0}", line); } break; default: break; } } else { Console.WriteLine("Failed to parse note: {0}", line); } } } else { Console.WriteLine("Empty notestring found: {0}", line); } } } } } else if (Metadata.Version.Major == 0) { // Regex match for standard steps if (Regex.Match(line, "[#][0-9]{3}[1]").Success) { var parsed = ParseLine(line); double noteSub = 1.0 / parsed.Notes.Count; for (int i = 0; i < parsed.Notes.Count; i++) { switch (parsed.Notes[i].Item1) { case 1: // Left Step Steps.Add(new Note(4 * (parsed.Measure + i * noteSub), parsed.LaneIndex, parsed.Notes[i].Item2, Side.Left)); break; case 2: // Right Step Steps.Add(new Note(4 * (parsed.Measure + i * noteSub), parsed.LaneIndex, parsed.Notes[i].Item2, Side.Right)); break; case 3: // Motion Up Motions.Add(new Note(4 * (parsed.Measure + i * noteSub), 0, 16, Motion.Up)); break; case 4: // Motion Down Motions.Add(new Note(4 * (parsed.Measure + i * noteSub), 0, 16, Motion.Down)); break; default: // Rest notes / spacers (0) are ignored break; } } } // Regex match for hold/slides else if (Regex.IsMatch(line, "[#][0-9]{3}[2-3]")) { var parsed = ParseLine(line); double noteSub = 1.0 / parsed.Notes.Count; for (int i = 0; i < parsed.Notes.Count; i++) { Side side = parsed.NoteClass == 2 ? Side.Left : Side.Right; switch (parsed.Notes[i].Item1) { case 1: // Start a new note // Check to see if a hold is already active-- if so, commit it and start a new one if (tempSlideDict.ContainsKey(parsed.NoteIdentifier)) { CommitHold(tempSlideDict[parsed.NoteIdentifier]); tempSlideDict.Remove(parsed.NoteIdentifier); } // Create a collection tempSlideDict.Add(parsed.NoteIdentifier, new SlideCollection()); // Add this note to it tempSlideDict[parsed.NoteIdentifier].Notes.Add(new Tuple <NoteParse, int>(parsed, i)); break; case 2: // End a hold note with no shuffle case 3: // End a hold note with a shuffle case 4: // Add a midpoint with no shuffle case 5: // Add a midpoint with a shuffle if (!tempSlideDict.ContainsKey(parsed.NoteIdentifier)) { tempSlideDict.Add(parsed.NoteIdentifier, new SlideCollection()); // Add a new one (it will f**k up shit if this happens) } // Add this note to it tempSlideDict[parsed.NoteIdentifier].Notes.Add(new Tuple <NoteParse, int>(parsed, i)); break; default: // Rest notes / spacers (0) are ignored break; } } } // Parse BPM changes else if (Regex.IsMatch(line, "[#][0-9]{3}(08:)")) { //var parsed = ParseLine(line); var split = line.Replace(" ", string.Empty).Split(':'); var parsed = new NoteParse(); parsed.Measure = Convert.ToDouble(line.Substring(1, 3)); parsed.Notes = new List <Tuple <int, int> >(); for (int i = 0; i < split[1].Length; i += 2) { string idStr = split[1][i].ToString() + split[1][i + 1].ToString(); parsed.Notes.Add(new Tuple <int, int>(idStr.ParseBase36(), 0)); } double noteSub = 1.0 / parsed.Notes.Count; for (int i = 0; i < parsed.Notes.Count; i++) { if (parsed.Notes[i].Item1 == 0) { break; } else { Metadata.BpmEvents.Add(new BpmChangeEvent(Metadata.BpmIndex[parsed.Notes[i].Item1], 4 * (parsed.Measure + i * noteSub))); } } } } } } // Close out any remaining hold notes foreach (var tempHold in tempSlideDict) { CommitHold(tempHold.Value); } // Sort holds for drawing later Holds = Holds.OrderBy(x => x.StartNote.BeatLocation).ToList(); // Add Beat Markers var noteLast = Steps.Count > 0 ? Steps.Max(x => x.BeatLocation) : 0; var holdLast = Holds.Count > 0 ? Holds.Max(x => x.Notes.Max(y => y.BeatLocation)) : 0; var motionLast = Motions.Count > 0 ? Motions.Max(x => x.BeatLocation) : 0; double lastBeat = Math.Max(noteLast, holdLast); lastBeat = Math.Ceiling(Math.Max(lastBeat, motionLast)); for (int i = 0; i <= (int)lastBeat; i += 4) { Markers.Add(new BeatMarker(i)); } TotalNotes += Steps.Count(); TotalNotes += Holds.Count(); foreach (var hold in Holds) { TotalNotes += hold.GradePoints.Count; // Additional beat counters for holds/slides TotalNotes += hold.Notes.Count(x => x.Type == NoteType.Shuffle); } TotalNotes += Motions.Count(); } catch (Exception e) { StyleStarLogger.WriteEntry("Exception in NoteCollection.ParseFile() => Input: " + fileName + ", Exception: " + e.Message + ", Stack Trace: " + e.StackTrace + (e.InnerException != null ? ", Inner Exception: " + e.InnerException.Message : "")); } return(Metadata); }
/// <summary> /// Create a connected point between 2 points with rigidity (motions, rotations) and plastic limits (forces, moments). /// </summary> public ConnectedPoints(FdPoint3d firstPoint, FdPoint3d secondPoint, Motions motions, MotionsPlasticLimits motionsPlasticLimits, Rotations rotations, RotationsPlasticLimits rotationsPlasticLimits, GuidListType[] references, string identifier = "CP") { RigidityDataType2 rigidity = new RigidityDataType2(motions, motionsPlasticLimits, rotations, rotationsPlasticLimits); Initialize(firstPoint, secondPoint, rigidity, references, identifier); }