Commit in batoru/src/games/batoru/entities on MAIN | |||
TreeEntity.java | +93 | added 1.1 | |
BulletEntity.java | +89 | added 1.1 | |
+182 |
Class added because Entities now must know how render themselves.
diff -N TreeEntity.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TreeEntity.java 1 Dec 2003 22:49:26 -0000 1.1 @@ -0,0 +1,93 @@
+/* + * Created on Nov 28, 2003 + */ +package games.batoru.entities; + +import javax.vecmath.Point3f; + +import net.java.games.jogl.GL; +import net.java.games.jogl.GLU; +import net.java.games.jogl.GLUquadric; +import net.java.games.jogl.util.GLUT; + +import org.codejive.utils4gl.GLColor; +import org.codejive.utils4gl.RenderContext; +import org.codejive.world3d.Entity; +import org.codejive.world3d.Universe; + +/** + * @author tako + * @version $Revision$ + */ +public class TreeEntity extends Entity { + static final GLColor m_trunkColor = new GLColor(.5f, .25f, 0); + static final GLColor m_coneColor = new GLColor(0, .5f, .25f); + int m_nTreeShapeList; + + public TreeEntity() { + super(); + } + + public TreeEntity(Universe _universe, Point3f _position) { + super(_universe, _position, 0.0f); + } + + public void initRendering(RenderContext _context) { + GL gl = _context.getGl(); + GLU glu = _context.getGlu(); + GLUT glut = _context.getGlut(); + + m_nTreeShapeList = gl.glGenLists(1); + gl.glNewList(m_nTreeShapeList, GL.GL_COMPILE); + + gl.glPushMatrix(); + gl.glColor3f(m_trunkColor.getRed(), m_trunkColor.getGreen(), m_trunkColor.getBlue()); + gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); + GLUquadric quad = glu.gluNewQuadric(); + glu.gluCylinder(quad, 0.2d, 0.2d, 1.6d, 6, 1); + glu.gluDeleteQuadric(quad); + gl.glPopMatrix(); + + gl.glPushMatrix(); + gl.glColor3f(m_coneColor.getRed(), m_coneColor.getGreen(), m_coneColor.getBlue()); + gl.glTranslatef(0.0f, 1.6f, 0.0f); + gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); + glut.glutSolidCone(glu, 0.7f, 4.0f, 6, 1); + gl.glPopMatrix(); + + gl.glEndList(); + + super.initRendering(_context); + } + + public void render(RenderContext _context) { + _context.getGl().glCallList(m_nTreeShapeList); +/* + GL gl = _context.getGl(); + GLU glu = _context.getGlu(); + GLUT glut = _context.getGlut(); + + gl.glPushMatrix(); + gl.glColor3f(m_trunkColor.getRed(), m_trunkColor.getGreen(), m_trunkColor.getBlue()); + gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); + GLUquadric quad = glu.gluNewQuadric(); + glu.gluCylinder(quad, 0.2d, 0.2d, 1.6d, 6, 1); + glu.gluDeleteQuadric(quad); + gl.glPopMatrix(); + + gl.glPushMatrix(); + gl.glColor3f(m_coneColor.getRed(), m_coneColor.getGreen(), m_coneColor.getBlue()); + gl.glTranslatef(0.0f, 1.6f, 0.0f); + gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); + glut.glutSolidCone(glu, 0.7f, 4.0f, 6, 1); + gl.glPopMatrix(); +*/ + } +} + +/* + * $Log$ + * Revision 1.1 2003/12/01 22:49:26 tako + * Class added because Entities now must know how render themselves. + * + */
\ No newline at end of file
diff -N BulletEntity.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ BulletEntity.java 1 Dec 2003 22:49:26 -0000 1.1 @@ -0,0 +1,89 @@
+/* + * Created on Nov 28, 2003 + */ +package games.batoru.entities; + +import java.awt.Color; + +import javax.vecmath.Point3f; +import javax.vecmath.Vector3f; + +import net.java.games.jogl.GL; +import net.java.games.jogl.GLU; +import net.java.games.jogl.GLUquadric; + +import org.codejive.utils4gl.GLColor; +import org.codejive.utils4gl.RenderContext; +import org.codejive.world3d.Entity; +import org.codejive.world3d.Universe; + +/** + * @author tako + * @version $Revision$ + */ +public class BulletEntity extends Entity { + private int m_nBulletShapeList; + + private static final GLColor m_bullet2Color = new GLColor(Color.YELLOW, 0.7f); + + public BulletEntity() { + super(); + } + + public BulletEntity(Universe _universe, Point3f _position, Vector3f _impulse, float _fGravityFactor) { + super(_universe, _position, _impulse, _fGravityFactor); + } + + public void initRendering(RenderContext _context) { + GL gl = _context.getGl(); + GLU glu = _context.getGlu(); + +/* m_nBulletShapeList = gl.glGenLists(1); + gl.glNewList(m_nBulletShapeList, GL.GL_COMPILE); + + gl.glDepthMask(false); + gl.glEnable(GL.GL_BLEND); + gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); + + GLUquadric quad = glu.gluNewQuadric(); + glu.gluSphere(quad, 0.1d, 6, 6); + glu.gluSphere(quad, 0.2d, 6, 6); + glu.gluSphere(quad, 0.3d, 6, 6); + glu.gluDeleteQuadric(quad); + + gl.glDisable(GL.GL_BLEND); + gl.glDepthMask(true); + + gl.glEndList(); +*/ + super.initRendering(_context); + } + + public void render(RenderContext _context) { + GL gl = _context.getGl(); + GLU glu = _context.getGlu(); + + gl.glColor4f(m_bullet2Color.getRed(), (float)Math.random(), m_bullet2Color.getBlue(), 0.5f); +// _context.getGl().glCallList(m_nBulletShapeList); + + gl.glDepthMask(false); + gl.glEnable(GL.GL_BLEND); + gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); + + GLUquadric quad = glu.gluNewQuadric(); + glu.gluSphere(quad, 0.1d, 6, 6); + glu.gluSphere(quad, 0.2d, 6, 6); + glu.gluSphere(quad, 0.3d, 6, 6); + glu.gluDeleteQuadric(quad); + + gl.glDisable(GL.GL_BLEND); + gl.glDepthMask(true); + } +} + +/* + * $Log$ + * Revision 1.1 2003/12/01 22:49:26 tako + * Class added because Entities now must know how render themselves. + * + */
\ No newline at end of file