Aktualisierungen November, 2011 Kommentarverlauf ein-/ausschalten | Tastaturkürzel

  • Andreas Höhmann 12:15 am Thursday, 17. November 2011 Permalink |
    Tags: guava, hierarchical, iterator   

    Hierarchical Iterator 

    import static com.google.common.collect.ImmutableList.of;
    import java.util.Iterator;
    import java.util.LinkedList;
    import com.google.common.collect.AbstractIterator;
    import com.google.common.collect.Lists;
     * This Iterator could be used for hierarchical data structure (e.g. Trees).
     * @author Andreas Höhmann
     * @param <T>
    public abstract class AbstractHierarchialIterator<T> extends AbstractIterator<T> {
       private final LinkedList<Iterable<T>> stack = Lists.newLinkedList();
       private Iterator<T> current;
       public AbstractHierarchialIterator(final T start) {
       private AbstractHierarchialIterator(final Iterable<T> start) {
          current = start.iterator();
        * An concrete hierarchical iterator has to implement a method to 
        * visit the children of an element.
        * @param currentElement
        * @return never <code>null</code>
       protected abstract Iterable<T> childrenOf(T currentElement);
       protected T computeNext() {
          while (true) {
             if (current.hasNext()) {
                final T next = current.next();
                return next;
             if (stack.isEmpty()) {
             current = stack.removeFirst().iterator();
          return endOfData();


    AbstractHierarchialIterator<Foobar> i = 
        new AbstractHierarchialIterator<Foobar>(foobarStart) {
        protected Iterable<Foobar> childrenOf(final Foobar currentElement) {
            // <--- here you have to implement something
            return currentElement.getFoobarChildren(); 
    // example 1 - show all foobars
    while (i.hasNext()) {
    // example 2 - search the first "foo"
    Foobar foo = com.google.common.collect.Iterators.find(i, new Predicate<Foobar>() {
          public boolean apply(final Foobar input) {
            return "foo".equals(input.getName());
        }, null);


    • bkiew 17:11 am Samstag, 19. November 2011 Permalink | Zum Antworten anmelden

      Some questions.
      a) The variable „stack“ is a LinkedList, why not a real „Stack“?
      b) In which order will the children be processed? In-, pre- or post-order? It is not configurable nor documented 😛

      Greetings, Ben

    • Andreas Höhmann 1:24 am Dienstag, 22. November 2011 Permalink | Zum Antworten anmelden

      Hi Ben,

      a) what class do you mean? Vector?
      b) this iterator will do it with http://en.wikipedia.org/wiki/Breadth-first_search, this simple code doesn’t need any documentation 😉 … you are right … a next step could be the usage of the strategy pattern, in combination with the builder pattern it would be quite easy to support all aspects of traversing a hierarchical data-structure.


      • xaerxess 20:23 am Montag, 20. August 2012 Permalink | Zum Antworten anmelden

        ad. a) ArrayDeque is superior to LinkedList (and Stack of course) if you use Java 6 and don’t need List interface goodies (positional get mainly). It even outperforms ArrayList; see this benchmark.

  • Andreas Höhmann 15:10 am Friday, 19. August 2011 Permalink |
    Tags: , label,   

    VAADIN Reverse Label with CSS 

    Here is a simple example how to use CSS to change the visual representation of Vaadin components.

    The com.vaadin.ui.Label component have a caption and a icon, i.e.  „[I] Caption“.

    But I need a label like this „Caption [I]“. This could be done with the following CSS:

    .v-caption-reverseLabel {
    float: left;
    .v-caption-reverseLabel .v-icon {
    float: right;
    margin: 0px 2px 0px 2px;
    .v-caption-reverseLabel .v-captiontext {
    float: right;
    final Label label = new Label();
    label.setIcon(new ThemeResource("img/info.gif"));
  • Andreas Höhmann 10:04 am Saturday, 9. July 2011 Permalink |  

    Vaadin my first steps 

    A new customer project started this month. My team and I are creating a new web application. I’m the lead designer of the project and I think about new technologies for that application.

    After many projects with JSF and Richfaces I want to go new ways. First of all Richfaces is a great framework and you can do (almost) everything you want. But some requirements are very tricky to implement, i.e. confirmation dialog with user input, multiple windows …

    Currently I’m evaluating  Vaadin and I love it. It is so easy to use (at first sight). The java geek blog inspired me to try Vaadin.

    In the near future I will post more about my experiences. Stay tuned 🙂

  • Andreas Höhmann 2:41 am Wednesday, 2. March 2011 Permalink |  

    Next video from bloxel 0.2.0 

    Some facts:
    – heightmap based terrain generation 1024 x 1024
    – 3 different textures (grass, sand and water)
    – hardware :  Intel Core2 2.66 GHz, Nvidia GeForce Go 7950 GTX, 2GB RAM, Windows7 64bit


    Video #1

    Video #2

  • Andreas Höhmann 0:38 am Wednesday, 2. March 2011 Permalink |
    Tags: , mesh, multitexture   

    MultiFaceBox mesh for bloxel 

    News from bloxel …

    Last days I spend a couple of hours creating a box mesh for our game bloxel which have different textures for each side … like this one …

    … without success … until now *g*

    First of all jmonkey rocks … but the multi texture support is not easy to use/understand for a rookie like me.

    Here the thinks I checked out:

    • http://jmonkeyengine.org/groups/general-2/forum/topic/box-with-multiple-textures/
      • the idea here was to create a box in a editor, and generate mapping coordinates for it, then  import it into JME with the ogre xml importer
      • paddy (bloxel team member) tried this approach with blender, the result was an .obj file with two geometries inside a) the grass geo on top and b) the dirt geos on the other sides
      • long story short end … this doesn’t work very well
    • then I tried the jme3 sky material
      • this material use a TextureCubeMap (multiple images for cube sides)
      • not working for me … sky material is only for sky-boxes I guess
    • then I want use shaders (glsl) to get the different textures on the box
      • but my knowledge about glsl is near zero *gg* … so I tried to find shader-code with google … no success
    • then I found the jme2 class MultiFaceBox
      • ported to jme3 was quite simple
      • play a little bit with the right texture
      • and voilà … here we are
    public class MultiFaceBox extends Box {
      public MultiFaceBox() {
      public MultiFaceBox(final Vector3f center, final float xExtent, final float yExtent, final float zExtent) {
        super(center, xExtent, yExtent, zExtent);
      public MultiFaceBox(final Vector3f min, final Vector3f max) {
        super(min, max);
      private void remap() {
        final FloatBuffer fb = getFloatBuffer(Type.TexCoord);
        for (int i = 0; i < 6; i++) {
          final float top = i / 8f;
          final float bottom = (i + 1) / 8f;
          final float[] tex = new float[] { 1, bottom, 0, bottom, 0, top, 1, top };

    This works for me … now I can remove the unused two empty areas in the texture …

  • Andreas Höhmann 22:05 am Saturday, 19. February 2011 Permalink |
    Tags: , heightmap,   

    Heightmap based terrain loading for bloxel 

    Last night I finished the first prototype of a heightmap based TerrainLoader.

    • I’m using a com.jme3.terrain.heightmap.HillHeightMap to create a 512×512 2D heightmap
    • our 3D TerrainChunkLoader (our manager for infinite worlds) map a TerrainChunk (x,y,z) to a region of this 2D map
    • here I had some problems to transform the 512×512 heightmap (2D) to the 4×4 terrain-chunks (3D) … but now it works 🙂




    Update 20.02.2011 – better textures for grass and dirt

  • Andreas Höhmann 11:37 am Thursday, 17. February 2011 Permalink |  

    Early tec video from the bloxel 0.2.0 

    Some facts:
    – round about 1,5 million Boxes
    – 2 different textures (grass, pond)
    – memory : 1,5 GB used
    – hardware : Q9450, GTX280, 4GB RAM, Windows7 64bit
    – 60fps with vsync (fraps reduced to 30fps)


  • Andreas Höhmann 3:26 am Tuesday, 15. February 2011 Permalink |
    Tags: ,   

    Bloxel 0.2.0 with better performance 

    To handle scenes with many elements you have to „merge“ identical objects (Geometry’s) … I did it for bloxel 0.2.0 and the performance is now much better … here are two brand new screenshots :


    JMonkey contains a class for that :  jme3tools.optimize.GeometryBatchFactory. This forum entry shows me the way : http://jmonkeyengine.org/groups/general/forum/topic/how-to-useoptimize-pvs-or-octree

    FYI: our main application loop contains a „updateTerrain“ method:

    // near elements ... player can add/remove such elements ...
    final TerrainElementsResult result = terrainManager.getTerrainElements(thePlayerPosition, theWalkDirection);
    final Set<TerrainElement> currentElements = Sets.newLinkedHashSet(currentTerrainElements);
    final Set<TerrainElement> elementsToAdd = Sets.difference(new HashSet(result.getNearElements()), currentElements);
    final Set<TerrainElement> elementsToRemove = Sets.difference(currentTe, new HashSet(result.getNearElements()));
    // ... add new elements to scene, physics, cache etc ...
    // ... remove old elements from scene, physics, cache etc ...
    // far elements
    final Iterator<TerrainElement> iterator = result.getFarElements().iterator();
    final List<Geometry> geos = Lists.newArrayList();
    while (iterator.hasNext()) {
      final TerrainElement te = iterator.next();
      Bloxel bloxel = bloxelCache.getFromCache(te.getCenter());
      if (bloxel == null) {
        bloxel = bloxelFactory.create(te.getBloxelType());
    final List<Geometry> makeBatches = GeometryBatchFactory.makeBatches(geos);
    final Material material = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
    material.setColor("Color", ColorRGBA.White);
    for (final Geometry geometry : makeBatches) {
      // for debugging
      // geometry.setMaterial(material);
    System.out.println("update far terrain time: " + (System.currentTimeMillis() - start));

    Good night 😉

  • Andreas Höhmann 20:56 am Saturday, 12. February 2011 Permalink |  

    Bloxel 0.1.0 make progress 

    Now we have a simple open world algorithm, simple water effect, a spring DI integration (of course *g*), a game menu, a groovy console and some testcases 🙂 And we using maven!

    And more screenshots …

  • Andreas Höhmann 13:16 am Thursday, 10. February 2011 Permalink |
    Tags: , , opengl   

    Bloxel 0.1.0 

    I’m working on a new hobby project called BLOXEL – Yet another Minecraft clone 😉

    We try to implement a infinit open world with the  JMonkey 3D Game engine – all in Java!

    Here is the first screenshot


    Pictures of a brand new glass bloxel with a nice transparency effect

Neuen Beitrag erstellen
nächster Beitrag/nächster Kommentar
vorheriger Beitrag/vorheriger Kommentar
zeige/verstecke Kommentare
Zum Anfang gehen
zum Login
Zeige/Verberge Hilfe
Shift + ESC