Moved PartFace and PartGear Cuboid boxes to CuboidShapes singleton

This commit is contained in:
Robert S 2014-10-18 09:45:05 -04:00
parent 236ee36f9b
commit 2529dda2c5
3 changed files with 31 additions and 39 deletions

View file

@ -1,20 +1,42 @@
package resonantinduction.core.prefab.part
import codechicken.lib.raytracer.IndexedCuboid6
import codechicken.lib.vec.Cuboid6
import codechicken.lib.vec.{Vector3, Rotation, Cuboid6}
/** Reference sheet for commonly created cuboid shape sets.
* Created by robert on 10/18/2014.
*/
final object CuboidShapes
{
/** 0.3 box shaped centered wire */
lazy val WIRE_SEGMENTS = getNewWireSegments()
/** 0.4 box shaped wire designed to be used for insulation */
lazy val WIRE_INSULATION = getNewWireInsulationSegments()
/** Center segment of wire */
lazy val WIRE_CENTER: IndexedCuboid6 = new IndexedCuboid6(7, new Cuboid6(0.375, 0.375, 0.375, 0.625, 0.625, 0.625))
/** 1/8th thick panel box can be used for anything flat */
lazy val PANEL = getNewPanelSegments()
/**
* Generates then returns a new set of wire segments that are .3 in size
* Generates then returns a new set of panel segments that are .125m in size
* @return 6 part matrix
*/
def getNewPanelSegments() : Array[Array[Cuboid6]] =
{
val segments = Array.ofDim[Cuboid6](6, 2);
segments(0)(0) = new Cuboid6(1 / 8D, 0, 0, 7 / 8D, 1 / 8D, 1)
segments(0)(1) = new Cuboid6(0, 0, 1 / 8D, 1, 1 / 8D, 7 / 8D)
for (s <- 1 until 6)
{
val t = Rotation.sideRotations(s).at(Vector3.center)
segments(s)(0) = segments(0)(0).copy().apply(t)
segments(s)(1) = segments(0)(1).copy().apply(t)
}
return segments
}
/**
* Generates then returns a new set of wire segments that are .3m in size
* @return 7 part array
*/
def getNewWireSegments() : Array[IndexedCuboid6] =
@ -31,7 +53,7 @@ final object CuboidShapes
}
/**
* Generates then returns a new set of insulation segments that are .4 in size
* Generates then returns a new set of insulation segments that are .4m in size
* @return 7 part array
*/
def getNewWireInsulationSegments() : Array[IndexedCuboid6] =

View file

@ -4,7 +4,7 @@ import java.lang.{Iterable => JIterable}
import java.util.{ArrayList, List}
import codechicken.lib.data.{MCDataInput, MCDataOutput}
import codechicken.lib.vec.{Cuboid6, Rotation, Vector3}
import codechicken.lib.vec.{Cuboid6, Rotation}
import codechicken.microblock.FaceMicroClass
import codechicken.multipart._
import net.minecraft.item.ItemStack
@ -19,21 +19,6 @@ import scala.collection.convert.wrapAll._
* A part that acts as a face
* @author Calclavia
*/
object PartFace
{
val bounds = Array.ofDim[Cuboid6](6, 2)
bounds(0)(0) = new Cuboid6(1 / 8D, 0, 0, 7 / 8D, 1 / 8D, 1)
bounds(0)(1) = new Cuboid6(0, 0, 1 / 8D, 1, 1 / 8D, 7 / 8D)
for (s <- 1 until 6)
{
val t = Rotation.sideRotations(s).at(Vector3.center)
bounds(s)(0) = bounds(0)(0).copy().apply(t)
bounds(s)(1) = bounds(0)(1).copy().apply(t)
}
}
abstract class PartFace extends PartAbstract with TCuboidPart with JNormalOcclusion with TFacePart
{
/**
@ -71,7 +56,7 @@ abstract class PartFace extends PartAbstract with TCuboidPart with JNormalOcclus
override def solid(arg0: Int): Boolean = true
override def getOcclusionBoxes: JIterable[Cuboid6] = PartFace.bounds(placementSide.ordinal).toList
override def getOcclusionBoxes: JIterable[Cuboid6] = CuboidShapes.PANEL(placementSide.ordinal).toList
override def occlusionTest(npart: TMultiPart): Boolean = NormalOcclusionTest.apply(this, npart)

View file

@ -2,7 +2,7 @@ package resonantinduction.mechanical.mech.gear
import java.util
import codechicken.lib.vec.{Cuboid6, Rotation, Transformation, Vector3}
import codechicken.lib.vec.{Cuboid6, Vector3}
import codechicken.microblock.FaceMicroClass
import codechicken.multipart.ControlKeyModifer
import cpw.mods.fml.relauncher.{Side, SideOnly}
@ -15,6 +15,7 @@ import net.minecraftforge.common.util.ForgeDirection
import resonant.lib.multiblock.reference.IMultiBlockStructure
import resonant.lib.utility.WrenchUtility
import resonantinduction.core.Reference
import resonantinduction.core.prefab.part.CuboidShapes
import resonantinduction.mechanical.MechanicalContent
import resonantinduction.mechanical.mech.PartMechanical
import universalelectricity.api.core.grid.INode
@ -23,22 +24,6 @@ import universalelectricity.core.transform.vector.VectorWorld
/** We assume all the force acting on the gear is 90 degrees.
*
* @author Calclavia */
object PartGear
{
var oBoxes: Array[Array[Cuboid6]] = new Array[Array[Cuboid6]](6)
oBoxes(0)(0) = new Cuboid6(1 / 8D, 0, 0, 7 / 8D, 1 / 8D, 1)
oBoxes(0)(1) = new Cuboid6(0, 0, 1 / 8D, 1, 1 / 8D, 7 / 8D)
for(s <- 1 until 6)
{
val t: Transformation = Rotation.sideRotations(s).at(Vector3.center)
oBoxes(s)(0) = oBoxes(0)(0).copy.apply(t)
oBoxes(s)(1) = oBoxes(0)(1).copy.apply(t)
}
}
class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
{
var isClockwiseCrank: Boolean = true
@ -191,7 +176,7 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
def getOcclusionBoxes: java.lang.Iterable[Cuboid6] =
{
val list: java.util.List[Cuboid6] = new util.ArrayList[Cuboid6];
for (v <- PartGear.oBoxes(this.placementSide.ordinal))
for (v <- CuboidShapes.PANEL(this.placementSide.ordinal))
{
list.add(v)
}