I have a question regarding interleaved vbo's. I have a structure that looks like this
struct VertexData{
float x,y,z; //vertex coordinates
float normalx,normaly,normalz; //vertex normal
float cx,cy,cz; //vertex color
};
Run Code Online (Sandbox Code Playgroud)
这就是我创建VBO,VAO,IBO的方式:
//creat OpenGL objects to use in drawing
unsigned int gl_vertex_array_object, gl_vertex_buffer_object, gl_index_buffer_object;
//vertex array object
glGenVertexArrays(1, &gl_vertex_array_object);
glBindVertexArray(gl_vertex_array_object);
//vertex buffer object -> we hold the vertices
glGenBuffers(1,&gl_vertex_buffer_object);
glBindBuffer(GL_ARRAY_BUFFER, gl_vertex_buffer_object);
glBufferData(GL_ARRAY_BUFFER, vertices.size()*sizeof(VertexData), &vertices[0], GL_STATIC_DRAW);
//index buffer object -> we hold the index of vertex
glGenBuffers(1,&gl_index_buffer_object);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gl_index_buffer_object);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size()*sizeof(unsigned int), …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个自定义反序列化器,以便减少从其他地方收到的大量数据.我从反序列化器返回一个自定义对象列表.
我的问题是,如果这是我的自定义反序列化器,我该怎么做:
public class MyCustomDeserializer extends JsonDeserializer<List<CustomClass>> { ... }
Run Code Online (Sandbox Code Playgroud)
我当然不能这样做:
final SimpleModule module = new SimpleModule();
module.addDeserializer(List<CustomClass>.class, new MyCustomDeserializer());
Run Code Online (Sandbox Code Playgroud)
这样的事情会起作用吗?
final List<CustomClass> response = Arrays.asList(objectMapper.readValue(stringBean, CustomClass[].class));
Run Code Online (Sandbox Code Playgroud)
如果这确实有效,我发现它有点令人困惑和"危险"?是不是在asList方法调用中完成了反序列化?所以它基本上将List映射到数组[]?
我了解了TypeReference,所以我可以这样使用它:
objectMapper.readValue(stringBean, new TypeReference<List<CustomClass>>(){});
Run Code Online (Sandbox Code Playgroud)
但我听说它慢了
我也不想为列表创建一个容器,并在反序列化中返回它,因为这意味着它将被包装在另一个json对象中,我只想让我的端点产生如下内容:
[{object1}, {object2}]
// instead of
{"Output" : [{object1}, {object2}]}
Run Code Online (Sandbox Code Playgroud)
编辑:
似乎我误解了杰克逊在两种情况下如何使用我的解串器:
final List<CustomClass> response = Arrays.asList(objectMapper.readValue(stringBean, CustomClass[].class));
// or
objectMapper.readValue(stringBean, new TypeReference<List<CustomClass>>(){});
Run Code Online (Sandbox Code Playgroud)
看起来反序列化器被调用两次,对于数组中的每个对象一次.我认为整个阵列将被视为一个整体.为了清除这种混淆,这就是我的意思:
我收到并尝试反序列化的json看起来像这样:
[
{
"Data" : {
"id" : "someId",
"otherThing" : "someOtherThing"
},
"Message" : "OK"
},
{
"Data" : null,
"Message" : …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法来设置多个配置文件,其中一个我想设置为默认值(运行时mvn clean install应该选择该配置文件).我对使用activeByDefault的任何解决方案都不感兴趣,因为它阻碍了我在另一个模块中创建单独的配置文件并在默认配置文件中同时使用它们.
目前我使用的属性方法看起来像:
<profiles>
<profile>
<id>prof1</id>
<activation>
<property>
<name>!myprop</name>
</property>
</activation>
</profile>
<profile>
<id>prof2</id>
<activation>
<property>
<name>myprop</name>
<value>prof2</value>
</property>
</activation>
</profile>
<profile>
<id>prof3</id>
<activation>
<property>
<name>myprop</name>
<value>prof3</value>
</property>
</activation>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
这意味着我必须编译我的项目,mvn clean install -Dmyprop=prof3如果我想选择prof3而不是prof1(默认情况下不设置任何属性).
但是我希望实现相同的效果但是编译我的项目-Pprofilename而不是设置属性.我已经尝试在<properties>标记下的每个配置文件中添加属性,但似乎默认始终运行.我读到pom属性不能用于激活配置文件.
这有什么解决方法吗?比如有一个设置或属性文件(我不想在每次编译时都改变它)从中我可以获得属性并实现我的编译目标-PprofileName?