public void writeBuffersToView(View3D v) { ArrayList<Float> verticesData = new ArrayList<>(); ArrayList<Short> drawOrder = new ArrayList<>(); for (Vertex ve : vertices) { verticesData.add(ve.x); verticesData.add(ve.y); verticesData.add(ve.z); } float[] texturesDataArray = new float[faces.size() * 2]; float[] normalsDataArray = new float[faces.size() * 3]; int indexTex = 0; int indexNormal = 0; for (Face f : faces) { drawOrder.add((short) (f.v[0] - 1)); drawOrder.add((short) (f.v[1] - 1)); drawOrder.add((short) (f.v[2] - 1)); if (!textures.isEmpty()) { if (indexTex < texturesDataArray.length) { texturesDataArray[indexTex] = textures.get(f.vt[0] - 1).x; texturesDataArray[indexTex + 1] = textures.get(f.vt[0] - 1).y; indexTex += 2; } } if (!normals.isEmpty()) { if (indexNormal < normalsDataArray.length) { normalsDataArray[indexNormal] = normals.get(f.vn[0] - 1).x; normalsDataArray[indexNormal + 1] = normals.get(f.vn[0] - 1).y; normalsDataArray[indexNormal + 2] = normals.get(f.vn[0] - 1).z; indexNormal += 3; } } } float[] verticesDataArray = new float[verticesData.size()]; for (int i = 0; i < verticesData.size(); i++) { verticesDataArray[i] = verticesData.get(i); } short[] drawOrderArray = new short[drawOrder.size()]; for (int i = 0; i < drawOrder.size(); i++) { drawOrderArray[i] = drawOrder.get(i); } ViewData data = new ViewData(); data.setVerticesData(verticesDataArray); data.setNormalData(normalsDataArray); data.setVerticesDrawOrder(drawOrderArray); data.setTextureData(texturesDataArray); v.setViewData(data); v.initializeBuffers(); }
@Override public void onCardboardTrigger() { if (lockCameraFlag) { lockCameraFlag = false; return; } for (View3D v : currentContent.getViews()) { v.performTriggerIfLookingAt(); } }