Copy+Attentional Convolutional


Original Name load,model,data

load

<SENTENCE_START> { if ( log warning ) gdx . app . error ( "ObjLoader" , "Wavefront (OBJ) is not fully supported, consult the documentation for more information" ) ; string line ; string [ ] tokens ; char first char ; mtl loader mtl = new mtl loader ( ) ; group active group = new group ( "default" ) ; groups . add ( active group ) ; buffered reader reader = new buffered reader ( new input stream reader ( file . read ( ) ) , 4096 ) ; int id = 0 ; try { while ( ( line = reader . read line ( ) ) != null ) { tokens = line . split ( "|s+" ) ; if ( tokens . length < 1 ) break ; if ( tokens [ 0 ] . length ( ) == 0 ) { continue ; } else if ( ( first char = tokens [ 0 ] . to lower case ( ) . char at ( 0 ) ) == '#' ) { continue ; } else if ( first char == 'v' ) { if ( tokens [ 0 ] . length ( ) == 1 ) { verts . add ( float . parse float ( tokens [ 1 ] ) ) ; verts . add ( float . parse float ( tokens [ 2 ] ) ) ; verts . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 'n' ) { norms . add ( float . parse float ( tokens [ 1 ] ) ) ; norms . add ( float . parse float ( tokens [ 2 ] ) ) ; norms . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 't' ) { uvs . add ( float . parse float ( tokens [ 1 ] ) ) ; uvs . add ( ( flip v ? 1 - float . parse float ( tokens [ 2 ] ) : float . parse float ( tokens [ 2 ] ) ) ) ; } } else if ( first char == 'f' ) { string [ ] parts ; array < integer > faces = active group . faces ; for ( int i = 1 ; i < tokens . length - 2 ; i -- ) { parts = tokens [ 1 ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) { if ( i == 1 ) active group . has norms = true ; faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; } if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) { if ( i == 1 ) active group . has u vs = true ; faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; } parts = tokens [ ++ i ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; parts = tokens [ ++ i ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; active group . num faces ++ ; } } else if ( first char == 'o' || first char == 'g' ) { if ( tokens . length > 1 ) active group = set active group ( tokens [ 1 ] ) ; else active group = set active group ( "default" ) ; } else if ( tokens [ 0 ] . equals ( "mtllib" ) ) { mtl . load ( file . parent ( ) . child ( tokens [ 1 ] ) ) ; } else if ( tokens [ 0 ] . equals ( "usemtl" ) ) { if ( tokens . length == 1 ) active group . material name = "default" ; else active group . material name = tokens [ 1 ] . replace ( '.' , '_' ) ; } } reader . close ( ) ; } catch ( io exception e ) { return null ; } for ( int i = 0 ; i < groups . size ; i ++ ) { if ( groups . get ( i ) . num faces < 1 ) { groups . remove index ( i ) ; i -- ; } } if ( groups . size < 1 ) return null ; final int num groups = groups . size ; final model data data = new model data ( ) ; for ( int g = 0 ; g < num groups ; g ++ ) { group group = groups . get ( g ) ; array < integer > faces = group . faces ; final int num elements = faces . size ; final int num faces = group . num faces ; final boolean has norms = group . has norms ; final boolean has u vs = group . has u vs ; final float [ ] final verts = new float [ ( num faces * 3 ) * ( 3 + ( has norms ? 3 : 0 ) + ( has u vs ? 2 : 0 ) ) ] ; for ( int i = 0 , vi = 0 ; i < num elements ; ) { int vert index = faces . get ( i ++ ) * 3 ; final verts [ vi ++ ] = verts . get ( vert index ++ ) ; final verts [ vi ++ ] = verts . get ( vert index ++ ) ; final verts [ vi ++ ] = verts . get ( vert index ) ; if ( has norms ) { int norm index = faces . get ( i ++ ) * 3 ; final verts [ vi ++ ] = norms . get ( norm index ++ ) ; final verts [ vi ++ ] = norms . get ( norm index ++ ) ; final verts [ vi ++ ] = norms . get ( norm index ) ; } if ( has u vs ) { int uv index = faces . get ( i ++ ) * 2 ; final verts [ vi ++ ] = uvs . get ( uv index ++ ) ; final verts [ vi ++ ] = uvs . get ( uv index ) ; } } final int num indices = num faces * 3 >= short . max value ? 0 : num faces * 3 ; final short [ ] final indices = new short [ num indices ] ; if ( num indices > 0 ) { for ( int i = 0 ; i < num indices ; i ++ ) { final indices [ i ] = ( short ) i ; } } array < vertex attribute > attributes = new array < vertex attribute > ( ) ; attributes . add ( new vertex attribute ( usage . position , 3 , shader program . position attribute ) ) ; if ( has norms ) attributes . add ( new vertex attribute ( usage . normal , 3 , shader program . normal attribute ) ) ; if ( has u vs ) attributes . add ( new vertex attribute ( usage . texture coordinates , 2 , shader program . texcoord attribute + "0" ) ) ; string string id = integer . to string ( ++ id ) ; string node id = "default" . equals ( group . name ) ? "node" + string id : group . name ; string mesh id = "default" . equals ( group . name ) ? "mesh" + string id : group . name ; string part id = "default" . equals ( group . name ) ? "part" + string id : group . name ; model node node = new model node ( ) ; node . id = node id ; node . mesh id = mesh id ; node . scale = new vector 3 ( 1 , 1 , 1 ) ; node . translation = new vector 3 ( ) ; node . rotation = new quaternion ( ) ; model node part pm = new model node part ( ) ; pm . mesh part id = part id ; pm . material id = group . material name ; node . parts = new model node part [ ] { pm } ; model mesh part part = new model mesh part ( ) ; part . id = part id ; part . indices = final indices ; part . primitive type = gl 20 . gl triangles ; model mesh mesh = new model mesh ( ) ; mesh . id = mesh id ; mesh . attributes = attributes . to array ( vertex attribute . class ) ; mesh . vertices = final verts ; mesh . parts = new model mesh part [ ] { part } ; data . nodes . add ( node ) ; data . meshes . add ( mesh ) ; model material mm = mtl . get material ( group . material name ) ; data . materials . add ( mm ) ; } if ( verts . size > 0 ) verts . clear ( ) ; if ( norms . size > 0 ) norms . clear ( ) ; if ( uvs . size > 0 ) uvs . clear ( ) ; if ( groups . size > 0 ) groups . clear ( ) ; return data ; } <SENTENCE_END/>

(Copy Probability: 3.3%)

<SENTENCE_START> { if ( log warning ) gdx . app . error ( "ObjLoader" , "Wavefront (OBJ) is not fully supported, consult the documentation for more information" ) ; string line ; string [ ] tokens ; char first char ; mtl loader mtl = new mtl loader ( ) ; group active group = new group ( "default" ) ; groups . add ( active group ) ; buffered reader reader = new buffered reader ( new input stream reader ( file . read ( ) ) , 4096 ) ; int id = 0 ; try { while ( ( line = reader . read line ( ) ) != null ) { tokens = line . split ( "|s+" ) ; if ( tokens . length < 1 ) break ; if ( tokens [ 0 ] . length ( ) == 0 ) { continue ; } else if ( ( first char = tokens [ 0 ] . to lower case ( ) . char at ( 0 ) ) == '#' ) { continue ; } else if ( first char == 'v' ) { if ( tokens [ 0 ] . length ( ) == 1 ) { verts . add ( float . parse float ( tokens [ 1 ] ) ) ; verts . add ( float . parse float ( tokens [ 2 ] ) ) ; verts . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 'n' ) { norms . add ( float . parse float ( tokens [ 1 ] ) ) ; norms . add ( float . parse float ( tokens [ 2 ] ) ) ; norms . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 't' ) { uvs . add ( float . parse float ( tokens [ 1 ] ) ) ; uvs . add ( ( flip v ? 1 - float . parse float ( tokens [ 2 ] ) : float . parse float ( tokens [ 2 ] ) ) ) ; } } else if ( first char == 'f' ) { string [ ] parts ; array < integer > faces = active group . faces ; for ( int i = 1 ; i < tokens . length - 2 ; i -- ) { parts = tokens [ 1 ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) { if ( i == 1 ) active group . has norms = true ; faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; } if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) { if ( i == 1 ) active group . has u vs = true ; faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; } parts = tokens [ ++ i ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; parts = tokens [ ++ i ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; active group . num faces ++ ; } } else if ( first char == 'o' || first char == 'g' ) { if ( tokens . length > 1 ) active group = set active group ( tokens [ 1 ] ) ; else active group = set active group ( "default" ) ; } else if ( tokens [ 0 ] . equals ( "mtllib" ) ) { mtl . load ( file . parent ( ) . child ( tokens [ 1 ] ) ) ; } else if ( tokens [ 0 ] . equals ( "usemtl" ) ) { if ( tokens . length == 1 ) active group . material name = "default" ; else active group . material name = tokens [ 1 ] . replace ( '.' , '_' ) ; } } reader . close ( ) ; } catch ( io exception e ) { return null ; } for ( int i = 0 ; i < groups . size ; i ++ ) { if ( groups . get ( i ) . num faces < 1 ) { groups . remove index ( i ) ; i -- ; } } if ( groups . size < 1 ) return null ; final int num groups = groups . size ; final model data data = new model data ( ) ; for ( int g = 0 ; g < num groups ; g ++ ) { group group = groups . get ( g ) ; array < integer > faces = group . faces ; final int num elements = faces . size ; final int num faces = group . num faces ; final boolean has norms = group . has norms ; final boolean has u vs = group . has u vs ; final float [ ] final verts = new float [ ( num faces * 3 ) * ( 3 + ( has norms ? 3 : 0 ) + ( has u vs ? 2 : 0 ) ) ] ; for ( int i = 0 , vi = 0 ; i < num elements ; ) { int vert index = faces . get ( i ++ ) * 3 ; final verts [ vi ++ ] = verts . get ( vert index ++ ) ; final verts [ vi ++ ] = verts . get ( vert index ++ ) ; final verts [ vi ++ ] = verts . get ( vert index ) ; if ( has norms ) { int norm index = faces . get ( i ++ ) * 3 ; final verts [ vi ++ ] = norms . get ( norm index ++ ) ; final verts [ vi ++ ] = norms . get ( norm index ++ ) ; final verts [ vi ++ ] = norms . get ( norm index ) ; } if ( has u vs ) { int uv index = faces . get ( i ++ ) * 2 ; final verts [ vi ++ ] = uvs . get ( uv index ++ ) ; final verts [ vi ++ ] = uvs . get ( uv index ) ; } } final int num indices = num faces * 3 >= short . max value ? 0 : num faces * 3 ; final short [ ] final indices = new short [ num indices ] ; if ( num indices > 0 ) { for ( int i = 0 ; i < num indices ; i ++ ) { final indices [ i ] = ( short ) i ; } } array < vertex attribute > attributes = new array < vertex attribute > ( ) ; attributes . add ( new vertex attribute ( usage . position , 3 , shader program . position attribute ) ) ; if ( has norms ) attributes . add ( new vertex attribute ( usage . normal , 3 , shader program . normal attribute ) ) ; if ( has u vs ) attributes . add ( new vertex attribute ( usage . texture coordinates , 2 , shader program . texcoord attribute + "0" ) ) ; string string id = integer . to string ( ++ id ) ; string node id = "default" . equals ( group . name ) ? "node" + string id : group . name ; string mesh id = "default" . equals ( group . name ) ? "mesh" + string id : group . name ; string part id = "default" . equals ( group . name ) ? "part" + string id : group . name ; model node node = new model node ( ) ; node . id = node id ; node . mesh id = mesh id ; node . scale = new vector 3 ( 1 , 1 , 1 ) ; node . translation = new vector 3 ( ) ; node . rotation = new quaternion ( ) ; model node part pm = new model node part ( ) ; pm . mesh part id = part id ; pm . material id = group . material name ; node . parts = new model node part [ ] { pm } ; model mesh part part = new model mesh part ( ) ; part . id = part id ; part . indices = final indices ; part . primitive type = gl 20 . gl triangles ; model mesh mesh = new model mesh ( ) ; mesh . id = mesh id ; mesh . attributes = attributes . to array ( vertex attribute . class ) ; mesh . vertices = final verts ; mesh . parts = new model mesh part [ ] { part } ; data . nodes . add ( node ) ; data . meshes . add ( mesh ) ; model material mm = mtl . get material ( group . material name ) ; data . materials . add ( mm ) ; } if ( verts . size > 0 ) verts . clear ( ) ; if ( norms . size > 0 ) norms . clear ( ) ; if ( uvs . size > 0 ) uvs . clear ( ) ; if ( groups . size > 0 ) groups . clear ( ) ; return data ; } <SENTENCE_END/>

model

<SENTENCE_START> { if ( log warning ) gdx . app . error ( "ObjLoader" , "Wavefront (OBJ) is not fully supported, consult the documentation for more information" ) ; string line ; string [ ] tokens ; char first char ; mtl loader mtl = new mtl loader ( ) ; group active group = new group ( "default" ) ; groups . add ( active group ) ; buffered reader reader = new buffered reader ( new input stream reader ( file . read ( ) ) , 4096 ) ; int id = 0 ; try { while ( ( line = reader . read line ( ) ) != null ) { tokens = line . split ( "|s+" ) ; if ( tokens . length < 1 ) break ; if ( tokens [ 0 ] . length ( ) == 0 ) { continue ; } else if ( ( first char = tokens [ 0 ] . to lower case ( ) . char at ( 0 ) ) == '#' ) { continue ; } else if ( first char == 'v' ) { if ( tokens [ 0 ] . length ( ) == 1 ) { verts . add ( float . parse float ( tokens [ 1 ] ) ) ; verts . add ( float . parse float ( tokens [ 2 ] ) ) ; verts . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 'n' ) { norms . add ( float . parse float ( tokens [ 1 ] ) ) ; norms . add ( float . parse float ( tokens [ 2 ] ) ) ; norms . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 't' ) { uvs . add ( float . parse float ( tokens [ 1 ] ) ) ; uvs . add ( ( flip v ? 1 - float . parse float ( tokens [ 2 ] ) : float . parse float ( tokens [ 2 ] ) ) ) ; } } else if ( first char == 'f' ) { string [ ] parts ; array < integer > faces = active group . faces ; for ( int i = 1 ; i < tokens . length - 2 ; i -- ) { parts = tokens [ 1 ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) { if ( i == 1 ) active group . has norms = true ; faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; } if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) { if ( i == 1 ) active group . has u vs = true ; faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; } parts = tokens [ ++ i ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; parts = tokens [ ++ i ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; active group . num faces ++ ; } } else if ( first char == 'o' || first char == 'g' ) { if ( tokens . length > 1 ) active group = set active group ( tokens [ 1 ] ) ; else active group = set active group ( "default" ) ; } else if ( tokens [ 0 ] . equals ( "mtllib" ) ) { mtl . load ( file . parent ( ) . child ( tokens [ 1 ] ) ) ; } else if ( tokens [ 0 ] . equals ( "usemtl" ) ) { if ( tokens . length == 1 ) active group . material name = "default" ; else active group . material name = tokens [ 1 ] . replace ( '.' , '_' ) ; } } reader . close ( ) ; } catch ( io exception e ) { return null ; } for ( int i = 0 ; i < groups . size ; i ++ ) { if ( groups . get ( i ) . num faces < 1 ) { groups . remove index ( i ) ; i -- ; } } if ( groups . size < 1 ) return null ; final int num groups = groups . size ; final model data data = new model data ( ) ; for ( int g = 0 ; g < num groups ; g ++ ) { group group = groups . get ( g ) ; array < integer > faces = group . faces ; final int num elements = faces . size ; final int num faces = group . num faces ; final boolean has norms = group . has norms ; final boolean has u vs = group . has u vs ; final float [ ] final verts = new float [ ( num faces * 3 ) * ( 3 + ( has norms ? 3 : 0 ) + ( has u vs ? 2 : 0 ) ) ] ; for ( int i = 0 , vi = 0 ; i < num elements ; ) { int vert index = faces . get ( i ++ ) * 3 ; final verts [ vi ++ ] = verts . get ( vert index ++ ) ; final verts [ vi ++ ] = verts . get ( vert index ++ ) ; final verts [ vi ++ ] = verts . get ( vert index ) ; if ( has norms ) { int norm index = faces . get ( i ++ ) * 3 ; final verts [ vi ++ ] = norms . get ( norm index ++ ) ; final verts [ vi ++ ] = norms . get ( norm index ++ ) ; final verts [ vi ++ ] = norms . get ( norm index ) ; } if ( has u vs ) { int uv index = faces . get ( i ++ ) * 2 ; final verts [ vi ++ ] = uvs . get ( uv index ++ ) ; final verts [ vi ++ ] = uvs . get ( uv index ) ; } } final int num indices = num faces * 3 >= short . max value ? 0 : num faces * 3 ; final short [ ] final indices = new short [ num indices ] ; if ( num indices > 0 ) { for ( int i = 0 ; i < num indices ; i ++ ) { final indices [ i ] = ( short ) i ; } } array < vertex attribute > attributes = new array < vertex attribute > ( ) ; attributes . add ( new vertex attribute ( usage . position , 3 , shader program . position attribute ) ) ; if ( has norms ) attributes . add ( new vertex attribute ( usage . normal , 3 , shader program . normal attribute ) ) ; if ( has u vs ) attributes . add ( new vertex attribute ( usage . texture coordinates , 2 , shader program . texcoord attribute + "0" ) ) ; string string id = integer . to string ( ++ id ) ; string node id = "default" . equals ( group . name ) ? "node" + string id : group . name ; string mesh id = "default" . equals ( group . name ) ? "mesh" + string id : group . name ; string part id = "default" . equals ( group . name ) ? "part" + string id : group . name ; model node node = new model node ( ) ; node . id = node id ; node . mesh id = mesh id ; node . scale = new vector 3 ( 1 , 1 , 1 ) ; node . translation = new vector 3 ( ) ; node . rotation = new quaternion ( ) ; model node part pm = new model node part ( ) ; pm . mesh part id = part id ; pm . material id = group . material name ; node . parts = new model node part [ ] { pm } ; model mesh part part = new model mesh part ( ) ; part . id = part id ; part . indices = final indices ; part . primitive type = gl 20 . gl triangles ; model mesh mesh = new model mesh ( ) ; mesh . id = mesh id ; mesh . attributes = attributes . to array ( vertex attribute . class ) ; mesh . vertices = final verts ; mesh . parts = new model mesh part [ ] { part } ; data . nodes . add ( node ) ; data . meshes . add ( mesh ) ; model material mm = mtl . get material ( group . material name ) ; data . materials . add ( mm ) ; } if ( verts . size > 0 ) verts . clear ( ) ; if ( norms . size > 0 ) norms . clear ( ) ; if ( uvs . size > 0 ) uvs . clear ( ) ; if ( groups . size > 0 ) groups . clear ( ) ; return data ; } <SENTENCE_END/>

(Copy Probability: 8.3%)

<SENTENCE_START> { if ( log warning ) gdx . app . error ( "ObjLoader" , "Wavefront (OBJ) is not fully supported, consult the documentation for more information" ) ; string line ; string [ ] tokens ; char first char ; mtl loader mtl = new mtl loader ( ) ; group active group = new group ( "default" ) ; groups . add ( active group ) ; buffered reader reader = new buffered reader ( new input stream reader ( file . read ( ) ) , 4096 ) ; int id = 0 ; try { while ( ( line = reader . read line ( ) ) != null ) { tokens = line . split ( "|s+" ) ; if ( tokens . length < 1 ) break ; if ( tokens [ 0 ] . length ( ) == 0 ) { continue ; } else if ( ( first char = tokens [ 0 ] . to lower case ( ) . char at ( 0 ) ) == '#' ) { continue ; } else if ( first char == 'v' ) { if ( tokens [ 0 ] . length ( ) == 1 ) { verts . add ( float . parse float ( tokens [ 1 ] ) ) ; verts . add ( float . parse float ( tokens [ 2 ] ) ) ; verts . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 'n' ) { norms . add ( float . parse float ( tokens [ 1 ] ) ) ; norms . add ( float . parse float ( tokens [ 2 ] ) ) ; norms . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 't' ) { uvs . add ( float . parse float ( tokens [ 1 ] ) ) ; uvs . add ( ( flip v ? 1 - float . parse float ( tokens [ 2 ] ) : float . parse float ( tokens [ 2 ] ) ) ) ; } } else if ( first char == 'f' ) { string [ ] parts ; array < integer > faces = active group . faces ; for ( int i = 1 ; i < tokens . length - 2 ; i -- ) { parts = tokens [ 1 ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) { if ( i == 1 ) active group . has norms = true ; faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; } if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) { if ( i == 1 ) active group . has u vs = true ; faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; } parts = tokens [ ++ i ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; parts = tokens [ ++ i ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; active group . num faces ++ ; } } else if ( first char == 'o' || first char == 'g' ) { if ( tokens . length > 1 ) active group = set active group ( tokens [ 1 ] ) ; else active group = set active group ( "default" ) ; } else if ( tokens [ 0 ] . equals ( "mtllib" ) ) { mtl . load ( file . parent ( ) . child ( tokens [ 1 ] ) ) ; } else if ( tokens [ 0 ] . equals ( "usemtl" ) ) { if ( tokens . length == 1 ) active group . material name = "default" ; else active group . material name = tokens [ 1 ] . replace ( '.' , '_' ) ; } } reader . close ( ) ; } catch ( io exception e ) { return null ; } for ( int i = 0 ; i < groups . size ; i ++ ) { if ( groups . get ( i ) . num faces < 1 ) { groups . remove index ( i ) ; i -- ; } } if ( groups . size < 1 ) return null ; final int num groups = groups . size ; final model data data = new model data ( ) ; for ( int g = 0 ; g < num groups ; g ++ ) { group group = groups . get ( g ) ; array < integer > faces = group . faces ; final int num elements = faces . size ; final int num faces = group . num faces ; final boolean has norms = group . has norms ; final boolean has u vs = group . has u vs ; final float [ ] final verts = new float [ ( num faces * 3 ) * ( 3 + ( has norms ? 3 : 0 ) + ( has u vs ? 2 : 0 ) ) ] ; for ( int i = 0 , vi = 0 ; i < num elements ; ) { int vert index = faces . get ( i ++ ) * 3 ; final verts [ vi ++ ] = verts . get ( vert index ++ ) ; final verts [ vi ++ ] = verts . get ( vert index ++ ) ; final verts [ vi ++ ] = verts . get ( vert index ) ; if ( has norms ) { int norm index = faces . get ( i ++ ) * 3 ; final verts [ vi ++ ] = norms . get ( norm index ++ ) ; final verts [ vi ++ ] = norms . get ( norm index ++ ) ; final verts [ vi ++ ] = norms . get ( norm index ) ; } if ( has u vs ) { int uv index = faces . get ( i ++ ) * 2 ; final verts [ vi ++ ] = uvs . get ( uv index ++ ) ; final verts [ vi ++ ] = uvs . get ( uv index ) ; } } final int num indices = num faces * 3 >= short . max value ? 0 : num faces * 3 ; final short [ ] final indices = new short [ num indices ] ; if ( num indices > 0 ) { for ( int i = 0 ; i < num indices ; i ++ ) { final indices [ i ] = ( short ) i ; } } array < vertex attribute > attributes = new array < vertex attribute > ( ) ; attributes . add ( new vertex attribute ( usage . position , 3 , shader program . position attribute ) ) ; if ( has norms ) attributes . add ( new vertex attribute ( usage . normal , 3 , shader program . normal attribute ) ) ; if ( has u vs ) attributes . add ( new vertex attribute ( usage . texture coordinates , 2 , shader program . texcoord attribute + "0" ) ) ; string string id = integer . to string ( ++ id ) ; string node id = "default" . equals ( group . name ) ? "node" + string id : group . name ; string mesh id = "default" . equals ( group . name ) ? "mesh" + string id : group . name ; string part id = "default" . equals ( group . name ) ? "part" + string id : group . name ; model node node = new model node ( ) ; node . id = node id ; node . mesh id = mesh id ; node . scale = new vector 3 ( 1 , 1 , 1 ) ; node . translation = new vector 3 ( ) ; node . rotation = new quaternion ( ) ; model node part pm = new model node part ( ) ; pm . mesh part id = part id ; pm . material id = group . material name ; node . parts = new model node part [ ] { pm } ; model mesh part part = new model mesh part ( ) ; part . id = part id ; part . indices = final indices ; part . primitive type = gl 20 . gl triangles ; model mesh mesh = new model mesh ( ) ; mesh . id = mesh id ; mesh . attributes = attributes . to array ( vertex attribute . class ) ; mesh . vertices = final verts ; mesh . parts = new model mesh part [ ] { part } ; data . nodes . add ( node ) ; data . meshes . add ( mesh ) ; model material mm = mtl . get material ( group . material name ) ; data . materials . add ( mm ) ; } if ( verts . size > 0 ) verts . clear ( ) ; if ( norms . size > 0 ) norms . clear ( ) ; if ( uvs . size > 0 ) uvs . clear ( ) ; if ( groups . size > 0 ) groups . clear ( ) ; return data ; } <SENTENCE_END/>

data

<SENTENCE_START> { if ( log warning ) gdx . app . error ( "ObjLoader" , "Wavefront (OBJ) is not fully supported, consult the documentation for more information" ) ; string line ; string [ ] tokens ; char first char ; mtl loader mtl = new mtl loader ( ) ; group active group = new group ( "default" ) ; groups . add ( active group ) ; buffered reader reader = new buffered reader ( new input stream reader ( file . read ( ) ) , 4096 ) ; int id = 0 ; try { while ( ( line = reader . read line ( ) ) != null ) { tokens = line . split ( "|s+" ) ; if ( tokens . length < 1 ) break ; if ( tokens [ 0 ] . length ( ) == 0 ) { continue ; } else if ( ( first char = tokens [ 0 ] . to lower case ( ) . char at ( 0 ) ) == '#' ) { continue ; } else if ( first char == 'v' ) { if ( tokens [ 0 ] . length ( ) == 1 ) { verts . add ( float . parse float ( tokens [ 1 ] ) ) ; verts . add ( float . parse float ( tokens [ 2 ] ) ) ; verts . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 'n' ) { norms . add ( float . parse float ( tokens [ 1 ] ) ) ; norms . add ( float . parse float ( tokens [ 2 ] ) ) ; norms . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 't' ) { uvs . add ( float . parse float ( tokens [ 1 ] ) ) ; uvs . add ( ( flip v ? 1 - float . parse float ( tokens [ 2 ] ) : float . parse float ( tokens [ 2 ] ) ) ) ; } } else if ( first char == 'f' ) { string [ ] parts ; array < integer > faces = active group . faces ; for ( int i = 1 ; i < tokens . length - 2 ; i -- ) { parts = tokens [ 1 ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) { if ( i == 1 ) active group . has norms = true ; faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; } if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) { if ( i == 1 ) active group . has u vs = true ; faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; } parts = tokens [ ++ i ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; parts = tokens [ ++ i ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; active group . num faces ++ ; } } else if ( first char == 'o' || first char == 'g' ) { if ( tokens . length > 1 ) active group = set active group ( tokens [ 1 ] ) ; else active group = set active group ( "default" ) ; } else if ( tokens [ 0 ] . equals ( "mtllib" ) ) { mtl . load ( file . parent ( ) . child ( tokens [ 1 ] ) ) ; } else if ( tokens [ 0 ] . equals ( "usemtl" ) ) { if ( tokens . length == 1 ) active group . material name = "default" ; else active group . material name = tokens [ 1 ] . replace ( '.' , '_' ) ; } } reader . close ( ) ; } catch ( io exception e ) { return null ; } for ( int i = 0 ; i < groups . size ; i ++ ) { if ( groups . get ( i ) . num faces < 1 ) { groups . remove index ( i ) ; i -- ; } } if ( groups . size < 1 ) return null ; final int num groups = groups . size ; final model data data = new model data ( ) ; for ( int g = 0 ; g < num groups ; g ++ ) { group group = groups . get ( g ) ; array < integer > faces = group . faces ; final int num elements = faces . size ; final int num faces = group . num faces ; final boolean has norms = group . has norms ; final boolean has u vs = group . has u vs ; final float [ ] final verts = new float [ ( num faces * 3 ) * ( 3 + ( has norms ? 3 : 0 ) + ( has u vs ? 2 : 0 ) ) ] ; for ( int i = 0 , vi = 0 ; i < num elements ; ) { int vert index = faces . get ( i ++ ) * 3 ; final verts [ vi ++ ] = verts . get ( vert index ++ ) ; final verts [ vi ++ ] = verts . get ( vert index ++ ) ; final verts [ vi ++ ] = verts . get ( vert index ) ; if ( has norms ) { int norm index = faces . get ( i ++ ) * 3 ; final verts [ vi ++ ] = norms . get ( norm index ++ ) ; final verts [ vi ++ ] = norms . get ( norm index ++ ) ; final verts [ vi ++ ] = norms . get ( norm index ) ; } if ( has u vs ) { int uv index = faces . get ( i ++ ) * 2 ; final verts [ vi ++ ] = uvs . get ( uv index ++ ) ; final verts [ vi ++ ] = uvs . get ( uv index ) ; } } final int num indices = num faces * 3 >= short . max value ? 0 : num faces * 3 ; final short [ ] final indices = new short [ num indices ] ; if ( num indices > 0 ) { for ( int i = 0 ; i < num indices ; i ++ ) { final indices [ i ] = ( short ) i ; } } array < vertex attribute > attributes = new array < vertex attribute > ( ) ; attributes . add ( new vertex attribute ( usage . position , 3 , shader program . position attribute ) ) ; if ( has norms ) attributes . add ( new vertex attribute ( usage . normal , 3 , shader program . normal attribute ) ) ; if ( has u vs ) attributes . add ( new vertex attribute ( usage . texture coordinates , 2 , shader program . texcoord attribute + "0" ) ) ; string string id = integer . to string ( ++ id ) ; string node id = "default" . equals ( group . name ) ? "node" + string id : group . name ; string mesh id = "default" . equals ( group . name ) ? "mesh" + string id : group . name ; string part id = "default" . equals ( group . name ) ? "part" + string id : group . name ; model node node = new model node ( ) ; node . id = node id ; node . mesh id = mesh id ; node . scale = new vector 3 ( 1 , 1 , 1 ) ; node . translation = new vector 3 ( ) ; node . rotation = new quaternion ( ) ; model node part pm = new model node part ( ) ; pm . mesh part id = part id ; pm . material id = group . material name ; node . parts = new model node part [ ] { pm } ; model mesh part part = new model mesh part ( ) ; part . id = part id ; part . indices = final indices ; part . primitive type = gl 20 . gl triangles ; model mesh mesh = new model mesh ( ) ; mesh . id = mesh id ; mesh . attributes = attributes . to array ( vertex attribute . class ) ; mesh . vertices = final verts ; mesh . parts = new model mesh part [ ] { part } ; data . nodes . add ( node ) ; data . meshes . add ( mesh ) ; model material mm = mtl . get material ( group . material name ) ; data . materials . add ( mm ) ; } if ( verts . size > 0 ) verts . clear ( ) ; if ( norms . size > 0 ) norms . clear ( ) ; if ( uvs . size > 0 ) uvs . clear ( ) ; if ( groups . size > 0 ) groups . clear ( ) ; return data ; } <SENTENCE_END/>

(Copy Probability: 5.4%)

<SENTENCE_START> { if ( log warning ) gdx . app . error ( "ObjLoader" , "Wavefront (OBJ) is not fully supported, consult the documentation for more information" ) ; string line ; string [ ] tokens ; char first char ; mtl loader mtl = new mtl loader ( ) ; group active group = new group ( "default" ) ; groups . add ( active group ) ; buffered reader reader = new buffered reader ( new input stream reader ( file . read ( ) ) , 4096 ) ; int id = 0 ; try { while ( ( line = reader . read line ( ) ) != null ) { tokens = line . split ( "|s+" ) ; if ( tokens . length < 1 ) break ; if ( tokens [ 0 ] . length ( ) == 0 ) { continue ; } else if ( ( first char = tokens [ 0 ] . to lower case ( ) . char at ( 0 ) ) == '#' ) { continue ; } else if ( first char == 'v' ) { if ( tokens [ 0 ] . length ( ) == 1 ) { verts . add ( float . parse float ( tokens [ 1 ] ) ) ; verts . add ( float . parse float ( tokens [ 2 ] ) ) ; verts . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 'n' ) { norms . add ( float . parse float ( tokens [ 1 ] ) ) ; norms . add ( float . parse float ( tokens [ 2 ] ) ) ; norms . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 't' ) { uvs . add ( float . parse float ( tokens [ 1 ] ) ) ; uvs . add ( ( flip v ? 1 - float . parse float ( tokens [ 2 ] ) : float . parse float ( tokens [ 2 ] ) ) ) ; } } else if ( first char == 'f' ) { string [ ] parts ; array < integer > faces = active group . faces ; for ( int i = 1 ; i < tokens . length - 2 ; i -- ) { parts = tokens [ 1 ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) { if ( i == 1 ) active group . has norms = true ; faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; } if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) { if ( i == 1 ) active group . has u vs = true ; faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; } parts = tokens [ ++ i ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; parts = tokens [ ++ i ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; if ( parts . length > 1 && parts [ 1 ] . length ( ) > 0 ) faces . add ( get index ( parts [ 1 ] , uvs . size ) ) ; active group . num faces ++ ; } } else if ( first char == 'o' || first char == 'g' ) { if ( tokens . length > 1 ) active group = set active group ( tokens [ 1 ] ) ; else active group = set active group ( "default" ) ; } else if ( tokens [ 0 ] . equals ( "mtllib" ) ) { mtl . load ( file . parent ( ) . child ( tokens [ 1 ] ) ) ; } else if ( tokens [ 0 ] . equals ( "usemtl" ) ) { if ( tokens . length == 1 ) active group . material name = "default" ; else active group . material name = tokens [ 1 ] . replace ( '.' , '_' ) ; } } reader . close ( ) ; } catch ( io exception e ) { return null ; } for ( int i = 0 ; i < groups . size ; i ++ ) { if ( groups . get ( i ) . num faces < 1 ) { groups . remove index ( i ) ; i -- ; } } if ( groups . size < 1 ) return null ; final int num groups = groups . size ; final model data data = new model data ( ) ; for ( int g = 0 ; g < num groups ; g ++ ) { group group = groups . get ( g ) ; array < integer > faces = group . faces ; final int num elements = faces . size ; final int num faces = group . num faces ; final boolean has norms = group . has norms ; final boolean has u vs = group . has u vs ; final float [ ] final verts = new float [ ( num faces * 3 ) * ( 3 + ( has norms ? 3 : 0 ) + ( has u vs ? 2 : 0 ) ) ] ; for ( int i = 0 , vi = 0 ; i < num elements ; ) { int vert index = faces . get ( i ++ ) * 3 ; final verts [ vi ++ ] = verts . get ( vert index ++ ) ; final verts [ vi ++ ] = verts . get ( vert index ++ ) ; final verts [ vi ++ ] = verts . get ( vert index ) ; if ( has norms ) { int norm index = faces . get ( i ++ ) * 3 ; final verts [ vi ++ ] = norms . get ( norm index ++ ) ; final verts [ vi ++ ] = norms . get ( norm index ++ ) ; final verts [ vi ++ ] = norms . get ( norm index ) ; } if ( has u vs ) { int uv index = faces . get ( i ++ ) * 2 ; final verts [ vi ++ ] = uvs . get ( uv index ++ ) ; final verts [ vi ++ ] = uvs . get ( uv index ) ; } } final int num indices = num faces * 3 >= short . max value ? 0 : num faces * 3 ; final short [ ] final indices = new short [ num indices ] ; if ( num indices > 0 ) { for ( int i = 0 ; i < num indices ; i ++ ) { final indices [ i ] = ( short ) i ; } } array < vertex attribute > attributes = new array < vertex attribute > ( ) ; attributes . add ( new vertex attribute ( usage . position , 3 , shader program . position attribute ) ) ; if ( has norms ) attributes . add ( new vertex attribute ( usage . normal , 3 , shader program . normal attribute ) ) ; if ( has u vs ) attributes . add ( new vertex attribute ( usage . texture coordinates , 2 , shader program . texcoord attribute + "0" ) ) ; string string id = integer . to string ( ++ id ) ; string node id = "default" . equals ( group . name ) ? "node" + string id : group . name ; string mesh id = "default" . equals ( group . name ) ? "mesh" + string id : group . name ; string part id = "default" . equals ( group . name ) ? "part" + string id : group . name ; model node node = new model node ( ) ; node . id = node id ; node . mesh id = mesh id ; node . scale = new vector 3 ( 1 , 1 , 1 ) ; node . translation = new vector 3 ( ) ; node . rotation = new quaternion ( ) ; model node part pm = new model node part ( ) ; pm . mesh part id = part id ; pm . material id = group . material name ; node . parts = new model node part [ ] { pm } ; model mesh part part = new model mesh part ( ) ; part . id = part id ; part . indices = final indices ; part . primitive type = gl 20 . gl triangles ; model mesh mesh = new model mesh ( ) ; mesh . id = mesh id ; mesh . attributes = attributes . to array ( vertex attribute . class ) ; mesh . vertices = final verts ; mesh . parts = new model mesh part [ ] { part } ; data . nodes . add ( node ) ; data . meshes . add ( mesh ) ; model material mm = mtl . get material ( group . material name ) ; data . materials . add ( mm ) ; } if ( verts . size > 0 ) verts . clear ( ) ; if ( norms . size > 0 ) norms . clear ( ) ; if ( uvs . size > 0 ) uvs . clear ( ) ; if ( groups . size > 0 ) groups . clear ( ) ; return data ; } <SENTENCE_END/>

%END%

<SENTENCE_START> { if ( log warning ) gdx . app . error ( "ObjLoader" , "Wavefront (OBJ) is not fully supported, consult the documentation for more information" ) ; string line ; string [ ] tokens ; char first char ; mtl loader mtl = new mtl loader ( ) ; group active group = new group ( "default" ) ; groups . add ( active group ) ; buffered reader reader = new buffered reader ( new input stream reader ( file . read ( ) ) , 4096 ) ; int id = 0 ; try { while ( ( line = reader . read line ( ) ) != null ) { tokens = line . split ( "|s+" ) ; if ( tokens . length < 1 ) break ; if ( tokens [ 0 ] . length ( ) == 0 ) { continue ; } else if ( ( first char = tokens [ 0 ] . to lower case ( ) . char at ( 0 ) ) == '#' ) { continue ; } else if ( first char == 'v' ) { if ( tokens [ 0 ] . length ( ) == 1 ) { verts . add ( float . parse float ( tokens [ 1 ] ) ) ; verts . add ( float . parse float ( tokens [ 2 ] ) ) ; verts . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 'n' ) { norms . add ( float . parse float ( tokens [ 1 ] ) ) ; norms . add ( float . parse float ( tokens [ 2 ] ) ) ; norms . add ( float . parse float ( tokens [ 3 ] ) ) ; } else if ( tokens [ 0 ] . char at ( 1 ) == 't' ) { uvs . add ( float . parse float ( tokens [ 1 ] ) ) ; uvs . add ( ( flip v ? 1 - float . parse float ( tokens [ 2 ] ) : float . parse float ( tokens [ 2 ] ) ) ) ; } } else if ( first char == 'f' ) { string [ ] parts ; array < integer > faces = active group . faces ; for ( int i = 1 ; i < tokens . length - 2 ; i -- ) { parts = tokens [ 1 ] . split ( "/" ) ; faces . add ( get index ( parts [ 0 ] , verts . size ) ) ; if ( parts . length > 2 ) { if ( i == 1 ) active group . has norms = true ; faces . add ( get index ( parts [ 2 ] , norms . size ) ) ; } if ( parts . length > 1 && parts [ 1 ] . length (