Search in sources :

Example 6 with TextureCoordinate

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;
}
Also used : FacesEntity(net.drewke.tdme.engine.model.FacesEntity) Group(net.drewke.tdme.engine.model.Group) Model(net.drewke.tdme.engine.model.Model) Object3DModel(net.drewke.tdme.engine.Object3DModel) PrimitiveModel(net.drewke.tdme.engine.primitives.PrimitiveModel) ArrayList(java.util.ArrayList) Material(net.drewke.tdme.engine.model.Material) Vector3(net.drewke.tdme.math.Vector3) TextureCoordinate(net.drewke.tdme.engine.model.TextureCoordinate) Face(net.drewke.tdme.engine.model.Face)

Aggregations

ArrayList (java.util.ArrayList)6 Face (net.drewke.tdme.engine.model.Face)6 FacesEntity (net.drewke.tdme.engine.model.FacesEntity)6 TextureCoordinate (net.drewke.tdme.engine.model.TextureCoordinate)6 Vector3 (net.drewke.tdme.math.Vector3)6 Material (net.drewke.tdme.engine.model.Material)5 Group (net.drewke.tdme.engine.model.Group)4 Model (net.drewke.tdme.engine.model.Model)4 StringTokenizer (java.util.StringTokenizer)2 Joint (net.drewke.tdme.engine.model.Joint)2 BufferedReader (java.io.BufferedReader)1 DataInputStream (java.io.DataInputStream)1 InputStreamReader (java.io.InputStreamReader)1 HashSet (java.util.HashSet)1 Object3DModel (net.drewke.tdme.engine.Object3DModel)1 JointWeight (net.drewke.tdme.engine.model.JointWeight)1 Skinning (net.drewke.tdme.engine.model.Skinning)1 PrimitiveModel (net.drewke.tdme.engine.primitives.PrimitiveModel)1 Matrix4x4 (net.drewke.tdme.math.Matrix4x4)1 Element (org.w3c.dom.Element)1