summaryrefslogtreecommitdiffstats
path: root/src/net/java/joglutils/model/ModelFactory.java
blob: 778f3199a104e999c1e4753c1d859baf15798d2d (plain)
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
/*
 * Model3DFactory.java
 *
 * Created on February 27, 2008, 10:00 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package net.java.joglutils.model;


import java.util.HashMap;
import net.java.joglutils.model.geometry.Model;
import net.java.joglutils.model.loader.LoaderFactory;

/**
 *
 * @author Brian Wood
 * modifications made by Greg Rodgers
 */
public class ModelFactory {
    
    private static HashMap<Object, Model> modelCache = new HashMap<Object, Model>();
        
    public static Model createModel(String source) throws ModelLoadException {
        Model model = modelCache.get(source);
        if (model == null) {
            model = LoaderFactory.load(source);
            modelCache.put(source, model);
        }
        
        if (model == null)
            throw new ModelLoadException();
        
        return model;
    }
}