Subversion Repositories distributed

Compare Revisions

No changes between revisions

Regard whitespace Rev 43 → Rev 44

/ViaThinkSoft Distributed/properties.cfg
File deleted
/ViaThinkSoft Distributed/src/test/fraktal3d/Raumplan.java
File deleted
/ViaThinkSoft Distributed/src/test/fraktal3d/BouncingBall.java
File deleted
/ViaThinkSoft Distributed/src/test/fraktal3d/LockDirectoryEnum.java
File deleted
Property changes:
Deleted: svn:mime-type
-text/plain
\ No newline at end of property
/ViaThinkSoft Distributed/src/test/fraktal3d/Fragestellungen.txt
File deleted
/ViaThinkSoft Distributed/src/test/fraktal3d/ColorUtilities.java
File deleted
/ViaThinkSoft Distributed/src/de/viathinksoft/marschall/raumplan/formula/FormulaProbe.java
0,0 → 1,13
package de.viathinksoft.marschall.raumplan.formula;
 
public class FormulaProbe {
 
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
 
}
 
}
/ViaThinkSoft Distributed/src/de/viathinksoft/marschall/raumplan/fraktal3d/LockDirectoryEnum.java
0,0 → 1,10
package de.viathinksoft.marschall.raumplan.fraktal3d;
 
public enum LockDirectoryEnum {
LOCK_NOTHING,
LOCK_X_POS, LOCK_X_NEG,
LOCK_Y_POS, LOCK_Y_NEG,
LOCK_Z_POS, LOCK_Z_NEG;
 
}
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/ViaThinkSoft Distributed/src/de/viathinksoft/marschall/raumplan/fraktal3d/Kubus.java
0,0 → 1,100
package de.viathinksoft.marschall.raumplan.fraktal3d;
import java.awt.Color;
 
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.scene.shape.Box;
import com.jme.scene.state.BlendState;
import com.jme.scene.state.MaterialState;
import com.jme.system.DisplaySystem;
 
public class Kubus {
protected Box centerbox;
private static final float Size_Faktor = 0.5f;
private static final float Abstand_Faktor = 0.5f;
private static final float Max_Iter = 6; // Ab 7 wird's eklig!
public Kubus(Node rootNode, float size, float abstand, float x, float y, float z, LockDirectoryEnum e, int iter) {
if (iter > Max_Iter) return;
Box centerbox = new Box("Center-Box", new Vector3f(x, y, z), size, size, size);
Node rn = getRoomNode(centerbox, iter);
rootNode.attachChild(rn);
// WIESO geht es nur mit abstand??? Es sollte abstand*1 sein!
float abstand2 = 0.5f*size + abstand + 0.5f*size*Size_Faktor;
// System.out.println(iter);
// System.out.println(size);
// System.out.println((0.5f*size) + " + " + abstand + " + " + ( 0.5f*size*Size_Faktor));
//
// System.out.println(x-abstand2);
if (e != LockDirectoryEnum.LOCK_X_NEG)
new Kubus(rn, size*Size_Faktor, abstand*Abstand_Faktor, x-abstand2, y, z, LockDirectoryEnum.LOCK_X_POS, iter+1);
if (e != LockDirectoryEnum.LOCK_X_POS)
new Kubus(rn, size*Size_Faktor, abstand*Abstand_Faktor, x+abstand2, y, z, LockDirectoryEnum.LOCK_X_NEG, iter+1);
if (e != LockDirectoryEnum.LOCK_Y_NEG)
new Kubus(rn, size*Size_Faktor, abstand*Abstand_Faktor, x, y-abstand2, z, LockDirectoryEnum.LOCK_Y_POS, iter+1);
if (e != LockDirectoryEnum.LOCK_Y_POS)
new Kubus(rn, size*Size_Faktor, abstand*Abstand_Faktor, x, y+abstand2, z, LockDirectoryEnum.LOCK_Y_NEG, iter+1);
if (e != LockDirectoryEnum.LOCK_Z_NEG)
new Kubus(rn, size*Size_Faktor, abstand*Abstand_Faktor, x, y, z-abstand2, LockDirectoryEnum.LOCK_Z_POS, iter+1);
if (e != LockDirectoryEnum.LOCK_Z_POS)
new Kubus(rn, size*Size_Faktor, abstand*Abstand_Faktor, x, y, z+abstand2, LockDirectoryEnum.LOCK_Z_NEG, iter+1);
}
protected static Node getRoomNode(Box centerbox, int iter) {
Node roomNode = new Node(); // Unnötiges Zwischennode?
float opacityAmount = 1.0f;
DisplaySystem display = DisplaySystem.getDisplaySystem();
MaterialState materialState = display.getRenderer()
.createMaterialState();
 
// the sphere material that will be modified to make the sphere
// look opaque then transparent then opaque and so on
materialState = display.getRenderer().createMaterialState();
materialState.setAmbient(new ColorRGBA(0.0f, 0.0f, 0.0f, opacityAmount));
Color x = ColorUtilities.HSLtoRGB(1.0f/iter, 1.0f, 0.5f);
float r = (float)x.getRed()/255;
float g = (float)x.getGreen()/255;
float b = (float)x.getBlue()/255;
materialState.setDiffuse(new ColorRGBA(r, g, b, opacityAmount)); // TODO
materialState.setSpecular(new ColorRGBA(1.0f, 1.0f, 1.0f, opacityAmount));
materialState.setShininess(128.0f);
materialState.setEmissive(new ColorRGBA(0.0f, 0.0f, 0.0f, opacityAmount));
materialState.setEnabled(true);
// IMPORTANT: this is used to handle the internal sphere faces when
// setting them to transparent, try commenting this line to see what
// happens
materialState.setMaterialFace(MaterialState.MaterialFace.FrontAndBack);
centerbox.setRenderState(materialState);
centerbox.updateRenderState();
 
// to handle transparency: a BlendState
// an other tutorial will be made to deal with the possibilities of this
// RenderState
final BlendState alphaState = DisplaySystem.getDisplaySystem().getRenderer().createBlendState();
alphaState.setBlendEnabled(true);
alphaState.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
alphaState.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
alphaState.setTestEnabled(true);
alphaState.setTestFunction(BlendState.TestFunction.GreaterThan);
alphaState.setEnabled(true);
centerbox.setRenderState(alphaState);
centerbox.updateRenderState();
roomNode.attachChild(centerbox);
return roomNode;
}
 
}
/ViaThinkSoft Distributed/src/de/viathinksoft/marschall/raumplan/fraktal3d/ColorUtilities.java
0,0 → 1,265
package de.viathinksoft.marschall.raumplan.fraktal3d;
 
/*
* $Id: ColorUtilities.java 1496 2006-10-22 03:26:24Z gfx $
*
* Dual-licensed under LGPL (Sun and Romain Guy) and BSD (Romain Guy).
*
* Copyright 2005 Sun Microsystems, Inc., 4150 Network Circle,
* Santa Clara, California 95054, U.S.A. All rights reserved.
*
* Copyright (c) 2006 Romain Guy <romain.guy@mac.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// package org.jdesktop.swingx.graphics;
 
import java.awt.Color;
 
/**
* <p><code>ColorUtilities</code> contains a set of tools to perform
* common color operations easily.</p>
*
* @author Romain Guy <romain.guy@mac.com>
*/
public class ColorUtilities {
private ColorUtilities() {
}
 
/**
* <p>Returns the HSL (Hue/Saturation/Luminance) equivalent of a given
* RGB color. All three HSL components are between 0.0 and 1.0.</p>
*
* @param color the RGB color to convert
* @return a new array of 3 floats corresponding to the HSL components
*/
public static float[] RGBtoHSL(Color color) {
return RGBtoHSL(color.getRed(), color.getGreen(), color.getBlue(), null);
}
 
/**
* <p>Returns the HSL (Hue/Saturation/Luminance) equivalent of a given
* RGB color. All three HSL components are between 0.0 and 1.0.</p>
*
* @param color the RGB color to convert
* @param hsl a pre-allocated array of floats; can be null
* @return <code>hsl</code> if non-null, a new array of 3 floats otherwise
* @throws IllegalArgumentException if <code>hsl</code> has a length lower
* than 3
*/
public static float[] RGBtoHSL(Color color, float[] hsl) {
return RGBtoHSL(color.getRed(), color.getGreen(), color.getBlue(), hsl);
}
 
/**
* <p>Returns the HSL (Hue/Saturation/Luminance) equivalent of a given
* RGB color. All three HSL components are between 0.0 and 1.0.</p>
*
* @param r the red component, between 0 and 255
* @param g the green component, between 0 and 255
* @param b the blue component, between 0 and 255
* @return a new array of 3 floats corresponding to the HSL components
*/
public static float[] RGBtoHSL(int r, int g, int b) {
return RGBtoHSL(r, g, b, null);
}
 
/**
* <p>Returns the HSL (Hue/Saturation/Luminance) equivalent of a given
* RGB color. All three HSL components are floats between 0.0 and 1.0.</p>
*
* @param r the red component, between 0 and 255
* @param g the green component, between 0 and 255
* @param b the blue component, between 0 and 255
* @param hsl a pre-allocated array of floats; can be null
* @return <code>hsl</code> if non-null, a new array of 3 floats otherwise
* @throws IllegalArgumentException if <code>hsl</code> has a length lower
* than 3
*/
public static float[] RGBtoHSL(int r, int g, int b, float[] hsl) {
if (hsl == null) {
hsl = new float[3];
} else if (hsl.length < 3) {
throw new IllegalArgumentException("hsl array must have a length of" +
" at least 3");
}
 
if (r < 0) r = 0;
else if (r > 255) r = 255;
if (g < 0) g = 0;
else if (g > 255) g = 255;
if (b < 0) b = 0;
else if (b > 255) b = 255;
 
float var_R = (r / 255f);
float var_G = (g / 255f);
float var_B = (b / 255f);
 
float var_Min;
float var_Max;
float del_Max;
 
if (var_R > var_G) {
var_Min = var_G;
var_Max = var_R;
} else {
var_Min = var_R;
var_Max = var_G;
}
if (var_B > var_Max) {
var_Max = var_B;
}
if (var_B < var_Min) {
var_Min = var_B;
}
 
del_Max = var_Max - var_Min;
 
float H, S, L;
L = (var_Max + var_Min) / 2f;
 
if (del_Max - 0.01f <= 0.0f) {
H = 0;
S = 0;
} else {
if (L < 0.5f) {
S = del_Max / (var_Max + var_Min);
} else {
S = del_Max / (2 - var_Max - var_Min);
}
 
float del_R = (((var_Max - var_R) / 6f) + (del_Max / 2f)) / del_Max;
float del_G = (((var_Max - var_G) / 6f) + (del_Max / 2f)) / del_Max;
float del_B = (((var_Max - var_B) / 6f) + (del_Max / 2f)) / del_Max;
 
if (var_R == var_Max) {
H = del_B - del_G;
} else if (var_G == var_Max) {
H = (1 / 3f) + del_R - del_B;
} else {
H = (2 / 3f) + del_G - del_R;
}
if (H < 0) {
H += 1;
}
if (H > 1) {
H -= 1;
}
}
 
hsl[0] = H;
hsl[1] = S;
hsl[2] = L;
 
return hsl;
}
 
/**
* <p>Returns the RGB equivalent of a given HSL (Hue/Saturation/Luminance)
* color.</p>
*
* @param h the hue component, between 0.0 and 1.0
* @param s the saturation component, between 0.0 and 1.0
* @param l the luminance component, between 0.0 and 1.0
* @return a new <code>Color</code> object equivalent to the HSL components
*/
public static Color HSLtoRGB(float h, float s, float l) {
int[] rgb = HSLtoRGB(h, s, l, null);
return new Color(rgb[0], rgb[1], rgb[2]);
}
 
/**
* <p>Returns the RGB equivalent of a given HSL (Hue/Saturation/Luminance)
* color. All three RGB components are integers between 0 and 255.</p>
*
* @param h the hue component, between 0.0 and 1.0
* @param s the saturation component, between 0.0 and 1.0
* @param l the luminance component, between 0.0 and 1.0
* @param rgb a pre-allocated array of ints; can be null
* @return <code>rgb</code> if non-null, a new array of 3 ints otherwise
* @throws IllegalArgumentException if <code>rgb</code> has a length lower
* than 3
*/
public static int[] HSLtoRGB(float h, float s, float l, int[] rgb) {
if (rgb == null) {
rgb = new int[3];
} else if (rgb.length < 3) {
throw new IllegalArgumentException("rgb array must have a length of" +
" at least 3");
}
 
if (h < 0) h = 0.0f;
else if (h > 1.0f) h = 1.0f;
if (s < 0) s = 0.0f;
else if (s > 1.0f) s = 1.0f;
if (l < 0) l = 0.0f;
else if (l > 1.0f) l = 1.0f;
 
int R, G, B;
 
if (s - 0.01f <= 0.0f) {
R = (int) (l * 255.0f);
G = (int) (l * 255.0f);
B = (int) (l * 255.0f);
} else {
float var_1, var_2;
if (l < 0.5f) {
var_2 = l * (1 + s);
} else {
var_2 = (l + s) - (s * l);
}
var_1 = 2 * l - var_2;
 
R = (int) (255.0f * hue2RGB(var_1, var_2, h + (1.0f / 3.0f)));
G = (int) (255.0f * hue2RGB(var_1, var_2, h));
B = (int) (255.0f * hue2RGB(var_1, var_2, h - (1.0f / 3.0f)));
}
 
rgb[0] = R;
rgb[1] = G;
rgb[2] = B;
 
return rgb;
}
 
private static float hue2RGB(float v1, float v2, float vH) {
if (vH < 0.0f) {
vH += 1.0f;
}
if (vH > 1.0f) {
vH -= 1.0f;
}
if ((6.0f * vH) < 1.0f) {
return (v1 + (v2 - v1) * 6.0f * vH);
}
if ((2.0f * vH) < 1.0f) {
return (v2);
}
if ((3.0f * vH) < 2.0f) {
return (v1 + (v2 - v1) * ((2.0f / 3.0f) - vH) * 6.0f);
}
return (v1);
}
}
/ViaThinkSoft Distributed/src/de/viathinksoft/marschall/raumplan/fraktal3d/RaumplanFraktal3D.java
0,0 → 1,21
package de.viathinksoft.marschall.raumplan.fraktal3d;
import com.jme.app.SimpleGame;
import com.jme.math.Vector3f;
 
public class RaumplanFraktal3D extends SimpleGame {
 
@Override
protected void simpleInitGame() {
cam.setLocation(new Vector3f(0, 50, 150));
new Kubus(rootNode, 50, 25, 0, 0, 0, LockDirectoryEnum.LOCK_NOTHING, 1);
}
 
/**
* @param args
*/
public static void main(String[] args) {
RaumplanFraktal3D ball = new RaumplanFraktal3D();
ball.setConfigShowMode(ConfigShowMode.ShowIfNoConfig);
ball.start();
}
}