vtm-themes: move GDX models (#577)
This commit is contained in:
parent
de259c27d7
commit
272ce1d9b6
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2016 devemux86
|
* Copyright 2016 devemux86
|
||||||
|
* Copyright 2018 Gustl22
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
*
|
*
|
||||||
@ -50,6 +51,13 @@ public class GdxAssets extends AssetAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get file path in GDX assets.
|
||||||
|
*/
|
||||||
|
public static String getAssetPath(String fileName) {
|
||||||
|
return Gdx.files.internal(pathPrefix + fileName).path();
|
||||||
|
}
|
||||||
|
|
||||||
public static void init(String path) {
|
public static void init(String path) {
|
||||||
AssetAdapter.init(new GdxAssets(path));
|
AssetAdapter.init(new GdxAssets(path));
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import org.oscim.core.PointF;
|
|||||||
import org.oscim.core.Tag;
|
import org.oscim.core.Tag;
|
||||||
import org.oscim.core.Tile;
|
import org.oscim.core.Tile;
|
||||||
import org.oscim.event.Event;
|
import org.oscim.event.Event;
|
||||||
|
import org.oscim.gdx.GdxAssets;
|
||||||
import org.oscim.layers.Layer;
|
import org.oscim.layers.Layer;
|
||||||
import org.oscim.layers.tile.MapTile;
|
import org.oscim.layers.tile.MapTile;
|
||||||
import org.oscim.layers.tile.MapTile.TileData;
|
import org.oscim.layers.tile.MapTile.TileData;
|
||||||
@ -21,6 +22,7 @@ import org.oscim.layers.tile.vector.VectorTileLayer.TileLoaderProcessHook;
|
|||||||
import org.oscim.map.Map;
|
import org.oscim.map.Map;
|
||||||
import org.oscim.renderer.bucket.RenderBuckets;
|
import org.oscim.renderer.bucket.RenderBuckets;
|
||||||
import org.oscim.renderer.bucket.SymbolItem;
|
import org.oscim.renderer.bucket.SymbolItem;
|
||||||
|
import org.oscim.theme.VtmModels;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -92,8 +94,10 @@ public class Poi3DLayer extends Layer implements Map.UpdateListener {
|
|||||||
// mModel = modelBuilder.createSphere(10f, 10f, 10f, 12, 12,
|
// mModel = modelBuilder.createSphere(10f, 10f, 10f, 12, 12,
|
||||||
// mat, attributes);
|
// mat, attributes);
|
||||||
|
|
||||||
|
pathToTree = GdxAssets.getAssetPath(VtmModels.TREE.getPath());
|
||||||
|
|
||||||
assets = new AssetManager();
|
assets = new AssetManager();
|
||||||
assets.load("data/g3d/treeA.g3dj", Model.class);
|
assets.load(pathToTree, Model.class);
|
||||||
loading = true;
|
loading = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,8 +111,10 @@ public class Poi3DLayer extends Layer implements Map.UpdateListener {
|
|||||||
Model mModel;
|
Model mModel;
|
||||||
AssetManager assets;
|
AssetManager assets;
|
||||||
|
|
||||||
|
private final String pathToTree;
|
||||||
|
|
||||||
private void doneLoading() {
|
private void doneLoading() {
|
||||||
Model model = assets.get("data/g3d/treeA.g3dj", Model.class);
|
Model model = assets.get(pathToTree, Model.class);
|
||||||
for (int i = 0; i < model.nodes.size; i++) {
|
for (int i = 0; i < model.nodes.size; i++) {
|
||||||
Node node = model.nodes.get(i);
|
Node node = model.nodes.get(i);
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
52
vtm-themes/src/org/oscim/theme/VtmModels.java
Normal file
52
vtm-themes/src/org/oscim/theme/VtmModels.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 Gustl22
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the
|
||||||
|
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.oscim.theme;
|
||||||
|
|
||||||
|
import org.oscim.backend.AssetAdapter;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumeration of all internal VTM models.
|
||||||
|
* <p>
|
||||||
|
* Generate own models:
|
||||||
|
* If using Blender for new models, start fresh project delete camera and light source, keep blender render engine.
|
||||||
|
* Export as .obj/fbx
|
||||||
|
* Use Fbx converter [https://github.com/libgdx/fbx-conv] and Java GUI [https://github.com/ASneakyFox/libgdx-fbxconv-gui]
|
||||||
|
* to convert to g3d.
|
||||||
|
* .obj is supported, too, but has troubles with textures and materials.
|
||||||
|
* More: [https://github.com/libgdx/libgdx/wiki/Importing-Blender-models-in-LibGDX]
|
||||||
|
*/
|
||||||
|
public enum VtmModels {
|
||||||
|
|
||||||
|
TREE("models/natural/treeA.g3dj");
|
||||||
|
|
||||||
|
private final String mPath;
|
||||||
|
|
||||||
|
VtmModels(String path) {
|
||||||
|
mPath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get relative path to models. Assets path isn't included!
|
||||||
|
*/
|
||||||
|
public String getPath() {
|
||||||
|
return mPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getModelAsStream() {
|
||||||
|
return AssetAdapter.readFileAsStream(mPath);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user