diff --git a/build.xml b/build.xml index 13838e79..5c02a2c2 100644 --- a/build.xml +++ b/build.xml @@ -230,7 +230,16 @@ - + + + + + @@ -253,7 +262,7 @@ target="${testrsrc.dir}/config/miso/tile/fringeconf.dat"/> - @@ -277,7 +286,7 @@ - diff --git a/src/main/java/com/threerings/cast/util/CastUtil.java b/src/main/java/com/threerings/cast/util/CastUtil.java index b610408c..75f4bad6 100644 --- a/src/main/java/com/threerings/cast/util/CastUtil.java +++ b/src/main/java/com/threerings/cast/util/CastUtil.java @@ -29,6 +29,9 @@ import com.google.common.collect.Lists; import com.samskivert.util.RandomUtil; +import com.threerings.media.image.ColorPository; +import com.threerings.media.image.Colorization; + import com.threerings.cast.CharacterDescriptor; import com.threerings.cast.ComponentClass; import com.threerings.cast.ComponentRepository; @@ -41,11 +44,10 @@ import static com.threerings.cast.Log.log; public class CastUtil { /** - * Returns a new character descriptor populated with a random set of - * components. + * Returns a new character descriptor populated with a random set of components. */ public static CharacterDescriptor getRandomDescriptor ( - String gender, ComponentRepository crepo) + String gender, ComponentRepository crepo, ColorPository cpos) { // get all available classes ArrayList classes = Lists.newArrayList(); @@ -63,8 +65,7 @@ public class CastUtil // make sure there are some components in this class Iterator iter = crepo.enumerateComponentIds(cclass); if (!iter.hasNext()) { - log.info("Skipping class for which we have no components " + - "[class=" + cclass + "]."); + log.info("Skipping class for which we have no components [class=" + cclass + "]."); continue; } @@ -72,15 +73,20 @@ public class CastUtil } // select the components - int size = classes.size(); - int components[] = new int[size]; - for (int ii = 0; ii < size; ii++) { + int[] components = new int[classes.size()]; + Colorization[][] zations = new Colorization[components.length][]; + for (int ii = 0; ii < components.length; ii++) { ComponentClass cclass = classes.get(ii); // get the components available for this class ArrayList choices = Lists.newArrayList(); Iterators.addAll(choices, crepo.enumerateComponentIds(cclass)); + zations[ii] = new Colorization[COLOR_CLASSES.length]; + for (int zz = 0; zz < COLOR_CLASSES.length; zz++) { + zations[ii][zz] = cpos.getRandomStartingColor(COLOR_CLASSES[zz]).getColorization(); + } + // choose a random component if (choices.size() > 0) { int idx = RandomUtil.getInt(choices.size()); @@ -90,10 +96,13 @@ public class CastUtil } } - return new CharacterDescriptor(components, null); + return new CharacterDescriptor(components, zations); } + // these are all specific to our test resourcse protected static final String[] CLASSES = { "legs", "feet", "hand_left", "hand_right", "torso", "head", "hair", "hat", "eyepatch" }; + protected static final String[] COLOR_CLASSES = { + "skin", "hair", "textile_p", "textile_s" }; } diff --git a/src/test/java/com/threerings/miso/viewer/ViewerApp.java b/src/test/java/com/threerings/miso/viewer/ViewerApp.java index 821993b3..f1de7d8b 100644 --- a/src/test/java/com/threerings/miso/viewer/ViewerApp.java +++ b/src/test/java/com/threerings/miso/viewer/ViewerApp.java @@ -34,6 +34,7 @@ import com.threerings.resource.ResourceManager; import com.threerings.media.FrameManager; import com.threerings.media.image.ClientImageManager; +import com.threerings.media.image.ColorPository; import com.threerings.media.tile.bundle.BundledTileSetRepository; import com.threerings.miso.data.SimpleMisoSceneModel; @@ -96,9 +97,10 @@ public class ViewerApp BundledComponentRepository crepo = new BundledComponentRepository(rmgr, imgr, "components"); CharacterManager charmgr = new CharacterManager(imgr, crepo); + ColorPository cpos = ColorPository.loadColorPository(rmgr); // create our scene view panel - _panel = new ViewerSceneViewPanel(ctx, charmgr, crepo); + _panel = new ViewerSceneViewPanel(ctx, charmgr, crepo, cpos); _frame.setPanel(_panel); // load up the scene specified by the user diff --git a/src/test/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java b/src/test/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java index 357a5f69..e673cb90 100644 --- a/src/test/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java +++ b/src/test/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java @@ -27,6 +27,7 @@ import java.awt.event.MouseEvent; import com.samskivert.util.RandomUtil; +import com.threerings.media.image.ColorPository; import com.threerings.media.sprite.PathObserver; import com.threerings.media.sprite.Sprite; import com.threerings.media.sprite.SpriteManager; @@ -54,15 +55,14 @@ public class ViewerSceneViewPanel extends MisoScenePanel /** * Construct the panel and initialize it with a context. */ - public ViewerSceneViewPanel (MisoContext ctx, - CharacterManager charmgr, - ComponentRepository crepo) + public ViewerSceneViewPanel ( + MisoContext ctx, CharacterManager charmgr, ComponentRepository crepo, ColorPository cpos) { super(ctx, MisoConfig.getSceneMetrics()); // create the character descriptors - _descUser = CastUtil.getRandomDescriptor("female", crepo); - _descDecoy = CastUtil.getRandomDescriptor("male", crepo); + _descUser = CastUtil.getRandomDescriptor("female", crepo, cpos); + _descDecoy = CastUtil.getRandomDescriptor("male", crepo, cpos); // create the manipulable sprite _sprite = createSprite(_spritemgr, charmgr, _descUser); diff --git a/src/test/resources/rsrc/config/media/colordefs.xml b/src/test/resources/rsrc/config/media/colordefs.xml new file mode 100644 index 00000000..c93e4882 --- /dev/null +++ b/src/test/resources/rsrc/config/media/colordefs.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +