CubeTwister 2.0alpha141 2011-10-13

ch.randelshofer.rubik
Class AbstractCubeIdx3D

java.lang.Object
  extended by ch.randelshofer.rubik.AbstractCube3D
      extended by ch.randelshofer.rubik.AbstractCubeIdx3D
All Implemented Interfaces:
Cube3D, CubeListener, java.beans.PropertyChangeListener, java.util.EventListener, javax.swing.event.ChangeListener
Direct Known Subclasses:
AbstractCube6Idx3D, AbstractCube7Idx3D, AbstractPocketCubeIdx3D, AbstractProfessorCubeIdx3D, AbstractRevengeCubeIdx3D, AbstractRubiksCubeIdx3D

public abstract class AbstractCubeIdx3D
extends AbstractCube3D

Abstract base class for the geometrical representation of a Cube using the Idx3D engine.

Version:
1.1 2010-04-05 Added inStartedPlayer property.
1.0.1 2008-04-27 Stickers were not always made visible.
1.0 January 6, 2006 Created.
Author:
Werner Randelshofer

Nested Class Summary
 
Nested classes/interfaces inherited from class ch.randelshofer.rubik.AbstractCube3D
AbstractCube3D.PartAction, AbstractCube3D.SwipeAction
 
Field Summary
protected  idx3d_Group alphaBetaTransform
           
protected  java.awt.Image cachedStickersImage
           
protected  int centerCount
           
protected  int centerOffset
           
protected  int cornerCount
           
protected  int cornerOffset
           
protected  int edgeCount
           
protected  int edgeOffset
           
protected  float explosion
           
protected  float explosionShift
           
protected  idx3d_Group[] explosionTransforms
          Holds the explosionTransforms of the parts in the sequence: corners, edges, sides and center.
protected static float HALF_PI
           
protected  idx3d_Matrix[] identityNormalMatrix
           
protected  idx3d_Matrix[] identityVertexMatrix
          Holds the identity locationTransforms of the parts.
protected  boolean isInStartedPlayer
           
protected  idx3d_Group[] locationTransforms
          Holds the locationTransforms of the parts in the sequence: corners, edges, sides and center.
protected  int partCount
           
protected  idx3d_Object[] parts
          Holds the parts in the sequence: corners, edges, sides and center.
protected  float PI
           
protected  idx3d_Group scaleTransform
           
protected  idx3d_Scene scene
           
protected static idx3d_Lightmap sharedLightmap
           
protected  int sideCount
           
protected  int sideOffset
           
protected  idx3d_Texture stickersTexture
           
 
Fields inherited from class ch.randelshofer.rubik.AbstractCube3D
attributes, changeEvent, dispatcher, isAnimated, layerCount, listenerList
 
Constructor Summary
AbstractCubeIdx3D(int layerCount, int cornerCount, int edgeCount, int sideCount, int centerCount)
          Creates a new instance.
 
Method Summary
 void dispose()
          Frees resources used by the 3D cube.
 java.lang.Object getLock()
          Returns the lock object used for synchronizing model and view changes.
protected  idx3d_Object getPart(int partIndex)
           
 int getPartCount()
           
 java.lang.Object getScene()
          Returns the 3D scene of the cube.
protected  float getUnitScaleFactor()
           
protected abstract  void initActions(idx3d_Scene scene)
           
 boolean isInStartedPlayer()
          Returns true if the cube is in a started script player.
 void setInStartedPlayer(boolean newValue)
          This is set to true by the script player if it is started.
abstract  void setStickerBeveling(float newValue)
           
protected  void updateAlphaBeta()
           
protected  void updateAttributes()
           
protected  void updateCube()
           
protected  void updateExplosionFactor()
           
protected  void updateExplosionFactor(float factor)
           
protected  void updatePartFillColor(int index, java.awt.Color c)
          Updates the fill color of a part.
protected  void updatePartOutlineColor(int index, java.awt.Color c)
           
protected  void updatePartsFillColor()
          Updates the fill color of the parts.
protected  void updatePartsVisibility()
          Updates the visible state of the parts.
protected  void updatePartVisibility(int index, float alpha)
          Updates the visibility of a part.
protected  void updateScaleFactor()
           
protected  void updateScaleFactor(float factor)
           
protected  void updateStickerFillColor(int index, java.awt.Color c)
           
protected  void updateStickersFillColor()
          Updates the stickers color of the parts.
protected  void updateStickersImage()
          Updates the sticker imagery.
protected  void updateStickerVisibility(int index, float alpha)
          Updates the visibility of a sticker.
protected  void validateAlphaBeta()
           
protected  void validateAttributes()
           
protected  void validateCube()
           
protected  void validateScaleFactor()
           
protected  void validateStickersImage()
           
protected abstract  void validateTwist(int[] partIndices, int[] locations, int[] orientations, int length, int axis, int angle, float alpha)
           
 
Methods inherited from class ch.randelshofer.rubik.AbstractCube3D
addChangeListener, addCube3DListener, createAttributes, cubeChanged, cubeTwisted, dispatch, fireActionPerformed, fireMouseEntered, fireMouseExited, fireMousePressed, fireMouseReleased, fireStateChanged, getAnimator, getAttributes, getCube, getDispatcher, getPartFaceIndexForStickerIndex, getPartIndexForStickerIndex, getStickerCount, isAdjusting, isAnimated, isAnimating, isShowGhostParts, propertyChange, removeChangeListener, removeCube3DListener, setAnimated, setAnimator, setAttributes, setCube, setDispatcher, setLock, setShowGhostParts, stateChanged, stopAnimation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ch.randelshofer.rubik.Cube3D
getKind
 

Field Detail

cornerCount

protected int cornerCount

edgeCount

protected int edgeCount

sideCount

protected int sideCount

centerCount

protected int centerCount

partCount

protected int partCount

cornerOffset

protected int cornerOffset

edgeOffset

protected int edgeOffset

sideOffset

protected int sideOffset

centerOffset

protected int centerOffset

sharedLightmap

protected static idx3d_Lightmap sharedLightmap

scene

protected idx3d_Scene scene

alphaBetaTransform

protected idx3d_Group alphaBetaTransform

scaleTransform

protected idx3d_Group scaleTransform

cachedStickersImage

protected java.awt.Image cachedStickersImage

stickersTexture

protected idx3d_Texture stickersTexture

HALF_PI

protected static final float HALF_PI
See Also:
Constant Field Values

PI

protected final float PI
See Also:
Constant Field Values

explosionShift

protected float explosionShift

parts

protected idx3d_Object[] parts
Holds the parts in the sequence: corners, edges, sides and center.


identityVertexMatrix

protected idx3d_Matrix[] identityVertexMatrix
Holds the identity locationTransforms of the parts. The identity locationTransforms represent the cube in solved state.


identityNormalMatrix

protected idx3d_Matrix[] identityNormalMatrix

locationTransforms

protected idx3d_Group[] locationTransforms
Holds the locationTransforms of the parts in the sequence: corners, edges, sides and center.


explosionTransforms

protected idx3d_Group[] explosionTransforms
Holds the explosionTransforms of the parts in the sequence: corners, edges, sides and center.


explosion

protected float explosion

isInStartedPlayer

protected boolean isInStartedPlayer
Constructor Detail

AbstractCubeIdx3D

public AbstractCubeIdx3D(int layerCount,
                         int cornerCount,
                         int edgeCount,
                         int sideCount,
                         int centerCount)
Creates a new instance.

Method Detail

getScene

public java.lang.Object getScene()
Description copied from class: AbstractCube3D
Returns the 3D scene of the cube. We return an Object type here, because the type of the 3D scene depends on the 3D engine used.

Specified by:
getScene in interface Cube3D
Specified by:
getScene in class AbstractCube3D

getLock

public java.lang.Object getLock()
Description copied from class: AbstractCube3D
Returns the lock object used for synchronizing model and view changes.

Specified by:
getLock in interface Cube3D
Overrides:
getLock in class AbstractCube3D

getPartCount

public int getPartCount()

initActions

protected abstract void initActions(idx3d_Scene scene)

updateAttributes

protected void updateAttributes()
Specified by:
updateAttributes in class AbstractCube3D

validateAttributes

protected void validateAttributes()

updatePartFillColor

protected void updatePartFillColor(int index,
                                   java.awt.Color c)
Updates the fill color of a part. The part Index is interpreted according to the scheme used by method getPart(int);


updatePartOutlineColor

protected void updatePartOutlineColor(int index,
                                      java.awt.Color c)

updateStickerFillColor

protected void updateStickerFillColor(int index,
                                      java.awt.Color c)

updateStickerVisibility

protected void updateStickerVisibility(int index,
                                       float alpha)
Updates the visibility of a sticker.

Specified by:
updateStickerVisibility in class AbstractCube3D

validateScaleFactor

protected void validateScaleFactor()

updateScaleFactor

protected void updateScaleFactor()

getUnitScaleFactor

protected float getUnitScaleFactor()

updateScaleFactor

protected void updateScaleFactor(float factor)
Specified by:
updateScaleFactor in class AbstractCube3D

updateExplosionFactor

protected void updateExplosionFactor()

updateExplosionFactor

protected void updateExplosionFactor(float factor)
Specified by:
updateExplosionFactor in class AbstractCube3D

updateAlphaBeta

protected void updateAlphaBeta()
Specified by:
updateAlphaBeta in class AbstractCube3D

validateAlphaBeta

protected void validateAlphaBeta()

getPart

protected idx3d_Object getPart(int partIndex)

updateStickersImage

protected void updateStickersImage()
Description copied from class: AbstractCube3D
Updates the sticker imagery.

Specified by:
updateStickersImage in class AbstractCube3D

validateStickersImage

protected void validateStickersImage()

dispose

public void dispose()
Frees resources used by the 3D cube.

Specified by:
dispose in interface Cube3D
Overrides:
dispose in class AbstractCube3D

updateCube

protected void updateCube()
Specified by:
updateCube in class AbstractCube3D

validateCube

protected void validateCube()

validateTwist

protected abstract void validateTwist(int[] partIndices,
                                      int[] locations,
                                      int[] orientations,
                                      int length,
                                      int axis,
                                      int angle,
                                      float alpha)

updatePartVisibility

protected void updatePartVisibility(int index,
                                    float alpha)
Updates the visibility of a part. The part Index is interpreted according to the scheme used by method getPart(int);

Specified by:
updatePartVisibility in class AbstractCube3D

updatePartsVisibility

protected final void updatePartsVisibility()
Updates the visible state of the parts.


updatePartsFillColor

protected final void updatePartsFillColor()
Updates the fill color of the parts.


updateStickersFillColor

protected final void updateStickersFillColor()
Updates the stickers color of the parts.


setStickerBeveling

public abstract void setStickerBeveling(float newValue)

setInStartedPlayer

public void setInStartedPlayer(boolean newValue)
Description copied from interface: Cube3D
This is set to true by the script player if it is started.


isInStartedPlayer

public boolean isInStartedPlayer()
Description copied from interface: Cube3D
Returns true if the cube is in a started script player.


(c) Werner Randelshofer.
All rights reserved.