當前位置: 首頁>>代碼示例>>Java>>正文


Java Material類代碼示例

本文整理匯總了Java中com.badlogic.gdx.graphics.g3d.Material的典型用法代碼示例。如果您正苦於以下問題:Java Material類的具體用法?Java Material怎麽用?Java Material使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Material類屬於com.badlogic.gdx.graphics.g3d包,在下文中一共展示了Material類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: GameObject

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
public GameObject(ScreenBase context, Model model, BoundingBox bounds) {
super(model);
this.context = context;
this.customBounds = bounds;

      this.bounds = this.customBounds != null ? this.customBounds : new BoundingBox();
      this.center = new Vector3();
      this.enabled = true;
      updateBox();
      
      this.animations = new AnimationController(this);
      this.blending = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
      
      for(Material item : materials){
      	item.set(new DepthTestAttribute(GL20.GL_LEQUAL, 0.01f, 25f, true));
	item.set(FloatAttribute.createAlphaTest(0.01f));
      	item.set(blending);
      }
  }
 
開發者ID:raphaelbruno,項目名稱:ZombieInvadersVR,代碼行數:20,代碼來源:GameObject.java

示例2: createEntity

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
@Deprecated //Only for creating the first one
private void createEntity(float f, float g, float h) {
	Vector3 position=new Vector3(f,g,h);
	List<EntityStatic> collidingEntities=space.getWithin(position, 0.03);

	if(collidingEntities.size() == 0) {
		EntityStatic entity=new EntityStatic(new ModelInstance(
				Assets.modelBuilder.createBox(0.03f, 0.03f, 0.06f, 
						new Material(StrategyGame.blueAttr), 
						Usage.Normal | Usage.Position)),
				position);

		space.addEntity(entity);
	} else {
		for(EntityStatic e:collidingEntities){
			e.damage(2);
		}
	}
}
 
開發者ID:DevelopersGuild,項目名稱:Planetbase,代碼行數:20,代碼來源:StrategyGame.java

示例3: create

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
@Override
public void create() {
    super.create();

    geometryPass = new ShaderProgram(
            Gdx.files.internal("shaders/g_buffer.vert"),
            Gdx.files.internal("shaders/g_buffer.frag"));

    lightingPass = new ShaderProgram(
            Gdx.files.internal("shaders/deferred_shader.vert"),
            Gdx.files.internal("shaders/deferred_shader.frag"));

    ModelBuilder mb = new ModelBuilder();
    Model cube = mb.createBox(1, 1, 1, new Material(),
            VertexAttributes.Usage.Position |
                    VertexAttributes.Usage.Normal |
                    VertexAttributes.Usage.TextureCoordinates);
    cubeMesh = cube.meshes.first();
}
 
開發者ID:MovementSpeed,項目名稱:nhglib,代碼行數:20,代碼來源:MainDef.java

示例4: select

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
@Override
    protected AbstractPanel select(T obj) {
        super.select(obj);
        if(obj == null) {
            matList.clearItems();
            selectMtl(null);
            return this;
        }
        ModelInstance inst = gameWorld.renderer().getRenderable(obj);
        matList.clearItems();
        inst.nodes.forEach(n -> n.parts.forEach(p -> {
            ArgentList.ArgentListElement<Material> e = new ArgentList.ArgentListElement<>(p.material, this::selectMtl);
            e.getString = () -> String.format("[%s] %s", n.id, e.obj.id);
            matList.addItem(e);
        }));
//        inst.materials.forEach(m -> {
//            ArgentList.ArgentListElement<Material> e = new ArgentList.ArgentListElement<>(m, this::selectMtl);
//            e.getString = () -> e.obj.id;
//            matList.addItem(e);
//        });

        selectMtl(null);
        return this;
    }
 
開發者ID:ncguy2,項目名稱:Argent,代碼行數:25,代碼來源:MaterialPanel.java

示例5: selectMtl

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
private void selectMtl(Material mtl) {
        configTree.clearChildren();
        selectedMtl = mtl;
        if(mtl == null) return;
        MaterialWrapper wrapper = new MaterialWrapper(mtl);
        List<ConfigurableAttribute<?>> attrs = wrapper.getConfigAttrs();
        builder.compileSet(configTree, attrs);
        configTree.getRootNodes().forEach(node -> node.setExpanded(true));
//        attrs.forEach(ca -> {
//            System.out.println(ca.displayName());
//            Object compObj = builder.buildComponent(ca);
//            if (compObj instanceof Actor) {
//                float compWidth = getWidth()-192;
//                configTable.add(new Label(ca.displayName(), skin)).width(192);
//                configTable.add((Actor) compObj).width(compWidth-10);
//                configTable.row();
//            }
//        });
    }
 
開發者ID:ncguy2,項目名稱:Argent,代碼行數:20,代碼來源:MaterialPanel.java

示例6: SimulationRunner

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
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");
}
 
開發者ID:Matsemann,項目名稱:eamaster,代碼行數:17,代碼來源:SimulationRunner.java

示例7: Terrain

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
private Terrain(int vertexResolution) {
    this.transform = new Matrix4();
    this.attribs = MeshBuilder.createAttributes(VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal
            | VertexAttributes.Usage.TextureCoordinates);
    this.posPos = attribs.getOffset(VertexAttributes.Usage.Position, -1);
    this.norPos = attribs.getOffset(VertexAttributes.Usage.Normal, -1);
    this.uvPos = attribs.getOffset(VertexAttributes.Usage.TextureCoordinates, -1);
    this.stride = attribs.vertexSize / 4;

    this.vertexResolution = vertexResolution;
    this.heightData = new float[vertexResolution * vertexResolution];

    this.terrainTexture = new TerrainTexture();
    this.terrainTexture.setTerrain(this);
    material = new Material();
    material.set(new TerrainTextureAttribute(TerrainTextureAttribute.ATTRIBUTE_SPLAT0, terrainTexture));
}
 
開發者ID:mbrlabs,項目名稱:Mundus,代碼行數:18,代碼來源:Terrain.java

示例8: createAxes

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
public static Model createAxes() {
    final float GRID_MIN = -10f;
    final float GRID_MAX = 10f;
    final float GRID_STEP = 1f;
    ModelBuilder modelBuilder = new ModelBuilder();
    modelBuilder.begin();
    MeshPartBuilder builder = modelBuilder.part("grid", GL20.GL_LINES,
            VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, new Material());
    builder.setColor(Color.LIGHT_GRAY);
    for (float t = GRID_MIN; t <= GRID_MAX; t += GRID_STEP) {
        builder.line(t, 0, GRID_MIN, t, 0, GRID_MAX);
        builder.line(GRID_MIN, 0, t, GRID_MAX, 0, t);
    }
    builder = modelBuilder.part("axes", GL20.GL_LINES,
            VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, new Material());
    builder.setColor(Color.RED);
    builder.line(0, 0, 0, 100, 0, 0);
    builder.setColor(Color.GREEN);
    builder.line(0, 0, 0, 0, 100, 0);
    builder.setColor(Color.BLUE);
    builder.line(0, 0, 0, 0, 0, 100);
    return modelBuilder.end();
}
 
開發者ID:mbrlabs,項目名稱:Mundus,代碼行數:24,代碼來源:UsefulMeshs.java

示例9: RotateHandle

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
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);
}
 
開發者ID:mbrlabs,項目名稱:Mundus,代碼行數:25,代碼來源:RotateTool.java

示例10: ScaleTool

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
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 };
}
 
開發者ID:mbrlabs,項目名稱:Mundus,代碼行數:25,代碼來源:ScaleTool.java

示例11: buildPlaneModel

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
public static Model buildPlaneModel(final float width,
									final float height, final Material material, final float u1,
									final float v1, final float u2, final float v2) {

	ModelBuilder modelBuilder = new ModelBuilder();
	modelBuilder.begin();
	MeshPartBuilder bPartBuilder = modelBuilder.part("rect", GL20.GL_TRIANGLES,
			VertexAttributes.Usage.Position
					| VertexAttributes.Usage.Normal
					| VertexAttributes.Usage.TextureCoordinates, material);
	bPartBuilder.setUVRange(u1, v1, u2, v2);
	bPartBuilder.rect(-(width * 0.5f), -(height * 0.5f), 0, (width * 0.5f),
			-(height * 0.5f), 0, (width * 0.5f), (height * 0.5f), 0,
			-(width * 0.5f), (height * 0.5f), 0, 0, 0, -1);

	return (modelBuilder.end());
}
 
開發者ID:jsjolund,項目名稱:GdxDemo3D,代碼行數:18,代碼來源:ModelFactory.java

示例12: MaterialInterpreter

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
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));

	}
 
開發者ID:aphex-,項目名稱:Alien-Ark,代碼行數:20,代碼來源:MaterialInterpreter.java

示例13: createInfiniteWaterPart

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
public static Model createInfiniteWaterPart(TypeInterpreter interpreter, int landscapeIndex, PlanetConfig planetConfig) {
	ModelBuilder modelBuilder = new ModelBuilder();
	MeshBuilder builder = new MeshBuilder();
	float waterHeight = interpreter.it.get(landscapeIndex).endValue;
	builder.begin(PlanetPart.VERTEX_ATTRIBUTES, GL20.GL_TRIANGLES);
	infiniteWaterHeight = waterHeight * planetConfig.landscapeHeight - 1;
	Vector3 corner01 = new Vector3(-INFINITE_WATER_SIZE, -INFINITE_WATER_SIZE, infiniteWaterHeight);
	Vector3 corner02 = new Vector3(INFINITE_WATER_SIZE, -INFINITE_WATER_SIZE, infiniteWaterHeight);
	Vector3 corner03 = new Vector3(INFINITE_WATER_SIZE, INFINITE_WATER_SIZE, infiniteWaterHeight);
	Vector3 corner04 = new Vector3(-INFINITE_WATER_SIZE, INFINITE_WATER_SIZE, infiniteWaterHeight);
	builder.rect(corner01, corner02, corner03, corner04, new Vector3(0, 0, 1));
	Material waterMaterial = planetConfig.layerConfigs.get(landscapeIndex).material;
	Mesh mesh = builder.end();
	modelBuilder.begin();
	modelBuilder.part(PlanetPart.LANDSCAPE_PART_NAME + landscapeIndex, mesh, GL20.GL_TRIANGLES, waterMaterial);
	return modelBuilder.end();
}
 
開發者ID:aphex-,項目名稱:Alien-Ark,代碼行數:18,代碼來源:ControllerPlanet.java

示例14: createWaterPart

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
/**
 * Creates a water plane.
 * @param chunk The chunk.
 */
private void createWaterPart(Chunk chunk, int landscapeIndex) {
	MeshBuilder builder = meshBuilders.get(landscapeIndex);
	float WATER_HEIGHT = interpreter.it.get(landscapeIndex).endValue;
	builder.begin(VERTEX_ATTRIBUTES, GL20.GL_TRIANGLES);
	float z = WATER_HEIGHT * planetConfig.landscapeHeight;
	float width = chunk.getWidth() * tileSize;
	float height = chunk.getHeight() * tileSize;

	Vector3 corner01 = new Vector3(0f, 0f, z);
	Vector3 corner02 = new Vector3(width, 0f, z);
	Vector3 corner03 = new Vector3(width, height, z);
	Vector3 corner04 = new Vector3(0f, height, z);

	builder.rect(corner01, corner02, corner03, corner04, new Vector3(0, 0, 1));
	Material waterMaterial = planetConfig.layerConfigs.get(landscapeIndex).material;
	Mesh mesh = builder.end();
	modelBuilder.node().id = LANDSCAPE_NODE_NAME + landscapeIndex;
	modelBuilder.part(LANDSCAPE_PART_NAME + landscapeIndex, mesh, GL20.GL_TRIANGLES, waterMaterial);
}
 
開發者ID:aphex-,項目名稱:Alien-Ark,代碼行數:24,代碼來源:PlanetPart.java

示例15: buildFaceForChunkWithAssembler

import com.badlogic.gdx.graphics.g3d.Material; //導入依賴的package包/類
private VoxelChunkRenderable buildFaceForChunkWithAssembler(Chunk chunk, VoxelsAssembler assembler, boolean haveTransparency) {
  if (!assembler.isEmpty()) {
    VoxelChunkRenderable renderable   = new VoxelChunkRenderable();
    renderable.primitiveType          = GL30.GL_TRIANGLES;

    if (ForgE.config.getBool(Config.Key.GenerateWireframe))
      renderable.wireframe           = assembler.wireframe();
    renderable.triangleCount         = assembler.getTriangleCount();
    renderable.meshFactory           = assembler.meshFactory(MeshVertexInfo.voxelTypes());

    renderable.worldTransform.idt();
    renderable.material = new Material(new SolidTerrainAttribute());
    if (haveTransparency) {
      renderable.material.set(new BlendingAttribute(true,1f));
    }

    chunk.addFace(renderable);
    return renderable;
  } else {
    return null;
  }
}
 
開發者ID:macbury,項目名稱:ForgE,代碼行數:23,代碼來源:TerrainBuilder.java


注:本文中的com.badlogic.gdx.graphics.g3d.Material類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。