/
SimpleObjExample.java
57 lines (50 loc) · 1.97 KB
/
SimpleObjExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Copyright (c) 2008-2021 Bird Dog Games, Inc.
*
* This file is part of Ardor3D.
*
* Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <https://git.io/fjRmv>.
*/
package com.ardor3d.example.pipeline;
import java.net.URISyntaxException;
import com.ardor3d.example.ExampleBase;
import com.ardor3d.example.Purpose;
import com.ardor3d.extension.model.obj.ObjGeometryStore;
import com.ardor3d.extension.model.obj.ObjImporter;
import com.ardor3d.math.Vector3;
import com.ardor3d.util.MaterialUtil;
import com.ardor3d.util.resource.ResourceLocatorTool;
import com.ardor3d.util.resource.SimpleResourceLocator;
/**
* Simplest example of loading a Wavefront OBJ model.
*/
@Purpose(
htmlDescriptionKey = "com.ardor3d.example.pipeline.SimpleObjExample", //
thumbnailPath = "com/ardor3d/example/media/thumbnails/pipeline_SimpleObjExample.jpg", //
maxHeapMemory = 64)
public class SimpleObjExample extends ExampleBase {
public static void main(final String[] args) {
ExampleBase.start(SimpleObjExample.class);
}
@Override
protected void initExample() {
_canvas.setTitle("Ardor3D - Simple Obj Example");
_canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 5, 20));
// Load the collada scene
final long time = System.currentTimeMillis();
final ObjImporter importer = new ObjImporter();
try {
importer.setTextureLocator(new SimpleResourceLocator(
ResourceLocatorTool.getClassPathResource(SimpleObjExample.class, "com/ardor3d/example/media/models/obj/")));
} catch (final URISyntaxException ex) {
ex.printStackTrace();
}
final ObjGeometryStore storage = importer.load("obj/pitcher.obj");
System.out.println("Importing Took " + (System.currentTimeMillis() - time) + " ms");
_root.attachChild(storage.getScene());
_root.updateWorldRenderStates(true);
MaterialUtil.autoMaterials(_root);
}
}