Java 类com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute 实例源码

项目:StreetCampusFighter    文件:GameScreen.java   
public GameScreen(){
    spriteBatch = new SpriteBatch(); // buffer ok
    texture     = new Texture(Gdx.files.internal("bg/gameBG.jpg"));
    viewMatrix  = new Matrix4();  // matriz de visualização
    tranMatrix  = new Matrix4();  // matriz de escala

    // camera
    camera = new PerspectiveCamera(67.0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.near = 0.1f;
    camera.far  = 1000f;
    camera.position.set(0, 5, 10);
    camera.lookAt(0, 5, 0);
    camera.update();

    // ambiente
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1,1,1,1));

    // renderizador
    modelBatch = new ModelBatch();
    p1 = new Player(1);
    p2 = new Player(2);



}
项目:enklave    文件:ScreenRaider.java   
private void addBackground(){
        decalBackground = Decal.newDecal(new TextureRegion(managerAssets.getAssetsCrafting().getTexture(NameFiles.backgroundCrafting)));
        decalBackground.setDimensions(100,200);
        decalBackground.setPosition(0,0,0);
        environment = new Environment();
//        environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
        environment.set(new ColorAttribute(ColorAttribute.Diffuse));
        environment.set(new ColorAttribute(ColorAttribute.Specular));
        environment.set(new ColorAttribute(ColorAttribute.Reflection));
        environment.add(new DirectionalLight().set(0.51f, 0.5f, 0.5f, 0f, -2f, -30f));
        Model model = managerAssets.getAssetsRaider().getModel(NameFiles.raiderFull);
        model.nodes.get(2).translation.set(-12,28.6f,-5.5f);
//        model.nodes.get(0).translation.set(0,28f,29.2f);
//        model.nodes.get(2).translation.set(0,13,-1);
        instance = new ModelInstance(model);
        instance.transform.trn(0,-20,25).rotate(0,1,0,-25);
        instance.transform.scale(1.5f,1.5f,1.5f);
    }
项目:VuforiaLibGDX    文件:Renderer.java   
public Renderer(VuforiaRenderer arRenderer) {

        lights = new Environment();
        lights.set(new ColorAttribute(ColorAttribute.AmbientLight, Color.WHITE));

        camera = new PerspectiveCamera(60, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        camera.near = 1.0F;
        camera.far = 1000.0F;
        //set camera into "Vuforia - style" direction
        camera.position.set(new Vector3(0,0,0));
        camera.lookAt(new Vector3(0,0,1));

        this.vuforiaRenderer = arRenderer;

        modelBatch = new ModelBatch();
    }
项目:Chemtris    文件:GameModel.java   
public GameModel(PerspectiveCamera cam, boolean [][][] collision){
    //setup the model instances
    parts = new Array<ModelInstance>();
    frame = new Array<ModelInstance>();
    shadow = new Array<ModelInstance>();

    //setup environment
    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));

    //setup collision matrix
    matrix = collision;

    //setup camera
    camera = cam;



}
项目:eamaster    文件:SimulationRunner.java   
public SimulationRunner() {
    logger.info("Loading models");
    ModelBuilder builder = new ModelBuilder();
    models.put("box", builder.createBox(5f, 5f, 5f,
            new Material(ColorAttribute.createDiffuse(new Color(0.8f, 0f, 0f, 0f))),
            VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal));

    G3dModelLoader loader = new G3dModelLoader(new JsonReader());
    models.put("hub", loader.loadModel(Gdx.files.internal("data/hubreal.g3dj")));
    models.put("rim", loader.loadModel(Gdx.files.internal("data/rimreal.g3dj")));
    models.put("spoke", loader.loadModel(Gdx.files.internal("data/spoke.g3dj")));


    Bullet.init();
    logger.info("Initialized Bullet");
}
项目:eamaster    文件:ConvexHullDistanceTest.java   
@Override
public void create () {
    super.create();

    final Model carModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
    disposables.add(carModel);
    carModel.materials.get(0).clear();
    carModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE));
    world.addConstructor("car", new BulletConstructor(carModel, 5f, createConvexHullShape(carModel, true)));

    // Create the entities
    world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(),
        0.25f + 0.5f * (float)Math.random(), 1f);

    for (float y = 10f; y < 50f; y += 5f)
        world.add("car", -2f + (float)Math.random() * 4f, y, -2f + (float)Math.random() * 4f).setColor(
            0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
    distance = new ConvexHullDistance();
    shapeRenderer = new ShapeRenderer();
}
项目:eamaster    文件:ConvexHullTest.java   
@Override
public void create () {
    super.create();

    final Model carModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
    disposables.add(carModel);
    carModel.materials.get(0).clear();
    carModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE));
    world.addConstructor("car", new BulletConstructor(carModel, 5f, createConvexHullShape(carModel, true)));

    // Create the entities
    world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(),
        0.25f + 0.5f * (float)Math.random(), 1f);

    for (float y = 10f; y < 50f; y += 5f)
        world.add("car", -2f + (float)Math.random() * 4f, y, -2f + (float)Math.random() * 4f).setColor(
            0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
}
项目:eamaster    文件:GimpactTest.java   
@Override
public void create () {
    super.create();

    final Model chassisModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
    disposables.add(chassisModel);
    chassisModel.materials.get(0).clear();
    chassisModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.RED), ColorAttribute.createSpecular(Color.WHITE));

    chassisVertexArray = new btTriangleIndexVertexArray(chassisModel.meshParts);
    btGImpactMeshShape chassisShape = new btGImpactMeshShape(chassisVertexArray);
    chassisShape.setLocalScaling(new Vector3(1f, 1f, 1f));
    chassisShape.setMargin(0f);
    chassisShape.updateBound();

    world.addConstructor("chassis", new BulletConstructor(chassisModel, 1f, chassisShape));

    (ground = world.add("ground", 0f, 0f, 0f)).setColor(0.25f + 0.5f * (float)Math.random(),
        0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);

    world.add("chassis", 3f, 10f, 3f);
    world.add("chassis", 4f, 5f, 3f);
    world.add("chassis", 4f, 1f, 5f);

       btGImpactCollisionAlgorithm.registerAlgorithm(world.dispatcher);
}
项目:ChessGDX    文件:GridSpaceHighlighter.java   
/**
 * Initializes a highlighter effect, will be processed in
 * {@link GridSpaceHighlighter#update(float)}
 * 
 * @param state
 *            effect to be initialized
 */
public void setEffect(GridState state) {

    mGridState = state;

    switch (state) {
    case FADE_GREEN:
        mModelInstance.materials.get(0).set(ColorAttribute.createDiffuse(0.5f, 1.0f, 0.5f, 1.0f));
        mAlphaBlend.opacity = 0.8f;
        break;
    case FADE_RED:
    case ILLEGAL_HOVER:
        mModelInstance.materials.get(0).set(ColorAttribute.createDiffuse(Color.RED));
        mAlphaBlend.opacity = 0.8f;
        break;
    case LEGAL_HOVER:
        mModelInstance.materials.get(0).set(ColorAttribute.createDiffuse(0.5f, 1.0f, 0.5f, 1.0f));
        mAlphaBlend.opacity = 0.8f;
        break;
    case NONE:
        mAlphaBlend.opacity = 0.0f;
    default:
        break;
    }
}
项目:Mundus    文件:RotateTool.java   
public RotateHandle(int id, Color color) {
    super(id);
    model = UsefulMeshs.torus(new Material(ColorAttribute.createDiffuse(color)), 20, 1f, 50, 50);
    modelInstance = new ModelInstance(model);
    modelInstance.materials.first().set(getIdAttribute());
    switch (id) {
    case X_HANDLE_ID:
        this.getRotationEuler().y = 90;
        this.getScale().x = 0.9f;
        this.getScale().y = 0.9f;
        this.getScale().z = 0.9f;
        break;
    case Y_HANDLE_ID:
        this.getRotationEuler().x = 90;
        break;
    case Z_HANDLE_ID:
        this.getRotationEuler().z = 90;
        this.getScale().x = 1.1f;
        this.getScale().y = 1.1f;
        this.getScale().z = 1.1f;
        break;
    }
    // mi.transform.translate(0, 100, 0);
}
项目:Mundus    文件:ScaleTool.java   
public ScaleTool(ProjectManager projectManager, GameObjectPicker goPicker, ToolHandlePicker handlePicker,
        ShapeRenderer shapeRenderer, ModelBatch batch, CommandHistory history) {
    super(projectManager, goPicker, handlePicker, batch, history);

    this.shapeRenderer = shapeRenderer;

    ModelBuilder modelBuilder = new ModelBuilder();
    Model xPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_X)),
            Vector3.Zero, new Vector3(15, 0, 0));
    Model yPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_Y)),
            Vector3.Zero, new Vector3(0, 15, 0));
    Model zPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_Z)),
            Vector3.Zero, new Vector3(0, 0, 15));
    Model xyzPlaneHandleModel = modelBuilder.createBox(3, 3, 3,
            new Material(ColorAttribute.createDiffuse(COLOR_XYZ)),
            VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);

    xHandle = new ScaleHandle(X_HANDLE_ID, xPlaneHandleModel);
    yHandle = new ScaleHandle(Y_HANDLE_ID, yPlaneHandleModel);
    zHandle = new ScaleHandle(Z_HANDLE_ID, zPlaneHandleModel);
    xyzHandle = new ScaleHandle(XYZ_HANDLE_ID, xyzPlaneHandleModel);

    handles = new ScaleHandle[] { xHandle, yHandle, zHandle, xyzHandle };
}
项目:GdxDemo3D    文件:GameRenderer.java   
public void setEnvironmentLights(Array<BaseLight<?>> lights, Vector3 sunDirection) {
    environment = new Environment();
    environment.add((shadowLight = new DirectionalShadowLight(
            GameSettings.SHADOW_MAP_WIDTH,
            GameSettings.SHADOW_MAP_HEIGHT,
            GameSettings.SHADOW_VIEWPORT_WIDTH,
            GameSettings.SHADOW_VIEWPORT_HEIGHT,
            GameSettings.SHADOW_NEAR,
            GameSettings.SHADOW_FAR))
            .set(GameSettings.SHADOW_INTENSITY,
                    GameSettings.SHADOW_INTENSITY,
                    GameSettings.SHADOW_INTENSITY,
                    sunDirection.nor()));
    environment.shadowMap = shadowLight;

    float ambientLight = GameSettings.SCENE_AMBIENT_LIGHT;
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, ambientLight, ambientLight, ambientLight, 1));
    for (BaseLight<?> light : lights) {
        environment.add(light);
    }
}
项目:Alien-Ark    文件:MaterialInterpreter.java   
public MaterialInterpreter() {

        waterColor = new Color(0.13f, 0.05f, 0.8f, 1);
        waterMaterial = new Material(
                ColorAttribute.createDiffuse(waterColor),
                ColorAttribute.createSpecular(1, 1, 1, 1),
                FloatAttribute.createShininess(8f));

        sandColor = new Color(0.9f, 0.733f, 0.58f, 1);
        sandMaterial = new Material(ColorAttribute.createDiffuse(sandColor),
                ColorAttribute.createSpecular(1, 1, 1, 1),
                FloatAttribute.createShininess(8f));

        grassColor = new Color(0f, 1f, 0f, 1f);
        grassMaterial = new Material(ColorAttribute.createDiffuse(grassColor),
                ColorAttribute.createSpecular(1, 1, 1, 1),
                FloatAttribute.createShininess(8f));

    }
项目:libgdxcn    文件:DefaultShader.java   
@Override
public void set (BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
    if (renderable.environment == null)
        shader.program.setUniform3fv(shader.loc(inputID), ones, 0, ones.length);
    else {
        renderable.worldTransform.getTranslation(tmpV1);
        if (renderable.environment.has(ColorAttribute.AmbientLight))
            cacheAmbientCubemap.set(((ColorAttribute)renderable.environment.get(ColorAttribute.AmbientLight)).color);

        for (int i = dirLightsOffset; i < renderable.environment.directionalLights.size; i++)
            cacheAmbientCubemap.add(renderable.environment.directionalLights.get(i).color,
                renderable.environment.directionalLights.get(i).direction);

        for (int i = pointLightsOffset; i < renderable.environment.pointLights.size; i++)
            cacheAmbientCubemap.add(renderable.environment.pointLights.get(i).color,
                renderable.environment.pointLights.get(i).position, tmpV1,
                renderable.environment.pointLights.get(i).intensity);

        cacheAmbientCubemap.clamp();

        shader.program.setUniform3fv(shader.loc(inputID), cacheAmbientCubemap.data, 0, cacheAmbientCubemap.data.length);
    }
}
项目:amatsukaze    文件:Basic3DTest.java   
@Override
    public void create () {
        modelBatch = new ModelBatch(new DefaultShaderProvider());
// modelBatch = new ModelBatch();
        environment = new Environment();
        environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .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(10f, 10f, 10f);
        cam.lookAt(0, 0, 0);
        cam.near = 0.1f;
        cam.far = 300f;
        cam.update();

        ModelBuilder modelBuilder = new ModelBuilder();
        model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position
            | Usage.Normal);
        instance = new ModelInstance(model);

// model = new G3dModelLoader(new UBJsonReader()).loadModel(Gdx.files.internal("data/g3d/knight.g3db"));
// instance = new ModelInstance(model);

        Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
    }
项目:libgdxcn    文件:ShaderCollectionTest.java   
@Override
public void create () {
    super.create();
    lights = new Environment();
    lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.1f, 0.1f, 0.1f, 1.f));
    lights.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f));

    shaderProvider = new TestShaderProvider();
    shaderBatch = new ModelBatch(shaderProvider);

    cam.position.set(1, 1, 1);
    cam.lookAt(0, 0, 0);
    cam.update();
    showAxes = true;

    onModelClicked("g3d/shapes/teapot.g3dj");

    shaderRoot = (hotLoadFolder != null && Gdx.app.getType() == ApplicationType.Desktop) ? Gdx.files.absolute(hotLoadFolder)
        : Gdx.files.internal("data/g3d/shaders");
}
项目:libgdxcn    文件:FogTest.java   
@Override
public void create () {
    modelBatch = new ModelBatch();
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
    environment.set(new ColorAttribute(ColorAttribute.Fog, 0.13f, 0.13f, 0.13f, 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(30f, 10f, 30f);
    cam.lookAt(0, 0, 0);
    cam.near = 0.1f;
    cam.far = 45f;
    cam.update();

    ModelBuilder modelBuilder = new ModelBuilder();
    model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position
        | Usage.Normal);
    instance = new ModelInstance(model);

    Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
项目:libgdxcn    文件:Basic3DTest.java   
@Override
    public void create () {
        modelBatch = new ModelBatch(new DefaultShaderProvider());
// modelBatch = new ModelBatch();
        environment = new Environment();
        environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .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(10f, 10f, 10f);
        cam.lookAt(0, 0, 0);
        cam.near = 0.1f;
        cam.far = 300f;
        cam.update();

        ModelBuilder modelBuilder = new ModelBuilder();
        model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position
            | Usage.Normal);
        instance = new ModelInstance(model);

// model = new G3dModelLoader(new UBJsonReader()).loadModel(Gdx.files.internal("data/g3d/knight.g3db"));
// instance = new ModelInstance(model);

        Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
    }
项目:libgdxcn    文件:CullTest.java   
@Override
public void create () {
    ModelBuilder builder = new ModelBuilder();
    sphere = builder.createSphere(2f, 2f, 2f, 16, 16, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)),
        Usage.Position | Usage.Normal);
    // cam = new PerspectiveCamera(45, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam = new OrthographicCamera(45, 45 * (Gdx.graphics.getWidth() / (float)Gdx.graphics.getHeight()));

    cam.near = 1;
    cam.far = 200;

    Random rand = new Random();
    for (int i = 0; i < instances.length; i++) {
        pos.set(rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * 100 - rand.nextFloat() * 100,
            rand.nextFloat() * -100 - 3);
        instances[i] = new ModelInstance(sphere, pos);
    }
    modelBatch = new ModelBatch();

    batch = new SpriteBatch();
    font = new BitmapFont();
    // Gdx.graphics.setVSync(true);
    // Gdx.app.log("CullTest", "" + Gdx.graphics.getBufferFormat().toString());
}
项目:libgdxcn    文件:ConvexHullDistanceTest.java   
@Override
public void create () {
    super.create();

    final Model carModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
    disposables.add(carModel);
    carModel.materials.get(0).clear();
    carModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE));
    world.addConstructor("car", new BulletConstructor(carModel, 5f, createConvexHullShape(carModel, true)));

    // Create the entities
    world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(),
        0.25f + 0.5f * (float)Math.random(), 1f);

    for (float y = 10f; y < 50f; y += 5f)
        world.add("car", -2f + (float)Math.random() * 4f, y, -2f + (float)Math.random() * 4f).setColor(
            0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
    distance = new ConvexHullDistance();
    shapeRenderer = new ShapeRenderer();
}
项目:libgdxcn    文件:ConvexHullTest.java   
@Override
public void create () {
    super.create();

    final Model carModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
    disposables.add(carModel);
    carModel.materials.get(0).clear();
    carModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE));
    world.addConstructor("car", new BulletConstructor(carModel, 5f, createConvexHullShape(carModel, true)));

    // Create the entities
    world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(),
        0.25f + 0.5f * (float)Math.random(), 1f);

    for (float y = 10f; y < 50f; y += 5f)
        world.add("car", -2f + (float)Math.random() * 4f, y, -2f + (float)Math.random() * 4f).setColor(
            0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
}
项目:libgdxcn    文件:GimpactTest.java   
@Override
public void create () {
    super.create();

    final Model chassisModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
    disposables.add(chassisModel);
    chassisModel.materials.get(0).clear();
    chassisModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.RED), ColorAttribute.createSpecular(Color.WHITE));

    chassisVertexArray = new btTriangleIndexVertexArray(chassisModel.meshParts);
    btGImpactMeshShape chassisShape = new btGImpactMeshShape(chassisVertexArray);
    chassisShape.setLocalScaling(new Vector3(1f, 1f, 1f));
    chassisShape.setMargin(0f);
    chassisShape.updateBound();

    world.addConstructor("chassis", new BulletConstructor(chassisModel, 1f, chassisShape));

    (ground = world.add("ground", 0f, 0f, 0f)).setColor(0.25f + 0.5f * (float)Math.random(),
        0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);

    world.add("chassis", 3f, 10f, 3f);
}
项目:HelixEngine    文件:TileHighlightDisplayable.java   
public TileHighlightDisplayable() {
  ModelBuilder modelBuilder = new ModelBuilder();

  Model model
      = modelBuilder.createRect(0, 0, Z_OFFSET,
                                1, 0, Z_OFFSET,
                                1, 1, Z_OFFSET,
                                0, 1, Z_OFFSET,
                                0, 0, 1,
                                GL20.GL_TRIANGLES,
                                new Material(
                                    new ColorAttribute(
                                        ColorAttribute.createDiffuse(color)),
                                    new BlendingAttribute(
                                        GL20.GL_SRC_ALPHA,
                                        GL20.GL_ONE_MINUS_SRC_ALPHA)),
                                VertexAttributes.Usage.Position |
                                VertexAttributes.Usage.TextureCoordinates);

  instance = new ModelInstance(model);
}
项目:HelixEngine    文件:AreaDisplayable.java   
public AreaDisplayable(Model model) {
  instance = new ModelInstance(model);

  animationController = new AnimationController(instance);

  instance.transform.rotate(new Vector3(1, 0, 0), 90);

  for (Material material : instance.materials) {
    TextureAttribute ta
        = (TextureAttribute) material.get(TextureAttribute.Diffuse);

    ta.textureDescription.magFilter = Texture.TextureFilter.Nearest;
    ta.textureDescription.minFilter = Texture.TextureFilter.Nearest;

    material.set(ta);
    material.set(ColorAttribute.createDiffuse(Color.WHITE));

    BlendingAttribute ba = new BlendingAttribute(GL20.GL_SRC_ALPHA,
                                                 GL20.GL_ONE_MINUS_SRC_ALPHA);

    material.set(ba);
  }
}
项目:gdx-vr    文件:SimpleRoom.java   
@Override
public void create() {
    assets = new AssetManager();
    String model = "Bambo_House.g3db";
    assets.load(model, Model.class);
    assets.finishLoading();
    modelInstance = new ModelInstance(assets.get(model, Model.class), new Matrix4().setToScaling(0.6f, 0.6f, 0.6f));

    DefaultShader.Config config = new Config();
    config.defaultCullFace = GL20.GL_NONE;
    ShaderProvider shaderProvider = new DefaultShaderProvider(config);
    modelBatch = new ModelBatch(shaderProvider);

    ModelBuilder builder = new ModelBuilder();
    float groundSize = 1000f;
    ground = new ModelInstance(builder.createRect(-groundSize, 0, groundSize, groundSize, 0, groundSize, groundSize, 0, -groundSize, -groundSize, 0, -groundSize, 0,
            1, 0, new Material(), Usage.Position | Usage.Normal), new Matrix4().setToTranslation(0, -0.01f, 0));
    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));

    VirtualReality.renderer.listeners.add(this);
    // VirtualReality.head.setCyclops(true);
}
项目:bladecoder-adventure-engine    文件:Utils3D.java   
public static void createFloor() {

        ModelBuilder modelBuilder = new ModelBuilder();
        modelBuilder.begin();
        MeshPartBuilder mpb = modelBuilder.part("parts", GL20.GL_TRIANGLES,
                Usage.Position | Usage.Normal | Usage.ColorUnpacked, new Material(
                        ColorAttribute.createDiffuse(Color.WHITE)));
        mpb.setColor(1f, 1f, 1f, 1f);
//      mpb.box(0, -0.1f, 0, 10, .2f, 10);
        mpb.rect(-10, 0, -10, 
                -10, 0, 10,
                10, 0, 10,
                10, 0, -10, 0, 1, 0);
        floorModel = modelBuilder.end();
        floorInstance = new ModelInstance(floorModel);

        // TODO Set only when FBO is active
        floorInstance.materials.get(0).set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
    }
项目:BotLogic    文件:LedEntity.java   
public LedEntity(Model model) {
  super(model);

  light = new PointLight();
  light.set(new Color(1f,1f, 1f, 1f), Vector3.Zero, 2f);

  for (Material material : instance.materials) {

    if (material.id.contains("Led")) {
      this.colorAttr = (ColorAttribute)material.get(ColorAttribute.Diffuse);
      colorAttr.color.set(Color.WHITE);

      this.blendingAttribute = (BlendingAttribute)material.get(BlendingAttribute.Type);
      blendingAttribute.opacity = 1.0f;
      blendingAttribute.sourceFunction = GL20.GL_ONE;
      blendingAttribute.destFunction = GL20.GL_SRC_ALPHA;

    }
  }
}
项目:Scene3d    文件:Stage3d.java   
public Stage3d (float width, float height, boolean keepAspectRatio) {
    this.width = width;
    this.height = height;

    root = new Group3d();
    root.setStage3d(this);

    modelBatch = new ModelBatch();

    camera =  new Camera3d();
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.9f, 0.9f, 0.9f, 1f));
    environment.add(new DirectionalLight().set(0.8f, 0f, 0f, -1f, -0.8f, -0.2f));

    setViewport(width, height, keepAspectRatio);
}
项目:gdx-proto    文件:ModelManager.java   
/** players are represented by cubes, with another cube marking the direction it is facing */
public void createPlayerModel() {
    ModelBuilder mb = new ModelBuilder();
    ModelBuilder mb2 = new ModelBuilder();
    long attr = Usage.Position | Usage.Normal;
    float r = 0.5f;
    float g = 1f;
    float b = 0.75f;
    Material material = new Material(ColorAttribute.createDiffuse(new Color(r, g, b, 1f)));
    Material faceMaterial = new Material(ColorAttribute.createDiffuse(Color.BLUE));
    float w = 1f;
    float d = w;
    float h = 2f;
    mb.begin();
    //playerModel = mb.createBox(w, h, d, material, attr);
    Node node = mb.node("box", mb2.createBox(w, h, d, material, attr));
    // the face is just a box to show which direction the player is facing
    Node faceNode = mb.node("face", mb2.createBox(w/2, h/2, d/2, faceMaterial, attr));
    faceNode.translation.set(0f, 0f, d/2);
    playerModel = mb.end();
}
项目:amatsukaze    文件:Basic3D.java   
@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(10f, 10f, 10f);
    cam.lookAt(0, 0, 0);
    cam.near = 1f;
    cam.far = 300f;
    cam.update();

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

    ModelBuilder modelBuilder = new ModelBuilder();
       model = modelBuilder.createBox(5f, 5f, 5f, 
           new Material(ColorAttribute.createDiffuse(Color.GREEN)),
           Usage.Position | Usage.Normal);
       instance = new ModelInstance(model);
}
项目:amatsukaze    文件:FogTest.java   
@Override
public void create () {
    modelBatch = new ModelBatch();
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
    environment.set(new ColorAttribute(ColorAttribute.Fog, 0.13f, 0.13f, 0.13f, 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(30f, 10f, 30f);
    cam.lookAt(0, 0, 0);
    cam.near = 0.1f;
    cam.far = 45f;
    cam.update();

    ModelBuilder modelBuilder = new ModelBuilder();
    model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position
        | Usage.Normal);
    instance = new ModelInstance(model);

    Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
项目:Tower-Defense-Galaxy    文件:LevelSelectScreen.java   
@Override
public void show() {
    super.show();
    assets = new AssetManager();
    assets.load("theme/basic/campaign/scene.g3db", Model.class);
    modelBatch = new ModelBatch();
    environment = new Environment();

    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
    //environment.add(new DirectionalLight().set(1f, 1f, 1f, -1f, -1f, -1f));
    addDisposables(modelBatch, assets);
}
项目:enklave    文件:ScreenProfile.java   
private void drawProfile() {
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
    environment.add(new DirectionalLight().set(1f, 1f, 1f, 1f, 1f, 1f));
    Model model = managerAssets.getAssetsProfile().getModel(NameFiles.profileObject);
    model.nodes.get(2).translation.set(0,-14.5f,9);
    instance = new ModelInstance(model);
    instance.transform.scale(0.2f,0.2f,0.2f);
    instance.transform.trn(0,-8f,27).rotate(0,1,0,55);
    decalBackground = Decal.newDecal(new TextureRegion(managerAssets.getAssetsCrafting().getTexture(NameFiles.backgroundCrafting)));
    decalBackground.setDimensions(75,150);
    decalBackground.setPosition(0,0,0);
    queueDisplay = QueueDisplay.getInstance();
}
项目:enklave    文件:MapsScreen.java   
public MapsScreen(GameManager game) {
    gameManager = game;
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
    environment.add(new DirectionalLight().set(1f, 1f, 1f, -1f, -0.8f, -0.2f));
    camera = new PerspectiveCamera(40, Width, Height);
    camera.lookAt(0, 0, 0);
    camera.far = 4000;
    camera.near = 1;
    camera.update();
    pos = new Vector2[3][3];
    CameraGroupStrategy cameraGroupStategy = new CameraGroupStrategy(camera);
    batch = new DecalBatch(cameraGroupStategy);
    bounds = new Bounds();
    matrixPixmap = MapPixmap.getInstance();
    managerAssets = ManagerAssets.getInstance();
    myLocation = MyLocation.getInstance();
    pointerx = new int[4];
    pointery = new int[4];
    compass = myLocation.getCompas();
    queue = MyQueue.getInstance();
    //calc bounds
    bounds.getCorners(matrixPixmap.getMatrix()[1][1].getLatitude(),matrixPixmap.getMatrix()[1][1].getLongitude() , 17.0, 640.0, 640.0);
    unitlong = (bounds.calcDisance(bounds.latSW, bounds.longSW, bounds.latSW, bounds.longNE)+bounds.calcDisance(bounds.latNE,bounds.longNE,bounds.latNE,bounds.longSW))/2.0;
    unitlong=600/unitlong;
    unitlat = bounds.calcDisance(bounds.latSW, bounds.longSW, bounds.latNE, bounds.longSW);
    unitlat= 600/unitlat;
    timerEnergy = new Timer();
    informationProfile = InformationProfile.getInstance();
}
项目:ZombieInvadersVR    文件:ScreenBase.java   
private void setupEnviroment() {
    camera = new CardboardCamera();
    camera.position.set(0f, CAMERA_Y, 0f);
    camera.lookAt(0f, CAMERA_Y, -1f);
    camera.near = Z_NEAR;
    camera.far = Z_FAR;

    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 0.5f));
    environment.set(new ColorAttribute(ColorAttribute.Fog, BACKGROUND_COLOR.r, BACKGROUND_COLOR.g, BACKGROUND_COLOR.b, BACKGROUND_COLOR.a));
    environment.add(new DirectionalLight().set(0.6f, 0.6f, 0.4f, -0.5f, -0.6f, -0.5f));
    environment.add(new DirectionalLight().set(0.6f, 0.6f, 0.4f, 0.5f, -0.6f, 0.5f));
}
项目:Planetbase    文件:StrategyGame.java   
@Override
public void create() {
    INSTANCE=this;

    Debug.dbg("Path: "+System.getProperty("user.dir"));

    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));

    staticEntityBatch = new ModelBatch();

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

    Assets.modelBuilder = new ModelBuilder();
    Model world = Assets.modelBuilder.createSphere(2f,2f,2f, 
            80, 80, /* 80x80 seems to be enough polys to look smooth */
            new Material(ColorAttribute.createDiffuse(Color.GREEN)),
            Usage.Position | Usage.Normal);
    models.add(world);

    planetSurface = new ModelInstance(world);

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

    space=new Space();
}
项目:Planetbase    文件:StrategyGame.java   
public void renderSelectTooltip(){
    float radius=selectGroup+0.03f;
    ModelInstance sphere=new ModelInstance(Assets.modelBuilder.createSphere(radius, radius, radius
            ,(int)(100*radius),(int)(100*radius), //This can be lower-resolution
            new Material(ColorAttribute.createDiffuse(1,0,0,0.5f)),
            Usage.Position | Usage.Normal));
    sphere.transform.setToTranslation(-cam.direction.x, -cam.direction.y, -cam.direction.z);
    staticEntityBatch.render(sphere);
}
项目:thunderboard-android    文件:DemoMotionGdxAdapter.java   
public void turnOffLights() {
    for (Material mat : lightMaterials) {
        if (mat.has(ColorAttribute.Emissive)) {
            mat.remove(ColorAttribute.Emissive);
        }
    }
}
项目:Argent    文件:AttributeTypeAdapter.java   
@Override
public void write(JsonWriter out, Attribute value) throws IOException {
    if(value == null) {
        out.nullValue();
        return;
    }
    out.beginObject();
    String alias = value.getClass().getSimpleName();
    out.name("type").value(value.type);

    alias += "::" + value.getAttributeAlias(value.type);
    out.name("alias").value(alias);


    out.name("attrData").beginObject();
    if(value instanceof TextureAttribute) {
        out.name("offsetU").value(((TextureAttribute) value).offsetU);
        out.name("offsetV").value(((TextureAttribute) value).offsetV);
        out.name("scaleU").value(((TextureAttribute) value).scaleU);
        out.name("scaleV").value(((TextureAttribute) value).scaleV);
        out.name("textureDescriptor").value(JSONSerializer.instance().serialize(((TextureAttribute) value).textureDescription));
    }else if(value instanceof ColorAttribute) {
        out.name("colour").value(((ColorAttribute) value).color.toString());
    }else if(value instanceof BlendingAttribute) {
        out.name("alpha").value(((BlendingAttribute) value).opacity);
    }
    out.endObject();
    out.endObject();
}
项目:Argent    文件:AttributeTypeAdapter.java   
@Override
public Attribute read(JsonReader in) throws IOException {
    Attribute attr = null;
    long type = -1;
    String alias = "";
    in.beginObject();
    while(in.hasNext()) {
        switch(in.nextName()) {
            case "type": type = in.nextLong(); break;
            case "alias": alias = in.nextString(); break;
            case "attrData":
                attr = buildFromAlias(alias);
                if(attr == null) break;
                in.beginObject();
                while(in.hasNext()) {
                    switch(in.nextName()) {
                        case "offsetU":
                            ((TextureAttribute)attr).offsetU = (float) in.nextDouble(); break;
                        case "offsetV":
                            ((TextureAttribute)attr).offsetV = (float) in.nextDouble(); break;
                        case "scaleU":
                            ((TextureAttribute)attr).scaleU = (float) in.nextDouble(); break;
                        case "scaleV":
                            ((TextureAttribute)attr).scaleV = (float) in.nextDouble(); break;
                        case "textureDescriptor":
                            ((TextureAttribute)attr).textureDescription.set(JSONSerializer.instance().deserialize(in.nextString(), TextureDescriptor.class)); break;
                        case "colour":
                            ((ColorAttribute)attr).color.set(Color.valueOf(in.nextString())); break;
                        case "alpha":
                            ((BlendingAttribute)attr).opacity = (float) in.nextDouble(); break;
                    }
                }
                in.endObject();
                break;
        }
    }
    in.endObject();
    return attr;
}