@@ -38,6 +38,7 @@ public static BBModel Interpret(string fileContent)
3838 Debug ( "Core read, start body..." ) ;
3939 JArray elements = ( JArray ) data [ "elements" ] ;
4040 JArray textures = ( JArray ) data [ "textures" ] ;
41+ JArray outliners = ( JArray ) data [ "outliner" ] ;
4142 JArray animations = ( JArray ) data [ "animations" ] ;
4243 if ( elements is not null )
4344 {
@@ -57,11 +58,12 @@ public static BBModel Interpret(string fileContent)
5758 Name = name ,
5859 Rescale = jElement . GetBool ( "rescale" , false ) ,
5960 Locked = jElement . GetBool ( "locked" , false ) ,
60- From = ParseIVecFromJson ( jElement . GetRequired ( "from" ) ) ,
61- To = ParseIVecFromJson ( jElement . GetRequired ( "to" ) ) ,
61+ From = ParseDVecFromArr ( jElement . GetRequired ( "from" ) ) ,
62+ To = ParseDVecFromArr ( jElement . GetRequired ( "to" ) ) ,
6263 AutoUV = ( int ) jElement . GetRequired ( "autouv" ) ,
6364 Color = ( int ) jElement . GetRequired ( "color" ) ,
64- Origin = ParseIVecFromJson ( jElement . GetRequired ( "origin" ) ) ,
65+ Rotation = jElement . ContainsKey ( "rotation" ) ? ParseDVecFromArr ( jElement . GetRequired ( "rotation" ) ) : new DoubleVector ( ) ,
66+ Origin = ParseDVecFromArr ( jElement . GetRequired ( "origin" ) ) ,
6567 North = ParseFaceFromJson ( jFaces . GetRequired ( "north" ) ) ,
6668 South = ParseFaceFromJson ( jFaces . GetRequired ( "south" ) ) ,
6769 East = ParseFaceFromJson ( jFaces . GetRequired ( "east" ) ) ,
@@ -103,6 +105,14 @@ public static BBModel Interpret(string fileContent)
103105 result . Textures . Add ( texture ) ;
104106 }
105107 }
108+ if ( outliners is not null )
109+ {
110+ Debug ( "contains outliners" ) ;
111+ foreach ( JObject jOutliner in outliners )
112+ {
113+ ReadOutliner ( result , jOutliner ) ;
114+ }
115+ }
106116 if ( animations is not null )
107117 {
108118 Debug ( "Contains animations" ) ;
@@ -133,7 +143,7 @@ public static BBModel Interpret(string fileContent)
133143 BBModel . Animation . Keyframe keyframe = new ( )
134144 {
135145 Channel = jFrame . GetRequiredEnum < BBModel . Animation . Keyframe . ChannelType > ( "channel" ) ,
136- DataPoint = ParseDVecFromJson ( jFrame . GetRequired ( "data_points" ) . First ) ,
146+ DataPoint = ParseDVecFromObj ( jFrame . GetRequired ( "data_points" ) . First ) ,
137147 UUID = Guid . Parse ( ( string ) jFrame . GetRequired ( "uuid" ) ) ,
138148 Time = ( double ) jFrame . GetRequired ( "time" ) ,
139149 Color = ( int ) jFrame . GetRequired ( "color" ) ,
@@ -150,16 +160,43 @@ public static BBModel Interpret(string fileContent)
150160 return result ;
151161 }
152162
153- public static DoubleVector ParseDVecFromJson ( JToken jVal )
163+ public static BBModel . Outliner ReadOutliner ( BBModel model , JObject jOutliner )
164+ {
165+ BBModel . Outliner outline = new ( )
166+ {
167+ Name = ( string ) jOutliner . GetRequired ( "name" ) ,
168+ Origin = ParseDVecFromArr ( jOutliner . GetRequired ( "origin" ) ) ,
169+ UUID = Guid . Parse ( ( string ) jOutliner . GetRequired ( "uuid" ) ) ,
170+ // Ignore ik_enabled, ik_chain_length, export, isOpen, locked, visibility, autouv
171+ } ;
172+ foreach ( JToken child in ( JArray ) jOutliner . GetRequired ( "children" ) )
173+ {
174+ if ( child . Type == JTokenType . String )
175+ {
176+ outline . Children . Add ( Guid . Parse ( ( string ) child ) ) ;
177+ }
178+ else
179+ {
180+ BBModel . Outliner subLine = ReadOutliner ( model , ( JObject ) child ) ;
181+ outline . Paired . Add ( subLine . UUID ) ;
182+ outline . Paired . AddRange ( subLine . Paired ) ;
183+ }
184+ }
185+ Debug ( $ "Read outliner { outline . Name } ") ;
186+ model . Outlines . Add ( outline ) ;
187+ return outline ;
188+ }
189+
190+ public static DoubleVector ParseDVecFromObj ( JToken jVal )
154191 {
155192 JObject jObj = ( JObject ) jVal ;
156193 return new DoubleVector ( ( double ) jObj . GetRequired ( "x" ) , ( double ) jObj . GetRequired ( "y" ) , ( double ) jObj . GetRequired ( "z" ) ) ;
157194 }
158195
159- public static IntegerVector ParseIVecFromJson ( JToken jVal )
196+ public static DoubleVector ParseDVecFromArr ( JToken jVal )
160197 {
161198 JArray jArr = ( JArray ) jVal ;
162- return new IntegerVector ( ( int ) jArr [ 0 ] , ( int ) jArr [ 1 ] , ( int ) jArr [ 2 ] ) ;
199+ return new DoubleVector ( ( int ) jArr [ 0 ] , ( int ) jArr [ 1 ] , ( int ) jArr [ 2 ] ) ;
163200 }
164201
165202 public static BBModel . Element . Face ParseFaceFromJson ( JToken jVal )
0 commit comments