Newer
Older
CactusServer / src / main / java / cactusServer / models / ObjectModelManager.java
y-ota on 27 Sep 2018 1 KB 初期化処理を追加
package cactusServer.models;

import java.io.IOException;
import java.util.HashMap;

import org.ntlab.radishforandroidstudio.framework.model3D.Model3D;
import org.ntlab.radishforandroidstudio.framework.model3D.ModelFactory;
import org.ntlab.radishforandroidstudio.framework.model3D.ModelFileFormatException;

public class ObjectModelManager {
	private static ObjectModelManager theInstance = null;
	private HashMap<Integer, Model3D> model = new HashMap<>();

	private ObjectModelManager() {
		try {
			setObject(0, ModelFactory.loadModel(getClass().getResource("../../pocha.stl").getPath()));
			setObject(1, ModelFactory.loadModel(getClass().getResource("../../pocha.stl").getPath()));
		} catch (IOException | ModelFileFormatException e) {
			e.printStackTrace();
		}
	}

	public static ObjectModelManager getInstance() {
		if (theInstance == null) {
			theInstance = new ObjectModelManager();
		}
		return theInstance;
	}

	public void setObject(int key, Model3D loadModel) {
		model.put(key, loadModel);
	}

	public Model3D getObject(int objectID) {
		return model.get(objectID);
	}

	public int getObjectModelCount() {
		return model.size();
	}
}