本文整理汇总了Java中net.minecraft.client.renderer.vertex.VertexFormatElement.getUsage方法的典型用法代码示例。如果您正苦于以下问题:Java VertexFormatElement.getUsage方法的具体用法?Java VertexFormatElement.getUsage怎么用?Java VertexFormatElement.getUsage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.client.renderer.vertex.VertexFormatElement
的用法示例。
在下文中一共展示了VertexFormatElement.getUsage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapFormats
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
public static int[] mapFormats(VertexFormat from, VertexFormat to)
{
int fromCount = from.getElementCount();
int toCount = to.getElementCount();
int[] eMap = new int[fromCount];
for(int e = 0; e < fromCount; e++)
{
VertexFormatElement expected = from.getElement(e);
int e2;
for(e2 = 0; e2 < toCount; e2++)
{
VertexFormatElement current = to.getElement(e2);
if(expected.getUsage() == current.getUsage() && expected.getIndex() == current.getIndex())
{
break;
}
}
eMap[e] = e2;
}
return eMap;
}
示例2: putVertex
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
private static void putVertex(UnpackedBakedQuad.Builder builder, VertexFormat format, EnumFacing face, Vertex5 vert, Colour colour) {
for (int e = 0; e < format.getElementCount(); e++) {
VertexFormatElement element = format.getElement(e);
switch (element.getUsage()) {
case POSITION:
Vector3 vec = vert.vec;
builder.put(e, (float) vec.x, (float) vec.y, (float) vec.z, 1);
break;
case NORMAL:
builder.put(e, face.getFrontOffsetX(), face.getFrontOffsetY(), face.getFrontOffsetZ(), 0);
break;
case COLOR:
builder.put(e, (colour.r & 0xFF) / 255F, (colour.g & 0xFF) / 255F, (colour.b & 0xFF) / 255F, (colour.a & 0xFF) / 255F);
break;
case UV:
UV uv = vert.uv;
builder.put(e, (float) uv.u, (float) uv.v, 0, 1);
break;
default:
builder.put(e);
break;
}
}
}
示例3: shadeQuadFaces
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
public static List<BakedQuad> shadeQuadFaces(List<BakedQuad> quads) {
LinkedList<BakedQuad> shadedQuads = new LinkedList<>();
for (BakedQuad quad : quads) {
int[] rawData = quad.getVertexData();
for (int v = 0; v < 4; v++) {
for (int e = 0; e < quad.getFormat().getElementCount(); e++) {
VertexFormatElement element = quad.getFormat().getElement(e);
if (element.getUsage() == EnumUsage.COLOR) {
float[] data = new float[4];
LightUtil.unpack(rawData, data, quad.getFormat(), v, e);
data = diffuseFaceLight(quad.getFace(), data);
LightUtil.pack(data, rawData, quad.getFormat(), v, e);
}
}
}
shadedQuads.add(new BakedQuad(rawData, quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat()));
}
return shadedQuads;
}
示例4: addQuad
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
private void addQuad(final UnpackedBakedQuad.Builder builder, EnumFacing face, TextureAtlasSprite sprite, Vertex position, Vertex texture) {
for (int e = 0; e < format.getElementCount(); e++) {
final VertexFormatElement el = format.getElement(e);
switch (el.getUsage()) {
case POSITION:
builder.put(e, position.x, position.y, position.z);
break;
case NORMAL:
builder.put(e, face.getFrontOffsetX(), face.getFrontOffsetY(), face.getFrontOffsetZ());
break;
case COLOR:
builder.put(e, 1, 1, 1, 1);
break;
case UV:
if (el.getIndex() == 0) {
builder.put(e, sprite.getInterpolatedU(16 * texture.u), sprite.getInterpolatedV(16 * texture.v));
} else {
builder.put(e, 0, 0);
}
break;
default:
builder.put(e);
}
}
}
示例5: draw
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
@SuppressWarnings("incomplete-switch")
public void draw(VertexBuffer vertexBufferIn)
{
if (vertexBufferIn.getVertexCount() > 0)
{
VertexFormat vertexformat = vertexBufferIn.getVertexFormat();
int i = vertexformat.getNextOffset();
ByteBuffer bytebuffer = vertexBufferIn.getByteBuffer();
List<VertexFormatElement> list = vertexformat.getElements();
for (int j = 0; j < list.size(); ++j)
{
VertexFormatElement vertexformatelement = (VertexFormatElement)list.get(j);
VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.getUsage();
int k = vertexformatelement.getType().getGlConstant();
int l = vertexformatelement.getIndex();
bytebuffer.position(vertexformat.getOffset(j));
// moved to VertexFormatElement.preDraw
vertexformatelement.getUsage().preDraw(vertexformat, j, i, bytebuffer);
}
GlStateManager.glDrawArrays(vertexBufferIn.getDrawMode(), 0, vertexBufferIn.getVertexCount());
int i1 = 0;
for (int j1 = list.size(); i1 < j1; ++i1)
{
VertexFormatElement vertexformatelement1 = (VertexFormatElement)list.get(i1);
VertexFormatElement.EnumUsage vertexformatelement$enumusage1 = vertexformatelement1.getUsage();
int k1 = vertexformatelement1.getIndex();
// moved to VertexFormatElement.postDraw
vertexformatelement1.getUsage().postDraw(vertexformat, i1, i, bytebuffer);
}
}
vertexBufferIn.reset();
}
示例6: put
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
@Override
public void put(
final int element,
final float... data )
{
final VertexFormatElement e = getVertexFormat().getElement( element );
if ( e.getUsage() == EnumUsage.UV && e.getIndex() != 1 )
{
sumU += data[0];
sumV += data[1];
++vertCount;
}
}
示例7: put
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
@Override
public void put(int e, float... data) {
VertexFormat format = getVertexFormat();
VertexFormatElement fmte = format.getElement(e);
switch (fmte.getUsage()) {
case POSITION:
ccrs.vert.vec.set(data).add(offset);
break;
case UV:
if (fmte.getIndex() == 0) {
ccrs.vert.uv.set(data[0], data[1]);
} else {
ccrs.brightness = (int) (data[1] * 0xFFFF / 2) << 16 | (int) (data[0] * 0xFFFF / 2);
}
break;
case COLOR:
ccrs.colour = Colour.packRGBA(data);
break;
case NORMAL:
ccrs.normal.set(data);
break;
case PADDING:
break;
default:
throw new UnsupportedOperationException("Generic vertex format element");
}
if (e == format.getElementCount() - 1) {
ccrs.writeVert();
}
}
示例8: writeVert
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
public void writeVert() {
if (r instanceof BakingVertexBuffer) {
((BakingVertexBuffer) r).setSprite(sprite);
}
for (int e = 0; e < fmt.getElementCount(); e++) {
VertexFormatElement fmte = fmt.getElement(e);
switch (fmte.getUsage()) {
case POSITION:
r.pos(vert.vec.x, vert.vec.y, vert.vec.z);
break;
case UV:
if (fmte.getIndex() == 0) {
r.tex(vert.uv.u, vert.uv.v);
} else {
r.lightmap(brightness >> 16 & 65535, brightness & 65535);
}
break;
case COLOR:
if (r.isColorDisabled()) {
//-_- Fucking mojang..
r.nextVertexFormatIndex();
} else {
r.color(colour >>> 24, colour >> 16 & 0xFF, colour >> 8 & 0xFF, alphaOverride >= 0 ? alphaOverride : colour & 0xFF);
}
break;
case NORMAL:
r.normal((float) normal.x, (float) normal.y, (float) normal.z);
break;
case PADDING:
break;
default:
throw new UnsupportedOperationException("Generic vertex format element");
}
}
r.endVertex();
}
示例9: endVertex
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
@Override
public void endVertex() {
VertexFormat format = getVertexFormat();
for (int e = 0; e < format.getElementCount(); e++) {
VertexFormatElement fmte = format.getElement(e);
switch (fmte.getUsage()) {
case POSITION:
wrapped.pos(pos.x, pos.y, pos.z);
break;
case UV:
if (fmte.getIndex() == 0) {
wrapped.tex(uv.u, uv.v);
} else {
wrapped.lightmap(lmap[0], lmap[1]);
}
break;
case COLOR:
if (wrapped.isColorDisabled()) {
//-_- Fucking mojang..
wrapped.nextVertexFormatIndex();
} else {
wrapped.color(colour.r & 0xFF, colour.g & 0xFF, colour.b & 0xFF, colour.a & 0xFF);
}
break;
case NORMAL:
wrapped.normal((float) normal.x, (float) normal.y, (float) normal.z);
break;
case PADDING:
break;
default:
throw new UnsupportedOperationException("Generic vertex format element");
}
}
wrapped.endVertex();
}
示例10: renderBlockLayer
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
private void renderBlockLayer(BlockRenderLayer layer) {
if (OpenGlHelper.useVbo()) {
GlStateManager.glEnableClientState(32884);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
GlStateManager.glEnableClientState(32888);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);
GlStateManager.glEnableClientState(32888);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
GlStateManager.glEnableClientState(32886);
}
this.chunkContainer.renderLayer(layer);
if (OpenGlHelper.useVbo()) {
for (VertexFormatElement element : DefaultVertexFormats.BLOCK.getElements()) {
VertexFormatElement.EnumUsage usage = element.getUsage();
int index = element.getIndex();
switch (usage) {
case POSITION:
GlStateManager.glDisableClientState(32884);
break;
case UV:
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + index);
GlStateManager.glDisableClientState(32888);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
break;
case COLOR:
GlStateManager.glDisableClientState(32886);
GlStateManager.resetColor();
}
}
}
}
示例11: put
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
@Override
public void put(int element, float... data) {
VertexFormatElement el = format.getElement(element);
switch (el.getUsage()) {
case POSITION: {
Vector4f vec = new Vector4f(data);
vec.w = 1;
transform.transform(vec);
vec.get(newData);
parent.put(element, newData);
break;
}
case NORMAL: {
parent.put(element, data);
/*Vector4f vec = new Vector4f(data);
vec.w = 0;
transform.transform(vec);
vec.w = 0;
vec.get(newData);
parent.put(element, newData);*/
break;
}
default:
parent.put(element, data);
break;
}
}
示例12: putIntoBakedQuadBuilder
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
public void putIntoBakedQuadBuilder(UnpackedBakedQuad.Builder builder, TextureAtlasSprite sprite) {
Vertex transformed = getTransformedVertex();
Tuple4f positionBuffer = new Vector4f();
transformed.getPosition(positionBuffer);
Tuple3f normalBuffer = new Vector3f();
transformed.getNormal(normalBuffer);
Tuple2f uvBuffer = new Vector2f();
transformed.getUV(uvBuffer);
VertexFormat vertexFormat = builder.getVertexFormat();
int elementCount = vertexFormat.getElementCount();
for (int e = 0; e < elementCount; e++) {
VertexFormatElement element = vertexFormat.getElement(e);
switch (element.getUsage()) {
case POSITION:
builder.put(e, positionBuffer.x, positionBuffer.z, -positionBuffer.y, positionBuffer.w);
break;
case NORMAL:
builder.put(e, normalBuffer.x, normalBuffer.z, -normalBuffer.y, 0);
break;
case UV:
if (element.getIndex() != 0)
break;
builder.put(
e,
sprite.getInterpolatedU(uvBuffer.x * 16),
sprite.getInterpolatedV(uvBuffer.y * 16),
0,
1);
break;
case COLOR:
builder.put(e, 1, 1, 1, 1);
break;
default:
builder.put(e);
}
}
}
示例13: setupAttributes
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
private void setupAttributes(final VertexFormat format) {
boolean hasTexture = false;
boolean hasColor = false;
final List<VertexFormatElement> elements = format.getElements();
for (int i = 0; i < elements.size(); i++) {
final VertexFormatElement el = elements.get(i);
switch (el.getUsage()) {
case COLOR:
attributePointer("aColor", format, i, el);
hasColor = true;
break;
case POSITION:
attributePointer("aVertex", format, i, el);
break;
case UV:
attributePointer("aTexCoord", format, i, el);
hasTexture = true;
break;
default:
break;
}
}
shader.uniform1f("uHasTexture", hasTexture? 1f : 0f);
shader.uniform1f("uHasColor", hasColor? 1f : 0f);
shader.uniform1i("uDefaultTexture", 0);
}
示例14: createElementOffsetMap
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
private static Map<VertexFormatElement, Integer> createElementOffsetMap(VertexFormat format) {
ImmutableMap.Builder<VertexFormatElement, Integer> builder = ImmutableMap.builder();
for (int i = 0; i < format.getElementCount(); i++) {
VertexFormatElement vfe = format.getElement(i);
if (vfe.getUsage() != EnumUsage.PADDING)
builder.put(vfe, format.getOffset(i));
}
return builder.build();
}
示例15: func_181679_a
import net.minecraft.client.renderer.vertex.VertexFormatElement; //导入方法依赖的package包/类
@SuppressWarnings("incomplete-switch")
public void func_181679_a(WorldRenderer p_181679_1_)
{
if (p_181679_1_.getVertexCount() > 0)
{
VertexFormat vertexformat = p_181679_1_.getVertexFormat();
int i = vertexformat.getNextOffset();
ByteBuffer bytebuffer = p_181679_1_.getByteBuffer();
List<VertexFormatElement> list = vertexformat.getElements();
for (int j = 0; j < list.size(); ++j)
{
VertexFormatElement vertexformatelement = (VertexFormatElement)list.get(j);
VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.getUsage();
int k = vertexformatelement.getType().getGlConstant();
int l = vertexformatelement.getIndex();
bytebuffer.position(vertexformat.func_181720_d(j));
switch (vertexformatelement$enumusage)
{
case POSITION:
GL11.glVertexPointer(vertexformatelement.getElementCount(), k, i, bytebuffer);
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
break;
case UV:
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + l);
GL11.glTexCoordPointer(vertexformatelement.getElementCount(), k, i, bytebuffer);
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
break;
case COLOR:
GL11.glColorPointer(vertexformatelement.getElementCount(), k, i, bytebuffer);
GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
break;
case NORMAL:
GL11.glNormalPointer(k, i, bytebuffer);
GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
}
}
GL11.glDrawArrays(p_181679_1_.getDrawMode(), 0, p_181679_1_.getVertexCount());
int i1 = 0;
for (int j1 = list.size(); i1 < j1; ++i1)
{
VertexFormatElement vertexformatelement1 = (VertexFormatElement)list.get(i1);
VertexFormatElement.EnumUsage vertexformatelement$enumusage1 = vertexformatelement1.getUsage();
int k1 = vertexformatelement1.getIndex();
switch (vertexformatelement$enumusage1)
{
case POSITION:
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
break;
case UV:
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + k1);
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
break;
case COLOR:
GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
GlStateManager.resetColor();
break;
case NORMAL:
GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
}
}
}
p_181679_1_.reset();
}