Fixed gear shaft rotation direction

This commit is contained in:
Calclavia 2014-11-10 19:28:36 +08:00
parent f713f9e46c
commit 50bd4d9af0
11 changed files with 28 additions and 19 deletions

View file

@ -43,10 +43,10 @@ trait TMechanicalNode extends INode with IVectorWorld
/**
* Does the direction flip on this side for rotation
*
* @param from - The side of the mechanical device
* @param other - The other mechanical node
* @return boolean, true = flipped, false = not
*/
def inverseRotation(from: ForgeDirection): Boolean = false
def inverseRotation(other: TMechanicalNode): Boolean = true
/**
* Applies rotational force and velocity to this node increasing its current rotation value

View file

@ -57,8 +57,7 @@ abstract class PartMechanical extends PartAbstract with JNormalOcclusion with TF
{
if (!world.isRemote)
{
println(mechanicalNode)
println(mechanicalNode.getMechanicalGrid)
println("Vel: " + mechanicalNode.angularVelocity)
}
super.activate(player, hit, item)

View file

@ -6,8 +6,9 @@ import net.minecraft.tileentity.TileEntity
import net.minecraftforge.common.util.ForgeDirection
import resonant.api.grid.INodeProvider
import resonant.lib.transform.vector.{IVectorWorld, Vector3, VectorWorld}
import resonant.lib.wrapper.ForgeDirectionWrapper._
import resonantinduction.core.interfaces.TMechanicalNode
import resonantinduction.mechanical.mech.gearshaft.PartGearShaft
import resonantinduction.mechanical.mech.gearshaft.{GearShaftNode, PartGearShaft}
import resonantinduction.mechanical.mech.grid.MechanicalNode
/**
@ -119,7 +120,7 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
//We are connecting to a shaft.
val shaft = parent.asInstanceOf[PartGearShaft]
//Check if the shaft is directing connected to the center of the gear (multiblock cases) and also its direction to make sure the shaft is facing the gear itself
return /*shaft.tile.partMap(from.getOpposite.ordinal) != gear && */Math.abs(shaft.placementSide.offsetX) == Math.abs(gear.placementSide.offsetX) && Math.abs(shaft.placementSide.offsetY) == Math.abs(gear.placementSide.offsetY) && Math.abs(shaft.placementSide.offsetZ) == Math.abs(gear.placementSide.offsetZ)
return /*shaft.tile.partMap(from.getOpposite.ordinal) != gear && */ Math.abs(shaft.placementSide.offsetX) == Math.abs(gear.placementSide.offsetX) && Math.abs(shaft.placementSide.offsetY) == Math.abs(gear.placementSide.offsetY) && Math.abs(shaft.placementSide.offsetZ) == Math.abs(gear.placementSide.offsetZ)
}
else if (parent.isInstanceOf[PartGear])
{
@ -196,6 +197,8 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
return false
}
override def inverseRotation(other: TMechanicalNode): Boolean = !other.isInstanceOf[GearShaftNode] || (other.isInstanceOf[GearShaftNode] && parent.placementSide.offset < Vector3.zero)
override def getRadius(dir: ForgeDirection, other: TMechanicalNode): Double =
{
val deltaPos: Vector3 = new VectorWorld(other.asInstanceOf[IVectorWorld]).subtract(toVectorWorld)

View file

@ -199,7 +199,8 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
return FaceMicroClass.aBounds(0x10 | this.placementSide.ordinal)
}
@SideOnly(Side.CLIENT) override def getRenderBounds: Cuboid6 = Cuboid6.full.copy.expand(multiBlockRadius)
@SideOnly(Side.CLIENT)
override def getRenderBounds: Cuboid6 = Cuboid6.full.copy.expand(multiBlockRadius)
override def toString = "[PartGear]" + x + "x " + y + "y " + z + "z " + getSlotMask + "s "
}

View file

@ -9,6 +9,7 @@ import net.minecraftforge.common.util.ForgeDirection
import org.lwjgl.opengl.GL11
import resonant.content.prefab.scal.render.ISimpleItemRenderer
import resonant.lib.render.RenderUtility
import resonant.lib.wrapper.ForgeDirectionWrapper._
import resonantinduction.core.Reference
@SideOnly(Side.CLIENT)
@ -51,7 +52,7 @@ object RenderGear extends ISimpleItemRenderer
GL11.glPushMatrix()
GL11.glTranslatef(x.toFloat + 0.5f, y.toFloat + 0.5f, z.toFloat + 0.5f)
GL11.glPushMatrix()
renderGear(part.placementSide.ordinal, part.tier, part.getMultiBlock.isConstructed, Math.toDegrees(part.mechanicalNode.angle) * (part.placementSide.offsetX + part.placementSide.offsetY + part.placementSide.offsetZ))
renderGear(part.placementSide.ordinal, part.tier, part.getMultiBlock.isConstructed, Math.toDegrees(part.mechanicalNode.angle))
GL11.glPopMatrix()
GL11.glPopMatrix()
}

View file

@ -3,7 +3,9 @@ package resonantinduction.mechanical.mech.gearshaft
import net.minecraftforge.common.util.ForgeDirection
import resonant.api.grid.INodeProvider
import resonant.lib.transform.vector.Vector3
import resonantinduction.mechanical.mech.gear.PartGear
import resonant.lib.wrapper.ForgeDirectionWrapper._
import resonantinduction.core.interfaces.TMechanicalNode
import resonantinduction.mechanical.mech.gear.{GearNode, PartGear}
import resonantinduction.mechanical.mech.grid.MechanicalNode
class GearShaftNode(parent: PartGearShaft) extends MechanicalNode(parent)
@ -78,7 +80,7 @@ class GearShaftNode(parent: PartGearShaft) extends MechanicalNode(parent)
return from == shaft.placementSide || from == shaft.placementSide.getOpposite
}
override def inverseRotation(dir: ForgeDirection): Boolean = false
override def inverseRotation(other: TMechanicalNode): Boolean = other.isInstanceOf[GearNode] && other.asInstanceOf[GearNode].parent.asInstanceOf[PartGear].placementSide.offset < Vector3.zero
def shaft: PartGearShaft = getParent.asInstanceOf[PartGearShaft]
}

View file

@ -11,11 +11,11 @@ import org.lwjgl.opengl.GL11.glRotatef
import resonant.content.prefab.scal.render.ISimpleItemRenderer
import resonant.lib.render.RenderUtility
import resonantinduction.core.Reference
import resonant.lib.wrapper.ForgeDirectionWrapper._
@SideOnly(Side.CLIENT)
object RenderGearShaft extends ISimpleItemRenderer
{
final val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "gears.obj"))
val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "gears.obj"))
def renderInventoryItem(`type`: IItemRenderer.ItemRenderType, itemStack: ItemStack, data: AnyRef*)
{
@ -51,7 +51,8 @@ object RenderGearShaft extends ISimpleItemRenderer
{
glRotatef(90, 0, 0, 1)
}
GL11.glRotatef(Math.toDegrees(part.mechanicalNode.angle).asInstanceOf[Float], 0, 1, 0)
GL11.glRotated(Math.toDegrees(part.mechanicalNode.angle) * part.placementSide.offset.toArray.sum, 0, 1, 0)
if (part.tier == 1)
{

View file

@ -1,6 +1,5 @@
package resonantinduction.mechanical.mech.grid
import net.minecraftforge.common.util.ForgeDirection
import resonant.api.grid.IUpdate
import resonant.lib.grid.{GridNode, UpdateTicker}
@ -40,7 +39,8 @@ class MechanicalGrid extends GridNode[MechanicalNode](classOf[MechanicalNode]) w
override protected def populateNode(node: MechanicalNode, prev: MechanicalNode)
{
super.populateNode(node, prev)
spinMap += (node -> (if (prev != null) !spinMap(prev) && node.inverseRotation(ForgeDirection.UNKNOWN) && prev.inverseRotation(ForgeDirection.UNKNOWN) else false))
val dir = if (prev != null) (if (node.inverseRotation(prev)) !spinMap(prev) else spinMap(prev)) else false
spinMap += (node -> dir)
}
override def update(deltaTime: Double)

View file

@ -22,9 +22,9 @@ class GrinderNode(parent: TileGrindingWheel) extends MechanicalNode(parent: Tile
return grider.getDirection != from && grider.getDirection.getOpposite != from
}
/*
override def inverseRotation(dir: ForgeDirection): Boolean =
{
return !(dir.offsetX > 0 || dir.offsetZ < 0 || dir.offsetY < 0)
}
}*/
}

View file

@ -15,8 +15,9 @@ class MixerNode(parent: INodeProvider) extends MechanicalNode(parent)
return direction == ForgeDirection.DOWN || direction == ForgeDirection.UP
}
/*
override def inverseRotation(dir: ForgeDirection): Boolean =
{
return dir == ForgeDirection.DOWN
}
}*/
}

View file

@ -22,8 +22,9 @@ class TurbineNode(tileTurbineBase: TileTurbine) extends MechanicalNode(tileTurbi
return turbine.getMultiBlock.isPrimary && other.isInstanceOf[MechanicalNode] && !(other.isInstanceOf[TurbineNode]) && from == turbine.getDirection
}
/**
override def inverseRotation(dir: ForgeDirection): Boolean =
{
return dir == turbine.getDirection.getOpposite
}
}*/
}