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


Java VertexAttribute.ColorUnpacked方法代碼示例

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


在下文中一共展示了VertexAttribute.ColorUnpacked方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

import com.badlogic.gdx.graphics.VertexAttribute; //導入方法依賴的package包/類
@Override
public void create () {
	String vertexShader = "attribute vec4 a_position;    \n" + "attribute vec4 a_color;\n" + "attribute vec2 a_texCoord0;\n"
		+ "uniform mat4 u_worldView;\n" + "varying vec4 v_color;" + "varying vec2 v_texCoords;"
		+ "void main()                  \n" + "{                            \n" + "   v_color = vec4(1, 1, 1, 1); \n"
		+ "   v_texCoords = a_texCoord0; \n" + "   gl_Position =  u_worldView * a_position;  \n"
		+ "}                            \n";
	String fragmentShader = "#ifdef GL_ES\n" + "precision mediump float;\n" + "#endif\n" + "varying vec4 v_color;\n"
		+ "varying vec2 v_texCoords;\n" + "uniform sampler2D u_texture;\n" + "void main()                                  \n"
		+ "{                                            \n" + "  gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n"
		+ "}";

	shader = new ShaderProgram(vertexShader, fragmentShader);
	if (shader.isCompiled() == false) {
		Gdx.app.log("ShaderTest", shader.getLog());
		Gdx.app.exit();
	}

	mesh = new Mesh(true, 4, 6, VertexAttribute.Position(), VertexAttribute.ColorUnpacked(), VertexAttribute.TexCoords(0));
	mesh.setVertices(new float[] {-0.5f, -0.5f, 0, 1, 1, 1, 1, 0, 1, 0.5f, -0.5f, 0, 1, 1, 1, 1, 1, 1, 0.5f, 0.5f, 0, 1, 1, 1,
		1, 1, 0, -0.5f, 0.5f, 0, 1, 1, 1, 1, 0, 0});
	mesh.setIndices(new short[] {0, 1, 2, 2, 3, 0});
	texture = new Texture(Gdx.files.internal("data/bobrgb888-32x32.png"));
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:25,代碼來源:MeshShaderTest.java

示例2: setupMesh

import com.badlogic.gdx.graphics.VertexAttribute; //導入方法依賴的package包/類
private void setupMesh(Model model, MaterialTileMapping textures) {
	int numVertices = countModelVertices(model);
	vertices = new Vertices(
			numVertices,
			VertexAttribute.Position(),
			VertexAttribute.ColorUnpacked(),
			VertexAttribute.Normal(),
			VertexAttribute.TexCoords(0)
	);

	model.calculateBoundingBox(tmpModelBounds);
	if (scaleToSize != null) {
		MathHelpers.getScaleFactor(tmpModelBounds.getDimensions(), scaleToSize, tmpScaleFactor);
		bounds = new BoundingBox().set(Vector3.Zero, scaleToSize);
	} else {
		bounds = new BoundingBox().set(Vector3.Zero, tmpModelBounds.getDimensions());
		tmpScaleFactor.set(1.0f, 1.0f, 1.0f);
	}

	for (int i = 0; i < model.nodes.size; ++i)
		collectModelNodeVertices(model.nodes.get(i), vertices, textures, color, tmpScaleFactor, positionOffset);
}
 
開發者ID:gered,項目名稱:gdx-tilemap3d,代碼行數:23,代碼來源:ModelTileMesh.java

示例3: Sunburst

import com.badlogic.gdx.graphics.VertexAttribute; //導入方法依賴的package包/類
public Sunburst(Stage stage) {
	this.setX(stage.getWidth() / 2);
	this.setY(stage.getHeight() / 2);
	String vertexShader = "attribute vec4 " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" //
			+ "attribute vec4 " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" //
			+ "uniform mat4 u_transformMatrix;\n" //
			+ "uniform mat4 u_projectionViewMatrix;\n" //
			+ "varying vec4 v_color;\n" //
			+ "\n" //
			+ "void main()\n" //
			+ "{\n" //
			+ "   v_color = " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" //
			+ "   gl_Position =  u_transformMatrix * u_projectionViewMatrix * " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" //
			+ "}\n";
	String fragmentShader = "#ifdef GL_ES\n" //
			+ "#define LOWP lowp\n" //
			+ "precision mediump float;\n" //
			+ "#else\n" //
			+ "#define LOWP \n" //
			+ "#endif\n" //
			+ "varying LOWP vec4 v_color;\n" //
			+ "void main()\n"//
			+ "{\n" //
			+ "  gl_FragColor = v_color;\n" //
			+ "}";
	shader = new ShaderProgram(vertexShader, fragmentShader);

	float radius = stage.getWidth();
	int i = 0;
	float[] vertices = new float[378];
	for (int angle = 0; angle < 360; angle += 20) {
		i = makePoint(radius, i, vertices, angle);
		i = makePoint(radius, i, vertices, angle + 10);
		vertices[i++] = getX();
		vertices[i++] = getY();
		vertices[i++] = 0f;
		vertices[i++] = 0f;
		vertices[i++] = 0f;
		vertices[i++] = 0.5f;
		vertices[i++] = 0f;
	}

	mesh = new Mesh(true, vertices.length, 0, VertexAttribute.Position(), VertexAttribute.ColorUnpacked());
	mesh.setVertices(vertices);
	transformMatrix = new Matrix4();
}
 
開發者ID:frigidplanet,項目名稱:droidtowers,代碼行數:47,代碼來源:Sunburst.java


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