de.javagl.obj.ObjReader Java Examples

The following examples show how to use de.javagl.obj.ObjReader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectRenderer.java    From react-native-arcore with MIT License 5 votes vote down vote up
/**
 * Creates and initializes OpenGL resources needed for rendering the model.
 *
 * @param context Context for loading the shader and below-named model and texture assets.
 * @param objAssetName  Name of the OBJ file containing the model geometry.
 * @param diffuseTextureAssetName  Name of the PNG file containing the diffuse texture map.
 */

public void createOnGlThread(Context context, String objAssetName,
                             String diffuseTextureAssetName)  throws IOException {
    Bitmap textureBitmap = BitmapFactory.decodeStream(
        context.getAssets().open(diffuseTextureAssetName));
    InputStream objInputStream = context.getAssets().open(objAssetName);
    Obj obj = ObjReader.read(objInputStream);
    this.createOnGlThread(context,obj,textureBitmap);
}
 
Example #2
Source File: ObjGltfAssetCreatorV1.java    From JglTF with MIT License 5 votes vote down vote up
/**
 * Read the OBJ from the given URI, and return it as a "renderable" OBJ,
 * which contains only triangles, has unique vertex coordinates and
 * normals, and is single-indexed 
 * 
 * @param objUri The OBJ URI
 * @return The OBJ
 * @throws IOException If an IO error occurs
 */
private static Obj readObj(URI objUri) throws IOException
{
    logger.log(level, "Reading OBJ from " + objUri);
    
    try (InputStream objInputStream =  objUri.toURL().openStream())
    {
        Obj obj = ObjReader.read(objInputStream);
        return ObjUtils.convertToRenderable(obj);
    }
}
 
Example #3
Source File: ObjGltfAssetCreatorV2.java    From JglTF with MIT License 5 votes vote down vote up
/**
 * Read the OBJ from the given URI, and return it as a "renderable" OBJ,
 * which contains only triangles, has unique vertex coordinates and
 * normals, and is single-indexed 
 * 
 * @param objUri The OBJ URI
 * @return The OBJ
 * @throws IOException If an IO error occurs
 */
private static Obj readObj(URI objUri) throws IOException
{
    logger.log(level, "Reading OBJ from " + objUri);
    
    try (InputStream objInputStream =  objUri.toURL().openStream())
    {
        Obj obj = ObjReader.read(objInputStream);
        return ObjUtils.convertToRenderable(obj);
    }
}
 
Example #4
Source File: ObjectRenderer.java    From react-native-arcore with MIT License 4 votes vote down vote up
public void createOnGlThreadWithBase64Object(Context context, String objBase64,
                                             String bitmapTextureBase64)  throws IOException {
    Bitmap textureBitmap = BitmapFactory.decodeStream(new ByteArrayInputStream(Base64.decode(bitmapTextureBase64, Base64.DEFAULT)));
    Obj obj = ObjReader.read(new ByteArrayInputStream(Base64.decode(objBase64, Base64.DEFAULT)));
    this.createOnGlThread(context,obj,textureBitmap);
}