Exemplo n.º 1
0
  @Override
  public void create() {
    modelBatch = new ModelBatch();
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
    environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(2f, 2f, 2f);
    cam.lookAt(0, 0, 0);
    cam.near = 1f;
    cam.far = 300f;
    cam.update();

    camController = new CameraInputController(cam);
    Gdx.input.setInputProcessor(camController);

    ModelLoader modelLoader = new G3dModelLoader(new JsonReader());
    ModelData modelData =
        modelLoader.loadModelData(Gdx.files.internal(data + "/invaderscene.g3dj"));
    model = new Model(modelData, new TextureProvider.FileTextureProvider());

    NodePart blockPart = model.getNode("ship").parts.get(0);

    renderable = new Renderable();
    renderable.mesh = blockPart.meshPart.mesh;
    renderable.meshPartOffset = blockPart.meshPart.indexOffset;
    renderable.meshPartSize = blockPart.meshPart.numVertices;
    renderable.primitiveType = blockPart.meshPart.primitiveType;
    renderable.material = blockPart.material;
    renderable.environment = environment;
    renderable.worldTransform.idt();
  }
Exemplo n.º 2
0
  public Wheel(GameManager base, Vector3 location, String type) {
    this.base = base;

    // If there is no wheel constructor, set it up
    if (this.base.world.getConstructor("wheel" + type) == null) {
      modelLoader = new G3dModelLoader(new JsonReader());
      if (type == "bigtruck")
        wheelData =
            modelLoader.loadModelData(
                Gdx.files.internal("data/vehicles/wheels/bigtruckwheel.g3dj"));
      else
        wheelData =
            modelLoader.loadModelData(Gdx.files.internal("data/vehicles/wheels/policewheel.g3dj"));
      wheelModel = new Model(wheelData, new TextureProvider.FileTextureProvider());
      wheelHalfExtents =
          wheelModel.calculateBoundingBox(new BoundingBox()).getDimensions(new Vector3()).scl(0.5f);

      this.base.world.addConstructor("wheel" + type, new BulletConstructor(wheelModel, 0f, null));
      this.base.disposables.add(wheelModel);

      wheel = this.base.world.add("wheel" + type, location.x, location.y, location.z);
    } else {
      wheel = this.base.world.add("wheel" + type, location.x, location.y, location.z);
      wheelHalfExtents =
          wheel
              .modelInstance
              .model
              .calculateBoundingBox(new BoundingBox())
              .getDimensions(new Vector3())
              .scl(0.5f);
    }
  }
Exemplo n.º 3
0
 @Override
 public void create() {
   super.create();
   shaderProgram = loadShader("defaultVS.glsl", "spot-phong-FS.glsl");
   spotlight =
       new Spotlight(
           new Vector3(0, 3, 0),
           new Vector3(0, (float) Math.PI / 4 + 0.3f, 0),
           new Vector3(0.3f, 1.0f, 0.3f),
           1,
           (float) Math.PI / 4);
   ModelLoader<?> cubeLoader = new ObjLoader();
   ModelData floorData = cubeLoader.loadModelData(Gdx.files.internal("box.obj"));
   floorTxt = new Texture("texture.png");
   floorMesh =
       new Mesh(
           true,
           floorData.meshes.get(0).vertices.length,
           floorData.meshes.get(0).parts[0].indices.length,
           VertexAttribute.Position(),
           VertexAttribute.Normal(),
           VertexAttribute.TexCoords(0));
   floorMesh.setVertices(floorData.meshes.get(0).vertices);
   floorMesh.setIndices(floorData.meshes.get(0).parts[0].indices);
   floor =
       new ModelObject(
           floorMesh,
           0.2f,
           new Vector3(-150, -2, -150),
           new Vector3(0, 0, 0),
           new Vector3(3000f, 0.1f, 3000f));
   ((MoveablePCamera) camera).addModel(model);
 }
Exemplo n.º 4
0
  @Override
  public void create() {
    modelBatch = new ModelBatch();
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
    environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(0f, 7f, 10f);
    cam.lookAt(0, 0, 0);
    cam.near = 0.1f;
    cam.far = 300f;
    cam.update();

    camController = new CameraInputController(cam);
    Gdx.input.setInputProcessor(camController);

    ModelLoader modelLoader = new G3dModelLoader(new JsonReader());
    ModelData modelData =
        modelLoader.loadModelData(Gdx.files.internal(data + "/invaderscene.g3dj"));
    model = new Model(modelData, new TextureProvider.FileTextureProvider());
    doneLoading();
  }