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


Java Usage類代碼示例

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


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

示例1: create

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的package包/類
@Override
public void create() {
	
        rotationSpeed = 0.5f;
        mesh = new Mesh(true, 4, 6,
                        new VertexAttribute(VertexAttributes.Usage.Position, 3,"attr_Position"),
                        new VertexAttribute(Usage.TextureCoordinates, 2, "attr_texCoords"));
        texture = new Texture(Gdx.files.internal("data/Jellyfish.jpg"));
        mesh.setVertices(new float[] { 
                         -1024f, -1024f, 0, 0, 1,
                          1024f, -1024f, 0, 1, 1,
                          1024f,  1024f, 0, 1, 0,
                         -1024f,  1024f, 0, 0, 0
        });
        mesh.setIndices(new short[] { 0, 1, 2, 2, 3, 0 });

        cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());            
        xScale = Gdx.graphics.getWidth()/(float)TARGET_WIDTH;
        yScale = Gdx.graphics.getHeight()/(float)TARGET_HEIGHT;
        font = loadBitmapFont("default.fnt", "default.png");
        scale = Math.min(xScale, yScale);
        cam.zoom = 1/scale;
      //  cam.project(start_position);
        cam.position.set(0, 0, 0);
        batch = new SpriteBatch();
}
 
開發者ID:game-libgdx-unity,項目名稱:GDX-Engine,代碼行數:27,代碼來源:TestCamera.java

示例2: ShaderEffect

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的package包/類
/**
 * Instantiates a new ShaderEffect. The ShaderEffect will NOT own shader
 * program, so it will not dispose it either!
 * 
 * @param program
 *            the ShaderProgram to use for this effect
 */
public ShaderEffect(ShaderProgram program) {
	this.program = program;

	if (meshRefCount++ <= 0) {
		mesh = new Mesh(VertexDataType.VertexArray, true, 4, 0,
				new VertexAttribute(Usage.Position, 2, ShaderProgram.POSITION_ATTRIBUTE),
				new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));

		// @formatter:off
		float[] verts = {
				// vertex    texture
				  -1, -1,    0f, 0f,
				   1, -1,    1f, 0f,
				   1,  1,    1f, 1f,
				  -1,  1,    0f, 1f,
		};
		// @formatter:on

		mesh.setVertices(verts);
	}
}
 
開發者ID:spookygames,項目名稱:gdx-gfx,代碼行數:29,代碼來源:ShaderEffect.java

示例3: createEntity

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的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

示例4: PositionalLight

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的package包/類
public PositionalLight (RayHandler rayHandler, int rays, Color color, float distance, float x, float y, float directionDegree) {
	super(rayHandler, rays, color, directionDegree, distance);
	start.x = x;
	start.y = y;
	sin = new float[rays];
	cos = new float[rays];
	endX = new float[rays];
	endY = new float[rays];

	lightMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum, 0, new VertexAttribute(Usage.Position, 2,
		"vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
		new VertexAttribute(Usage.Generic, 1, "s"));
	softShadowMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum * 2, 0, new VertexAttribute(Usage.Position, 2,
		"vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
		new VertexAttribute(Usage.Generic, 1, "s"));
	setMesh();
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:18,代碼來源:PositionalLight.java

示例5: DirectionalLight

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的package包/類
/** Directional lights simulate light source that locations is at infinite distance. Direction and intensity is same everywhere.
 * -90 direction is straight from up.
 * 
 * @param rayHandler
 * @param rays
 * @param color
 * @param directionDegree */
public DirectionalLight (RayHandler rayHandler, int rays, Color color, float directionDegree) {

	super(rayHandler, rays, color, directionDegree, Float.POSITIVE_INFINITY);

	vertexNum = (vertexNum - 1) * 2;

	start = new Vector2[rayNum];
	end = new Vector2[rayNum];
	for (int i = 0; i < rayNum; i++) {
		start[i] = new Vector2();
		end[i] = new Vector2();
	}
	setDirection(direction);

	lightMesh = new Mesh(VertexDataType.VertexArray, staticLight, vertexNum, 0, new VertexAttribute(Usage.Position, 2,
		"vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
		new VertexAttribute(Usage.Generic, 1, "s"));
	softShadowMesh = new Mesh(VertexDataType.VertexArray, staticLight, vertexNum, 0, new VertexAttribute(Usage.Position, 2,
		"vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
		new VertexAttribute(Usage.Generic, 1, "s"));
	update();
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:30,代碼來源:DirectionalLight.java

示例6: RavChainLight

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的package包/類
/** Creates chain light from specified vertices
 * 
 * @param rayHandler not {@code null} instance of RayHandler
 * @param rays number of rays - more rays make light to look more realistic but will decrease performance, can't be less than
 *           MIN_RAYS
 * @param color color, set to {@code null} to use the default color
 * @param distance distance of light
 * @param rayDirection direction of rays
 *           <ul>
 *           <li>1 = left</li>
 *           <li>-1 = right</li>
 *           </ul>
 * @param chain float array of (x, y) vertices from which rays will be evenly distributed */
public RavChainLight (RayHandler rayHandler, int rays, Color color, float distance, int rayDirection, float[] chain) {
	super(rayHandler, rays, color, distance, 0f);

	rayStartOffset = ChainLight.defaultRayStartOffset;
	this.rayDirection = rayDirection;
	vertexNum = (vertexNum - 1) * 2;
	endX = new float[rays];
	endY = new float[rays];
	startX = new float[rays];
	startY = new float[rays];
	this.chain = (chain != null) ? new FloatArray(chain) : new FloatArray();

	lightMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum, 0,
		new VertexAttribute(Usage.Position, 2, "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
		new VertexAttribute(Usage.Generic, 1, "s"));
	softShadowMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum * 2, 0,
		new VertexAttribute(Usage.Position, 2, "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
		new VertexAttribute(Usage.Generic, 1, "s"));
	setMesh();
}
 
開發者ID:Quexten,項目名稱:RavTech,代碼行數:34,代碼來源:RavChainLight.java

示例7: createAxes

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的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

示例8: canRender

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的package包/類
@Override
public boolean canRender (Renderable renderable) {
	if (renderable.material.has(BlendingAttribute.Type)) {
		if ((materialMask & BlendingAttribute.Type) != BlendingAttribute.Type)
			return false;
		if (renderable.material.has(TextureAttribute.Diffuse) != ((materialMask & TextureAttribute.Diffuse) == TextureAttribute.Diffuse))
			return false;
	}
	final boolean skinned = ((renderable.mesh.getVertexAttributes().getMask() & Usage.BoneWeight) == Usage.BoneWeight);
	if (skinned != (numBones > 0)) return false;
	if (!skinned) return true;
	int w = 0;
	final int n = renderable.mesh.getVertexAttributes().size();
	for (int i = 0; i < n; i++) {
		final VertexAttribute attr = renderable.mesh.getVertexAttributes().get(i);
		if (attr.usage == Usage.BoneWeight) w |= (1 << attr.unit);
	}
	return w == weights;
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:20,代碼來源:DepthShader.java

示例9: createAttributes

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的package包/類
/** @param usage bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal and
 *           TextureCoordinates is supported. */
public static VertexAttributes createAttributes (long usage) {
	final Array<VertexAttribute> attrs = new Array<VertexAttribute>();
	if ((usage & Usage.Position) == Usage.Position)
		attrs.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE));
	if ((usage & Usage.Color) == Usage.Color) attrs.add(new VertexAttribute(Usage.Color, 4, ShaderProgram.COLOR_ATTRIBUTE));
	if ((usage & Usage.ColorPacked) == Usage.ColorPacked)
		attrs.add(new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE));
	if ((usage & Usage.Normal) == Usage.Normal)
		attrs.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
	if ((usage & Usage.TextureCoordinates) == Usage.TextureCoordinates)
		attrs.add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
	final VertexAttribute attributes[] = new VertexAttribute[attrs.size];
	for (int i = 0; i < attributes.length; i++)
		attributes[i] = attrs.get(i);
	return new VertexAttributes(attributes);
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:19,代碼來源:MeshBuilder.java

示例10: setMesh

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的package包/類
@Override
public void setMesh(Mesh mesh, Model model){
	super.setMesh(mesh, model);
	vertexSize = mesh.getVertexSize()/4;
	positionOffset = mesh.getVertexAttribute(Usage.Position).offset/4;
	int indicesCount = mesh.getNumIndices();
	if(indicesCount >0){
		indices = new short[indicesCount];
		mesh.getIndices(indices);
		triangleCount = indices.length/3;
	}
	else indices = null;
	vertexCount = mesh.getNumVertices();
	vertices = new float[ vertexCount* vertexSize];
	mesh.getVertices(vertices);
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:17,代碼來源:UnweightedMeshSpawnShapeValue.java

示例11: create

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的package包/類
@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)));
}
 
開發者ID:if1live,項目名稱:amatsukaze,代碼行數:23,代碼來源:FogTest.java

示例12: PolygonSpriteBatch

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的package包/類
/** Constructs a new PolygonSpriteBatch. Sets the projection matrix to an orthographic projection with y-axis point upwards,
 * x-axis point to the right and the origin being in the bottom left corner of the screen. The projection will be pixel perfect
 * with respect to the current screen resolution.
 * <p>
 * The defaultShader specifies the shader to use. Note that the names for uniforms for this default shader are different than
 * the ones expect for shaders set with {@link #setShader(ShaderProgram)}. See {@link SpriteBatch#createDefaultShader()}.
 * @param size The max number of vertices and number of triangles in a single batch. Max of 10920.
 * @param defaultShader The default shader to use. This is not owned by the PolygonSpriteBatch and must be disposed separately. */
public PolygonSpriteBatch (int size, ShaderProgram defaultShader) {
	// 32767 is max index, so 32767 / 3 - (32767 / 3 % 3) = 10920.
	if (size > 10920) throw new IllegalArgumentException("Can't have more than 10920 triangles per batch: " + size);

	mesh = new Mesh(VertexDataType.VertexArray, false, size, size * 3, new VertexAttribute(Usage.Position, 2,
		ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE),
		new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));

	vertices = new float[size * VERTEX_SIZE];
	triangles = new short[size * 3];

	if (defaultShader == null) {
		shader = SpriteBatch.createDefaultShader();
		ownsShader = true;
	} else
		shader = defaultShader;

	projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:28,代碼來源:PolygonSpriteBatch.java

示例13: create

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的package包/類
@Override
public void create () {
	modelBatch = new ModelBatch(new BaseShaderProvider() {
		@Override
		protected Shader createShader (Renderable renderable) {
			return new TestShader();
		}
	});

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

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

	Material material = new Material(new TestAttribute(1f));
	ModelBuilder builder = new ModelBuilder();
	model = builder.createCone(5, 5, 5, 20, material, Usage.Position);
	instance = new ModelInstance(model);
	testAttribute = (TestAttribute)instance.materials.get(0).get(TestAttribute.ID);
}
 
開發者ID:if1live,項目名稱:amatsukaze,代碼行數:26,代碼來源:ShaderTest.java

示例14: create

import com.badlogic.gdx.graphics.VertexAttributes.Usage; //導入依賴的package包/類
@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)));
	}
 
開發者ID:if1live,項目名稱:amatsukaze,代碼行數:26,代碼來源:Basic3DTest.java

示例15: create

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


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