Subversion Repositories AndroidProjects

Rev

Blame | Last modification | View Log | RSS feed

package com.gebauz.bauzoid.graphics.model;

import com.gebauz.bauzoid.graphics.Graphics;
import com.gebauz.bauzoid.graphics.GraphicsObject;
import com.gebauz.bauzoid.math.BoundingBox;

/** Mesh class implementing the SUX Mesh format - acts in cooperation with the Model class. */
public class Mesh extends GraphicsObject
{
        private String mName;
        private BoundingBox mBoundingBox;
       
        private Geometry mGeometry = null;
       
        private MeshGroup[] mGroups = null;
       
        /** Constructor. */
        public Mesh(Graphics graphics, String name)
        {
                super(graphics);
                mName = name;          
        }
       
        /** Destroy internal data. */
        public void dispose()
        {
                if (mGeometry != null)
                {
                       
                }              
        }
       
        /** Destroy internal Geometry. */
        public void destroyGeometry()
        {
                if (mGeometry != null)
                {
                        mGeometry.dispose();
                        mGeometry = null;
                }
        }
       
        /** Destroy groups. */
        public void destroyGroups()
        {
                if (mGroups != null)
                {
                        //for (int i = 0; i < mGroups.length; i++)
                        for (MeshGroup group : mGroups)
                                group.dispose();                               
                       
                        mGroups = null;
                }
        }
       
        /** Update the mesh. */
        public void update(float deltaTime)
        {
               
        }
       
        /** Render the mesh. */
        public void render()
        {
                mGeometry.activate();

                // enable shader/effect for group
               
                for (int i = 0; i < mGroups.length; i++)
                {
                        mGroups[i].render();
                }
               
                mGeometry.deactivate();
        }
       
        /** Get the mesh name. */
        public final String getName()
        {
                return mName;
        }
       
        /** Get the bounding box. */
        public BoundingBox getBoundingBox()
        {
                return mBoundingBox;
        }
       
        /** Set the bounding box. */
        public void setBoundingBox(BoundingBox box)
        {
                mBoundingBox = box;
        }
       
       
        /** Get the Geometry object. */
        public final Geometry getGeometry()
        {
                return mGeometry;
        }
       
        /** Set the Geometry object. */
        public final void setGeometry(Geometry geometry)
        {
                mGeometry = geometry;
        }
       
        /** Get a group. */
        public final MeshGroup getGroup(int i)
        {
                return mGroups[i];
        }
       
        /** Get the number of groups. */
        public final int getGroupCount()
        {
                return mGroups.length;
        }
       
        /** Set the groups. */
        public final void setGroups(MeshGroup[] groups)
        {
                mGroups = groups;
        }

}