hey welcome !
this is a good place to start your java learning
http://java.sun.com/docs/books/tutorial/
this is a good place to start your java learning
http://java.sun.com/docs/books/tutorial/
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menupublic class Map extends AbstractEntity {
private int height;
private int width;
public static final int SQUARE_SIZE = 50;
/**
* define the number of subpanels that the map will have defined in a matrix
* [width x height]
*
* @param width
* @param height
*/
public Map(int width, int height, World w) {
super(Primitives.getPlane(SQUARE_SIZE, 1), w);
createThePlanes(width, height);
}
private void createThePlanes(int width, int height) {
this.width = width;
this.height = height;
Object3D[][] matrix = new Object3D[height][];
for (int i = 0; i < matrix.length; i++) {
matrix[i] = new Object3D[width];
}
int shiftX = SQUARE_SIZE;
int shiftY = SQUARE_SIZE;
String textureName = "red";
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
matrix[i][j] = Primitives.getPlane(SQUARE_SIZE, 1);
matrix[i][j].translate(shiftX * i, shiftY * j, 0);
matrix[i][j].setTexture(textureName);
addChild(matrix[i][j]);
prepare(matrix[i][j]);
// TODO remove this
if (textureName.equals("red")) {
textureName = "white";
} else {
textureName = "red";
}
}
}
prepare(this);
}
private void prepare(Object3D one) {
one.rotateX((float) Math.toRadians(90));
one.translateMesh();
one.rotateMesh();
one.setTranslationMatrix(new Matrix());
one.setRotationMatrix(new Matrix());
// one.createTriangleStrips(2);
one.enableLazyTransformations();
}
private static final long serialVersionUID = 1L;
}
Quote from: "rolz"
1. Terrain generator.
The common concept for landscapes in technopolies was in
- making it easy to edit (drawing landscape map in photoshop with a couple of brush strokes)
- making it lightweight enough to be transfered via network (~4kb for a 1000 x 1000 meters level)
- make it possible to be divided into regions (to define footstep sounds for different tiles, add effects like sand smokes and animated grass )
- load / render only visible parts of a bigger level
int collisionObject = w.checkCollision(getTransformedCenter(), where, 5 );
int collisionObject = w.checkCollision(getTransformedCenter(), where, 25 );
public void translate(SimpleVector where) {
int collisionObject = w.checkCollision(getTransformedCenter(), where,
5);
if (collisionObject == Object3D.NO_OBJECT) {
super.translate(where);
syncTranslate(where);
}
else {
System.out.println("colide with " + collisionObject );
}
}
public void init() throws Exception {
System.out.println("Config.maxPolysVisible=" + Config.maxPolysVisible);
Config.maxPolysVisible = 12000;
Config.collideOffset = 250;
Config.tuneForOutdoor();
addTexture("alita2", "models/alita/alita2.jpg");
addTexture("floor", "textures/floor.jpg");
addTexture("red", "textures/red.jpg");
AbstractEntity[] list = new AbstractEntity[3];
list[0] = ModelUtil.loadModelMD2(getWorld(), "alita/tris", 0, -90, 0,
0.9f);
list[0].setTexture("alita2");
setCurrent(list[0]);
Animation run = list[0].getAnimationSequence();
anim = run.createSubSequence("run");
list[1] = new AbstractEntity(PlaneUtil.getPlane("floor", 20, 300),
getWorld());
list[1].setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
list[2] = new AbstractEntity(Primitives.getCube(50), getWorld());
list[2].setTexture("red");
list[2].setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
addObjects(list);
PositionUtil.placeOver(list[0], 0, 0);
PositionUtil.placeOver(list[2], -50, -50);
CameraUtil.setCameraLookingFromTop(getCamera(), list[0]);
LightUtil.addDefaultLight(getWorld());
addFPSListener(this);
Config.tuneForOutdoor();
Logger.setLogLevel(Logger.LL_ONLY_ERRORS);
}
Page created in 0.037 seconds with 13 queries.