use of net.drewke.tdme.engine.model.TextureCoordinate in project tdme by andreasdr.
the class EngineTest method createWallModel.
/**
* Create wall model
* @return
*/
private Model createWallModel() {
// wall model
Model wall = new Model("wall", "wall", UpVector.Y_UP, RotationOrder.XYZ, null);
// wall material
Material wallMaterial = new Material("wall");
wall.getMaterials().put("wall", wallMaterial);
// group
Group wallGroup = new Group(wall, null, "wall", "wall");
// faces entity
// far plane
FacesEntity groupFacesEntityFarPlane = new FacesEntity(wallGroup, "wall");
wallMaterial.getAmbientColor().set(1f, 1f, 1f, 1f);
wallMaterial.getDiffuseColor().set(1f, 1f, 1f, 1f);
groupFacesEntityFarPlane.setMaterial(wallMaterial);
// faces entity
ArrayList<FacesEntity> groupFacesEntities = new ArrayList<FacesEntity>();
groupFacesEntities.add(groupFacesEntityFarPlane);
// vertices
ArrayList<Vector3> vertices = new ArrayList<Vector3>();
// left, near, far plane
vertices.add(new Vector3(-4f, 0f, +4f));
// left, far, far plane
vertices.add(new Vector3(-4f, +4f, +4f));
// right far, far plane
vertices.add(new Vector3(+4f, +4f, +4f));
// right, near, far plane
vertices.add(new Vector3(+4f, 0f, +4f));
// normals
ArrayList<Vector3> normals = new ArrayList<Vector3>();
// far plane
normals.add(new Vector3(0f, 0f, -1f));
// texture coordinates
ArrayList<TextureCoordinate> textureCoordinates = new ArrayList<TextureCoordinate>();
textureCoordinates.add(new TextureCoordinate(0f, 0f));
textureCoordinates.add(new TextureCoordinate(0f, 1f));
textureCoordinates.add(new TextureCoordinate(1f, 1f));
textureCoordinates.add(new TextureCoordinate(1f, 0f));
// faces ground far plane
ArrayList<Face> facesFarPlane = new ArrayList<Face>();
facesFarPlane.add(new Face(wallGroup, 0, 1, 2, 0, 0, 0, 0, 1, 2));
facesFarPlane.add(new Face(wallGroup, 2, 3, 0, 0, 0, 0, 2, 3, 0));
// set up faces entity
groupFacesEntityFarPlane.setFaces(facesFarPlane);
// setup ground group
wallGroup.setVertices(vertices);
wallGroup.setNormals(normals);
wallGroup.setTextureCoordinates(textureCoordinates);
wallGroup.setFacesEntities(groupFacesEntities);
// determine features
wallGroup.determineFeatures();
// register group
wall.getGroups().put("wall", wallGroup);
wall.getSubGroups().put("wall", wallGroup);
// prepare for indexed rendering
ModelHelper.prepareForIndexedRendering(wall);
//
return wall;
}
Aggregations