@Override public ByteBuffer getImageData() { if (imageData == null) { return bufferViewModel.getBufferViewData(); } return Buffers.createSlice(imageData); }
/** * Create the {@link AccessorData} for the given {@link AccessorModel} * * @param accessorModel The {@link AccessorModel} * @return The {@link AccessorData} */ public static AccessorData create(AccessorModel accessorModel) { BufferViewModel bufferViewModel = accessorModel.getBufferViewModel(); ByteBuffer bufferViewData = bufferViewModel.getBufferViewData(); return create(accessorModel, bufferViewData); }
/** * Creates an {@link AccessorFloatData} for the given {@link AccessorModel} * * @param accessorModel The {@link AccessorModel} * @return The {@link AccessorFloatData} * @throws IllegalArgumentException If the * {@link AccessorModel#getComponentType() component type} of the given * accessorModel is not <code>GL_FLOAT</code> */ public static AccessorFloatData createFloat(AccessorModel accessorModel) { BufferViewModel bufferViewModel = accessorModel.getBufferViewModel(); return createFloat(accessorModel, bufferViewModel.getBufferViewData()); }
/** * Creates an {@link AccessorShortData} for the given {@link AccessorModel} * * @param accessorModel The {@link AccessorModel} * @return The {@link AccessorShortData} * @throws IllegalArgumentException If the * {@link AccessorModel#getComponentType() component type} of the given * accessorModel is not <code>GL_SHORT</code> or * <code>GL_UNSIGNED_SHORT</code> */ static AccessorShortData createShort(AccessorModel accessorModel) { BufferViewModel bufferViewModel = accessorModel.getBufferViewModel(); return createShort(accessorModel, bufferViewModel.getBufferViewData()); }
/** * Creates an {@link AccessorByteData} for the given {@link AccessorModel} * * @param accessorModel The {@link AccessorModel} * @return The {@link AccessorByteData} * @throws IllegalArgumentException If the * {@link AccessorModel#getComponentType() component type} of the given * accessor is not <code>GL_BYTE</code> or <code>GL_UNSIGNED_BYTE</code> */ static AccessorByteData createByte(AccessorModel accessorModel) { BufferViewModel bufferViewModel = accessorModel.getBufferViewModel(); return createByte(accessorModel, bufferViewModel.getBufferViewData()); }
/** * Creates an {@link AccessorIntData} for the given {@link AccessorModel} * * @param accessorModel The {@link AccessorModel} * @return The {@link AccessorIntData} * @throws IllegalArgumentException If the * {@link AccessorModel#getComponentType() component type} of the given * accessorModel is not <code>GL_INT</code> or <code>GL_UNSIGNED_INT</code> */ static AccessorIntData createInt(AccessorModel accessorModel) { BufferViewModel bufferViewModel = accessorModel.getBufferViewModel(); return createInt(accessorModel, bufferViewModel.getBufferViewData()); }
/** * Internal method to create the GL buffer for the given * {@link BufferViewModel}. If the GL buffer can not be created for * any reason, then a warning will be printed and <code>null</code> * will be returned. * * @param bufferViewModel The {@link BufferViewModel} * @return The GL buffer */ private Integer createGlBufferView(BufferViewModel bufferViewModel) { logger.fine("Creating GL bufferView for bufferView " + bufferViewModel); Integer byteLength = bufferViewModel.getByteLength(); ByteBuffer bufferViewData = bufferViewModel.getBufferViewData(); int target = Optionals.of( bufferViewModel.getTarget(), GltfConstants.GL_ARRAY_BUFFER); int glBufferView = glContext.createGlBufferView( target, byteLength, bufferViewData.slice()); logger.fine("Creating GL bufferView for bufferView " + bufferViewModel + " DONE"); return glBufferView; }
/** * Create the {@link AccessorData} for the given * {@link AccessorSparseValues} * * @param accessorSparseValues The {@link AccessorSparseValues} * @param componentType The component type of the {@link Accessor} * @param numComponentsPerElement The number of components per element * of the {@link AccessorModel#getElementType() accessor element type} * @param count The count from the {@link AccessorSparse} * @return The {@link AccessorData} */ private AccessorData createSparseValuesAccessorData( AccessorSparseValues accessorSparseValues, int componentType, int numComponentsPerElement, int count) { Integer bufferViewIndex = accessorSparseValues.getBufferView(); BufferViewModel bufferViewModel = bufferViewModels.get(bufferViewIndex); ByteBuffer bufferViewData = bufferViewModel.getBufferViewData(); int byteOffset = Optionals.of(accessorSparseValues.getByteOffset(), 0); return AccessorDatas.create( componentType, bufferViewData, byteOffset, count, numComponentsPerElement, null); }
/** * Create the {@link AccessorData} for the given * {@link AccessorSparseIndices} * * @param accessorSparseIndices The {@link AccessorSparseIndices} * @param count The count from the {@link AccessorSparse} * @return The {@link AccessorData} */ private AccessorData createSparseIndicesAccessorData( AccessorSparseIndices accessorSparseIndices, int count) { Integer componentType = accessorSparseIndices.getComponentType(); Integer bufferViewIndex = accessorSparseIndices.getBufferView(); BufferViewModel bufferViewModel = bufferViewModels.get(bufferViewIndex); ByteBuffer bufferViewData = bufferViewModel.getBufferViewData(); int byteOffset = Optionals.of(accessorSparseIndices.getByteOffset(), 0); return AccessorDatas.create( componentType, bufferViewData, byteOffset, count, 1, null); }
morphedBufferViewModel.getByteLength(); ByteBuffer morphedBufferViewData = morphedBufferViewModel.getBufferViewData(); int bufferSize = morphedBufferViewData.capacity();
BufferViewModel bufferViewModel = getBufferViewModelById(bufferViewId); shaderModel.setShaderData(bufferViewModel.getBufferViewData());