开发者

Obtaining this information properly and efficiently

开发者 https://www.devze.com 2023-01-10 20:37 出处:网络
I was wonder how I should record this information: #num:material:type:geo:light:tex:extralight:verts: 0:130x00004300.000030,01,12,2

I was wonder how I should record this information:

#  num:  material:   type:  geo:  light:   tex:  extralight:  verts:
     0:        13  0x0000     4       3      0       0.0000       3    0,  0   1,  1   2,  2 
     1:        13  0x0000     4       3      0       0.0000       3    2,  2   3,  3   4,  4 
     2:        13  0x0000     4       3      0       0.0000       3    4,  4   5,  5   0,  0 开发者_Python百科
     3:        13  0x0000     4       3      0       0.0000       3    4,  4   0,  0   2,  2 
     4:        13  0x0000     4       3      0       0.0000       4    7,  7  12, 12   8,  8   0,  0  

I want to record it in a float[], but I cannot do it without having to know the size of it ahead of time(Which is impossible unless I run through it a second time). The reason I say this is that the range of values changes based on the value in verts. The number to the right of verts is the locations of Vertices; so if it's 4, there are 8 extra numbers, if it's 3, there are 6 extra numbers.

Side-note: Ignore the column "num:" as I'm not going to use any of those values.


Use a dynamically expansible collection like a List. You don't need to know the size beforehand during construction. Instead of float[], use a List<Float> and use the add() method to add items.

See also:

  • Java collections tutorial


The most obvious solution to me is to create an object.

class Information
{
     private final int material ;

     private final int type ;

     private final int geo ;

     private final int light ;

     private final int tex ;

     private final int extralight ;

     private final List<Float> verts ;

    // appropriate constructor

    // appropriate accessor methods
}
0

精彩评论

暂无评论...
验证码 换一张
取 消