@Override public int getComponentSizeInBytes() { return Accessors.getNumBytesForAccessorComponentType(componentType); }
@Override public Class<?> getComponentDataType() { return Accessors.getDataTypeForAccessorComponentType( getComponentType()); }
GltfConstants.stringFor(accessor.getComponentType()); int componentSizeInBytes = Accessors.getNumBytesForAccessorComponentType(componentType); int numComponents = Accessors.getNumComponentsForAccessorType(accessor.getType()); int elementSizeInBytes = numComponents * componentSizeInBytes;
/** * Create a byte buffer containing the data of the indices for the * given OBJ. The face vertex indices of the given OBJ will be * extracted (assuming that it contains only triangles), converted * to the given indices component type (which is a GL constant like * GL_SHORT), and a byte buffer containing these indices will be returned. * * @param obj The OBJ * @param indicesComponentType The indices component type * @return The byte buffer */ private static ByteBuffer createIndicesByteBuffer( ReadableObj obj, int indicesComponentType) { int numVerticesPerFace = 3; IntBuffer objIndices = ObjData.getFaceVertexIndices(obj, numVerticesPerFace); int indicesComponentSize = Accessors.getNumBytesForAccessorComponentType( indicesComponentType); ByteBuffer indicesByteBuffer = IntBuffers.convertToByteBuffer(objIndices, indicesComponentSize); return indicesByteBuffer; }
/** * Create a byte buffer containing the data of the indices for the * given OBJ. The face vertex indices of the given OBJ will be * extracted (assuming that it contains only triangles), converted * to the given indices component type (which is a GL constant like * GL_SHORT), and a byte buffer containing these indices will be returned. * * @param obj The OBJ * @param indicesComponentType The indices component type * @return The byte buffer */ private static ByteBuffer createIndicesByteBuffer( ReadableObj obj, int indicesComponentType) { int numVerticesPerFace = 3; IntBuffer objIndices = ObjData.getFaceVertexIndices(obj, numVerticesPerFace); int indicesComponentSize = Accessors.getNumBytesForAccessorComponentType( indicesComponentType); ByteBuffer indicesByteBuffer = IntBuffers.convertToByteBuffer(objIndices, indicesComponentSize); return indicesByteBuffer; }
/** * Create an {@link AccessorModel} in the {@link BufferStructure} that * is currently being built. * * @param id The ID of the {@link AccessorModel} * @param componentType The component type, as a GL constant * @param type The type of the data, as a string corresponding to * the {@link ElementType} of the accessor * @param byteBuffer The actual data */ public void createAccessorModel(String id, int componentType, String type, ByteBuffer byteBuffer) { ElementType elementType = ElementType.valueOf(type); int numComponents = elementType.getNumComponents(); int numBytesPerComponent = Accessors.getNumBytesForAccessorComponentType(componentType); int numBytesPerElement = numComponents * numBytesPerComponent; int count = byteBuffer.capacity() / numBytesPerElement; DefaultAccessorModel accessorModel = new DefaultAccessorModel( componentType, count, elementType); bufferStructure.addAccessorModel(accessorModel, id); currentAccessorModels.add(accessorModel); rawAccessorModelByteBuffers.put(accessorModel, byteBuffer); }
/** * Create a {@link DefaultAccessorModel} for the given {@link Accessor} * * @param accessor The {@link Accessor} * @return The {@link AccessorModel} */ private static DefaultAccessorModel createAccessorModel(Accessor accessor) { Integer componentType = accessor.getComponentType(); Integer byteOffset = accessor.getByteOffset(); Integer count = accessor.getCount(); ElementType elementType = ElementType.forString(accessor.getType()); Integer byteStride = accessor.getByteStride(); if (byteStride == null) { byteStride = elementType.getNumComponents() * Accessors.getNumBytesForAccessorComponentType( componentType); } DefaultAccessorModel accessorModel = new DefaultAccessorModel( componentType, count, elementType); accessorModel.setByteOffset(byteOffset); accessorModel.setByteStride(byteStride); return accessorModel; }