Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SMD to CHR0 Importing #19

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RedStoneMatt
Copy link

It's not perfect, but from what i tested, it works.
Note that SMD Animation files don't support scale editing.
If you make your tests with Blender-exported SMD Animation files, keep it mind blender breaks these sometimes.

I just hope i didn't forget any file :c
@soopercool101
Copy link
Owner

Codacy Here is an overview of what got changed by this pull request:

Issues
======
- Added 5
           

Complexity increasing per file
==============================
- BrawlLib/Wii/Animations/CHR0SMDImporter.cs  13
         

See the complete overview on Codacy

@soopercool101
Copy link
Owner

You should be using Equals() (likely with StringComparison.OrdinalIgnoreCase) rather than CompareTo(). Fix this and I'll merge.

int currentFrameID = new int();
float radianFloat = 57.29579143313326f; //Angles are given in radians. To convert them into degrees, multiply them by this float.
List<SMDFrame> allFrames = new List<SMDFrame>();
for (TextReader reader = new StreamReader(input); reader.Peek() != -1;) //Writing data into Lists
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lineNumber should be incremented in the for loop declaration, or this should be changed to a while loop


if (lineNumber == 0) //First Line
{
if (line.CompareTo("version 1") != 0) //The first line contains the version number. It needs to be 1.
Copy link
Owner

@soopercool101 soopercool101 Jul 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use !line.Equals("version 1", StringComparison.OrdinalIgnoreCase)

}
}

if (line.CompareTo("nodes") == 0) //When reaching this line, we start reading bones names
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use line.Equals("nodes", StringComparison.OrdinalIgnoreCase)

isReadingBones = true;
}

if (line.CompareTo("skeleton") == 0) //When reaching this line, we start reading frames
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use line.Equals("skeleton", StringComparison.OrdinalIgnoreCase)

}

chr0.FrameCount = keynum;
chr0.Loop = true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be set repeatedly. Set it in the declaration (you currently set it to false there)

}
}

chr0.FrameCount = keynum;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't repeatedly set FrameCount, unless you have checks in place to prevent the animation from shrinking

{
string line = reader.ReadLine();

if (line.CompareTo("end") == 0) //When reaching this line, we stop reading what we were reading
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use line.Equals("end", StringComparison.OrdinalIgnoreCase)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants