Class Shape3d

java.lang.Object
com.ijurnove.cpu3d.Shape3d
All Implemented Interfaces:
Rotatable, Scalable, Translatable

public class Shape3d extends Object implements Translatable, Rotatable, Scalable
Shape3ds represent a three-dimensional shape with a texture and a material.
  • Constructor Details

    • Shape3d

      public Shape3d(Mesh mesh, BufferedImage texture, Material material)
      Constructs a Shape3d with a specified Mesh, Material, and a texture represented by a BufferedImage.
      Parameters:
      mesh - the specified Mesh
      texture - the specified texture
      material - the specified Material
    • Shape3d

      public Shape3d(Triangle[] triangles)
      Constructs a Shape3d with the given Triangle[], without a texture or Material.
  • Method Details

    • getShapeFlag

      public int getShapeFlag(ShapeFlag flag)
      Returns the value of a specified ShapeFlag.
      Refer to ShapeFlag to see what each one does.
      Parameters:
      flag - the specified ShapeFlag
      Returns:
      the value of the ShapeFlag
    • setShapeFlag

      public void setShapeFlag(ShapeFlag flag, int value)
      Sets the value of a specified ShapeFlag to a given value.
      Refer to ShapeFlag to see what each one does.
      Parameters:
      flag - the specified ShapeFlag
      value - the new value
    • copy

      public Shape3d copy()
      Returns a new Shape3d that is a copy of this one with new references.
      Returns:
      an identical Shape3d
    • getTriangles

      public Triangle[] getTriangles()
      Returns this Shape3d's Triangle array.
      Returns:
      the Triangle[] of this Shape3d
    • getTexture

      public BufferedImage getTexture()
      Returns the texture of this Shape3d as a BufferedImage.
      Returns:
      the texture of this Shape3d
    • getMaterial

      public Material getMaterial()
      Returns the Material of this Shape3d.
      Returns:
      the Material of this Shape3d
    • setParent

      public void setParent(Scene parent)
      Sets the parent of this Shape3d to a given Scene.
      Parameters:
      parent - the specified parent Scene
    • setTexture

      public void setTexture(BufferedImage texture)
      Sets the texture of this Shape3d to a given BufferedImage.
      Parameters:
      texture - the specified BufferedImage
    • setMaterial

      public void setMaterial(Material material)
      Sets the Material of this Shape3d.
      Parameters:
      material - the Material to set
    • flipNormals

      public void flipNormals()
      Inverts all surface and point normals of this Shape3d, essentially flipping it inside out.
    • scale

      public void scale(double scale, Point3d point)
      Description copied from interface: Scalable
      Scales this object by a given amount from a point.
      Specified by:
      scale in interface Scalable
      Parameters:
      scale - the scale multiplier
      point - the point that this object should be scaled from
    • rotate

      protected void rotate(int axis, double theta)
    • rotate

      public void rotate(int axis, double theta, Point3d point)
      Description copied from interface: Rotatable
      Rotates this object about a given point on a specified axis. 0 corresponds to the X axis, 1 corresponds to the Y axis, and 2 corresponds to the Z axis.
      Specified by:
      rotate in interface Rotatable
      Parameters:
      axis - the axis to rotate around
      theta - the radians to rotate by
      point - the center point to rotate around
    • translate

      public void translate(double x, double y, double z)
      Description copied from interface: Translatable
      Shifts this object's X, Y, and Z position by the given values.
      Specified by:
      translate in interface Translatable
      Parameters:
      x - how far the object should be translated along the X axis
      y - how far the object should be translated along the Y axis
      z - how far the object should be translated along the Z axis
    • uniqueVertices

      public Point3d[] uniqueVertices()
      Returns a Point3d array consisting of every unique vertex in this Shape3d.
      Returns:
      a list of every unique vertex
    • uniquePointNormals

      public Vector3d[] uniquePointNormals()
      Returns a Vector3d array consisting of every unique point normal in this Shape3d.
      Returns:
      a list of every unique point normal
    • perspProjectionForPointShadowMap

      protected void perspProjectionForPointShadowMap(Camera c)
    • perspProjection

      protected void perspProjection(Camera c)
    • orthoProjection

      protected void orthoProjection(Camera c)
    • center

      public Point3d center()
      Calculates and returns the center of this Shape3d as a Point3d.
      Returns:
      the center of this Shape3d