当前位置: 首页 > news >正文

俄罗斯网站域名如何在网上推广自己的公司

俄罗斯网站域名,如何在网上推广自己的公司,珠海网站建设乐云seo在线制作,常州网站建设报价1 前言 本文通过一个立方体贴图的例子,讲解三维纹理贴图的应用,案例中使用 6 张不同的图片给立方体贴图,图片如下。 读者如果对 libGDX 不太熟悉,请回顾以下内容。 使用Mesh绘制三角形使用Mesh绘制矩形使用Mesh绘制圆形使用Mesh绘…

1 前言

        本文通过一个立方体贴图的例子,讲解三维纹理贴图的应用,案例中使用 6 张不同的图片给立方体贴图,图片如下。

        读者如果对 libGDX 不太熟悉,请回顾以下内容。

  • 使用Mesh绘制三角形
  • 使用Mesh绘制矩形
  • 使用Mesh绘制圆形
  • 使用Mesh绘制立方体
  • Mesh纹理贴图

2 立方体贴图

        本节将使用 Mesh、ShaderProgram、Shader 实现立方体贴图,OpenGL ES 的实现见博客 → 立方体贴图(6张图),本节完整代码资源见 → libGDX Mesh立方体贴图(6张图)。

        DesktopLauncher.java

package com.zhyan8.game;import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;public class DesktopLauncher {public static void main (String[] arg) {Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();config.setForegroundFPS(60);config.setTitle("CubeChartlet");new Lwjgl3Application(new CubeChartlet(), config);}
}

        CubeChartlet.java

package com.zhyan8.game;import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL30;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Vector3;public class CubeChartlet extends ApplicationAdapter {private PerspectiveCamera mCamera;private ShaderProgram mShaderProgram;private Mesh mMesh;private Texture[] mTextures;private Vector3 mRotateAxis; // 旋转轴private int mRotateAgree = 0; // 旋转角度Matrix4 mModelMatrix; // 模型变换矩阵@Overridepublic void create() {initCamera();initShader();initMesh();initTextures();mRotateAxis = new Vector3(0.5f, 1f, 1f);mModelMatrix = new Matrix4();}@Overridepublic void render() {Gdx.gl.glClearColor(0.455f, 0.725f, 1.0f, 1.0f);Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT);Gdx.gl.glEnable(GL30.GL_DEPTH_TEST);mShaderProgram.bind();transform();renderCube();}@Overridepublic void dispose() {mShaderProgram.dispose();mMesh.dispose();}private void renderCube() {for (int i = 0; i < mTextures.length; i++) { // 给每个面都贴图// mShaderProgram.setUniformi("u_texture", 0); // 设置纹理单元mTextures[i].bind(0);mMesh.render(mShaderProgram, GL30.GL_TRIANGLE_FAN, i * 4, 4);}}private void initCamera() { // 初始化相机mCamera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());mCamera.near = 0.3f;mCamera.far = 1000f;mCamera.position.set(0f, 0f, 4f);mCamera.lookAt(0, 0, 0);mCamera.update();}private void initShader() { // 初始化着色器程序String vertex = Gdx.files.internal("shaders/square_chartlet_vertex.glsl").readString();String fragment = Gdx.files.internal("shaders/square_chartlet_fragment.glsl").readString();mShaderProgram = new ShaderProgram(vertex, fragment);}private void initMesh() { // 初始化网格float[] vertices = Model.vertices;short[] indices = Model.indices;VertexAttribute vertexPosition = new VertexAttribute(Usage.Position, 3, "a_position");VertexAttribute texCoords = new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord0");mMesh = new Mesh(true, vertices.length / 5, indices.length, vertexPosition, texCoords);mMesh.setVertices(vertices);mMesh.setIndices(indices);}private void initTextures() {mTextures = new Texture[Model.texturePaths.length];for (int i = 0; i < mTextures.length; i++) {mTextures[i] = new Texture(Gdx.files.internal(Model.texturePaths[i]));}}private void transform() { // MVP矩阵变换mRotateAgree = (mRotateAgree + 2) % 360;mRotateAxis.x = mRotateAgree / 180f - 1;mRotateAxis.y = (float) Math.sin(mRotateAgree / 180f * Math.PI * 0.7f);mRotateAxis.z = (float) Math.cos(mRotateAgree / 180f * Math.PI * 0.5f);mModelMatrix.idt(); // 模型变换矩阵单位化mModelMatrix.rotate(mRotateAxis, mRotateAgree);Matrix4 mvpMatrix = mModelMatrix.mulLeft(mCamera.combined);mShaderProgram.setUniformMatrix("u_mvpTrans", mvpMatrix);}
}

        Model.java

package com.zhyan8.game;public class Model {private static float r = 1.0f;public static String[] texturePaths = new String[] {"textures/a1.png", "textures/a2.png", "textures/a3.png","textures/a4.png", "textures/a5.png", "textures/a6.png"};public static float[] vertices = new float[] {// 前面r, r, r, 0f, 0f, // 0-r, r, r, 1f, 0f, // 1-r, -r, r, 1f, 1f, // 2r, -r, r, 0f, 1f, // 3// 后面r, r, -r, 0f, 0f, // 4-r, r, -r, 1f, 0f, // 5-r, -r, -r, 1f, 1f, // 6r, -r, -r, 0f, 1f, // 7// 上面r, r, r, 0f, 0f, // 8r, r, -r, 1f, 0f, // 9-r, r, -r, 1f, 1f, // 10-r, r, r, 0f, 1f, // 11// 下面r, -r, r, 0f, 0f, // 12r, -r, -r, 1f, 0f, // 13-r, -r, -r, 1f, 1f, // 14-r, -r, r, 0f, 1f, // 15// 右面r, r, r, 0f, 0f, // 16r, r, -r, 1f, 0f, // 17r, -r, -r, 1f, 1f, // 18r, -r, r, 0f, 1f, // 19// 左面-r, r, r, 0f, 0f, // 20-r, r, -r, 1f, 0f, // 21-r, -r, -r, 1f, 1f, // 22-r, -r, r, 0f, 1f // 23};public static short[] indices = new short[] {0, 1, 2, 3, // 前面4, 5, 6, 7, // 上面8, 9, 10, 11, // 右面12, 13, 14, 15, // 后面16, 17, 18, 19, // 下面20, 21, 22, 23 // 左面};
}

        square_chartlet_vertex.glsl

#version 300 esin vec3 a_position;
in vec2 a_texCoord0;uniform mat4 u_mvpTrans; // MVP矩阵变换out vec2 v_texCoord0;void main() {gl_Position = u_mvpTrans * vec4(a_position, 1.0);v_texCoord0 = a_texCoord0;
}

        square_chartlet_fragment.glsl

#version 300 es
precision mediump float; // 声明float型变量的精度为mediumpin vec2 v_texCoord0;uniform sampler2D u_texture;out vec4 fragColor;void main() {fragColor = texture(u_texture, v_texCoord0);
}

        运行效果如下。

http://www.hkea.cn/news/660388/

相关文章:

  • 烟台网站建设联系企汇互联专业网站维护收费标准
  • 网络客户服务平台搜索优化推广公司
  • 建设网站技术方案线上教育培训机构十大排名
  • 沈阳人流seo优化师就业前景
  • 开发区网站制作公司seo关键词有话要多少钱
  • 网站被篡改处理app拉新平台
  • 在线房屋设计网站seo推广平台服务
  • 电子政务门户网站建设代码短链接生成网址
  • 崔各庄地区网站建设百度非企渠道开户
  • 怎么用自己的电脑做网站服务器产品推广平台排行榜
  • 中国做的比较好的电商网站有哪些哈市今日头条最新
  • 微信怎么做网站推广百度网站优化培训
  • 网站开发支持多个币种电子技术培训机构
  • 移动网站设计与制作怎么找关键词
  • 国内移动端网站做的最好的厦门人才网597人才网
  • 建网站收费吗aso关键词覆盖优化
  • 西安的网站设计与制作首页微信视频号怎么推广引流
  • 顺义公司建站多少钱pc端百度
  • wordpress收费资源下载关键词优化的策略
  • 广州做网站建设的公司网站公司
  • 做网络平台的网站有哪些广州网站维护
  • 网页 代码怎么做网站东莞市民最新疫情
  • 电子商务网站设计中影响客户体验的元素有搜索引擎有哪些种类
  • 网站建设难点优化关键词技巧
  • 免费行情网站链接百度知道合伙人官网
  • 餐饮公司网站建设的特点大数据智能营销
  • 济南快速排名刷关键词排名seo软件
  • 系统做网站的地方百度推广登录后台登录入口
  • 集约化网站建设情况广告公司网站制作
  • 网站制作发票字节跳动广告代理商加盟