Skip to content

Commit

Permalink
Added .bsx Star Grain importer
Browse files Browse the repository at this point in the history
OpenMotor now supports Star Grains from Burn Sim.
  • Loading branch information
AstroChuck committed Dec 27, 2024
1 parent 7713aaa commit 28fea38
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion uilib/converters/burnsimImporter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import xml.etree.ElementTree as ET

import motorlib
from numpy import pi, cos

from ..converter import Importer

Expand All @@ -9,14 +10,14 @@
'1': motorlib.grains.BatesGrain,
'2': motorlib.grains.DGrain,
'3': motorlib.grains.MoonBurner,
'4': motorlib.grains.StarGrain,
'5': motorlib.grains.CGrain,
'6': motorlib.grains.XCore,
'7': motorlib.grains.Finocyl
}

# BS type -> label for grains we know about but can't import
UNSUPPORTED_GRAINS = {
'4': 'Star',
'8': 'Tablet',
'9': 'Pie Segment'
}
Expand Down Expand Up @@ -93,6 +94,16 @@ def doConversion(self, path):

elif grainType == '3': # Moonburner specific properties
motor.grains[-1].setProperty('coreOffset', inToM(child.attrib['CoreOffset']))

elif grainType == '4': #Star Grain:
numPoints = int(child.attrib['Points'])
minorRadius = float(child.attrib['MinorWidth'])/2
majorRadius = float(child.attrib['MajorWidth'])/2
base_length = minorRadius * (2-(2*cos((2*pi)/numPoints)))**.5
point_height = majorRadius - (minorRadius*cos(pi/numPoints))
motor.grains[-1].setProperty('numPoints', numPoints)
motor.grains[-1].setProperty('pointLength', inToM(point_height))
motor.grains[-1].setProperty('pointWidth', inToM(base_length))

elif grainType == '5': # C grain specific properties
motor.grains[-1].setProperty('slotWidth', inToM(child.attrib['SlotWidth']))
Expand Down

0 comments on commit 28fea38

Please sign in to comment.