Subversion Repositories AndroidProjects

Rev

Rev 205 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
205 chris 1
package com.gebauz.Bauzoid.graphics.model;
2
 
3
 
4
/** Implementation of the SUX Model format (subset). */
5
public class Model
6
{
7
        private String mName;
8
        private Mesh[] mMeshes = null;
9
 
10
        /** Constructor. */
11
        public Model(String name)
12
        {
13
                mName = name;
14
        }
15
 
216 chris 16
        /** Dispose internal data. */
17
        public void dispose()
18
        {
19
                if (mMeshes != null)
20
                {
21
                        for (int i = 0; i < mMeshes.length; i++)
22
                        {
23
                                mMeshes[i].dispose();
24
                                mMeshes[i] = null;
25
                        }
26
 
27
                        mMeshes = null;
28
                }
29
        }
30
 
205 chris 31
        /** Update internals. */
32
        public void update(float deltaTime)
33
        {
34
 
35
        }
36
 
37
        /** Render the model. */
38
        public void render()
39
        {
40
                for (int i = 0; i < mMeshes.length; i++)
41
                {
42
                        mMeshes[i].render();
43
                }
44
        }
45
 
46
        /** Upload the internal geometry to hardware. */
47
        public void upload()
48
        {
49
                for (int i = 0; i < mMeshes.length; i++)
50
                {
51
                        mMeshes[i].getGeometry().upload();
52
                }
53
        }
54
 
55
        /** Unload internal geometry from hardware. */
56
        public void unload()
57
        {
58
                for (int i = 0; i < mMeshes.length; i++)
59
                {
60
                        mMeshes[i].getGeometry().unload();
61
                }
62
        }
63
 
64
        /** Get number of meshes. */
65
        public final int getMeshCount()
66
        {
67
                return mMeshes.length;
68
        }
69
 
70
        /** Get a single mesh. */
71
        public final Mesh getMesh(int i)
72
        {
73
                return mMeshes[i];
74
        }
75
 
76
        /** Get a mesh by name. */
77
        public final Mesh getMesh(String name)
78
        {
79
                for (int i = 0; i < mMeshes.length; i++)
80
                {
81
                        if (mMeshes[i].getName().equalsIgnoreCase(name))
82
                                return mMeshes[i];
83
                }
84
                return null;
85
        }
86
 
87
        /** Set the meshes. */
88
        public final void setMeshes(Mesh[] meshes)
89
        {
216 chris 90
                if (meshes == null)
91
                        dispose();
92
 
205 chris 93
                mMeshes = meshes;
94
        }
95
 
96
        /** Get the mesh name. */
97
        public final String getName()
98
        {
99
                return mName;
100
        }
101
 
102
}
103
 
104