Android OpenGLES 360全景图片渲染(球体内部)

在这里插入图片描述

概述

    360度全景图是一种虚拟现实技术,它通过对现实场景进行多角度拍摄后,利用计算机软件将这些照片拼接成一个完整的全景图像。这种技术能够让观看者在虚拟环境中以交互的方式查看整个周围环境,就好像他们真的站在那个位置一样。在Android设备上查看360度全景图片,可以使用一些专门的app, 不如Google相册, Google 街景, 第三方的全景图片查看应用。这些应用程序能够识别并以交互方式展示360度全景图像,让用户可以旋转、缩放和平移来探索整个场景。
    360全景图片渲染可以使用openGLES来轻松实现.

实现

在这里插入图片描述
在这里插入图片描述

使用OpenGL 创建一个球体, 并将图片纹理按一定的规则贴到球体的内部. 如上图, 可以考虑将图片等比例铺满球面展开的面积即可, 方法有很多, 可以按经度, 也可以按维度, 不同顺序对结果没影响.

参考代码:

主界面

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import com.android.apitester.SphereView;public class SphereViewer extends Activity {SphereView sphereView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);Bitmap bm = BitmapFactory.decodeFile("/sdcard/sphere.jpg");sphereView = new SphereView(this);sphereView.setBitmap(bm);setContentView(sphereView);}
}

自定义GLSurfaceView

import android.content.Context;
import android.graphics.Bitmap;
import android.hardware.SensorManager;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.opengl.GLUtils;
import android.opengl.Matrix;
import android.os.SystemClock;
import android.view.MotionEvent;
import android.view.View;import com.ansondroider.acore.Logger;
import com.ansondroider.acore.opengl.EGLHelper;import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;public class SphereView  extends GLSurfaceView implements GLSurfaceView.Renderer {final String TAG = "SphereView";private String vertextShaderSource = "attribute vec4 aPosition;" +"precision mediump float;" +"uniform mat4 uMatrix;" +"attribute vec2 aCoordinate;" +"varying vec2 vCoordinate;" +"attribute float alpha;" +"varying float inAlpha;" +"void main(){" +"	gl_Position = uMatrix*aPosition;\n" +//"	gl_Position = aPosition;" +" 	gl_PointSize = 10.0;" +"	vCoordinate = aCoordinate;" +"	inAlpha = alpha;" +"}";private String fragmentShaderSource = "#extension GL_OES_EGL_image_external : require\n" +"precision mediump float;" +"varying vec2 vCoordinate;" +"varying float inAlpha;" +//"uniform samplerExternalOES uTexture;" +"uniform sampler2D uTexture;" +"uniform bool isPoint;" +"void main() {" +"	vec4 color = texture2D(uTexture, vCoordinate);" +"	if(isPoint){" +" 	   gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);" +"	}else{" +"		gl_FragColor = vec4(color.r, color.g, color.b, inAlpha);" +"	}" +"}";//纹理IDprivate int mTextureId = -1;// 定义OpenGL 程序IDprivate int mProgram = -1;//矩阵变换接受者(shader中)private int mVertexMatrixHandler = -1;//顶点坐标接收者private int mVertexPosHandler = -1;//纹理坐标接受者private int mTexturePosHandler = -1;//纹理接受者private int mTextureHandler = -1;//半透明值接受者private int mAlphaHandler = -1;private int mPointHandler = -1;//矩阵private float[] mMatrix = new float[16];private float[] projectionMatrix = new float[16];//透明度private float mAlpha = 1f;public SphereView(Context context) {super(context);//A        #16 pc 000000000000d348  [anon:dalvik-classes2.dex extracted in memory from /data/app/~~Kkld4fhSS0RUjHOLDPgB7w==/com.ansondroider.apitester-9-2nRYL85FvddCKlwbFEFw==/base.apk!classes2.dex] (com.ansondroider.apitester.sphere.SphereView.createGLPrg+36)//A        #18 pc 000000000000d74a  [anon:dalvik-classes2.dex extracted in memory from /data/app/~~Kkld4fhSS0RUjHOLDPgB7w==/com.ansondroider.apitester-9-2nRYL85FvddCKlwbFEFw==/base.apk!classes2.dex] (com.ansondroider.apitester.sphere.SphereView.onDrawFrame+138)setEGLContextClientVersion(2);setRenderer(this);setOnTouchListener(new OnTouchListener() {@Overridepublic boolean onTouch(View v, MotionEvent event) {updateRotate(event);return true;}});}//if touching, stop sensor rotate.boolean touching;float dx, dy;float angStartX, angStartY;float angelTouchX, angelTouchY;public void updateRotate(MotionEvent e){if(e.getAction() == MotionEvent.ACTION_DOWN){touching = true;dx = e.getX();dy = e.getY();//float[] rot = {0, 0, 0};//provider.getAngle(rot);angStartX = angelTouchY;//rot[0];angStartY = angelTouchX;//rot[1];}else if(e.getAction() == MotionEvent.ACTION_MOVE){angelTouchY = angStartX + 180f * (e.getX() - dx) / getWidth();angelTouchX = angStartY + 180f * (e.getY() - dy) / getHeight();}else{touching = false;}}Bitmap tmpBm = null;boolean rebindTexture = false;public void setBitmap(Bitmap bm){//check mTextureId is -1, save bm to tmpBm;if(bm == null || bm.isRecycled())return;else tmpBm = bm;if(mTextureId >= 0){rebindTexture = true;}}float ratio = 1;//float frustumSize 	= 2.5f;float[] NEAR_FAR 	= {1.7f,	0.5f, 	20f, 	17f};float[] EYE_Z 		= {-0.06f, 	-3f, 	3};float[] SCALE 		= {5f, 		0.5f, 	10};float[] FRUSTUM 	= {1, 		1, 		3};float[] RADIUS 		= {2.5f, 	2, 		3};/*** 初始化矩阵变换,主要是防止视频拉伸变形*/private void initDefMatrix() {//Log.d(TAG, "initDefMatrix");//设置相机位置float[] viewMatrix = new float[16];Matrix.setLookAtM(viewMatrix, 0,0f, 0f, EYE_Z[0],0f, 0f, 0,0f, 1.0f, 0f);float[] rotSensor = new float[16];Matrix.setIdentityM(rotSensor, 0);float[] rotTouch = new float[16];Matrix.setIdentityM(rotTouch, 0);Matrix.rotateM(rotTouch, 0, -angelTouchX, 1, 0, 0);float rotY = -angelTouchY + (vtSphere != null ? vtSphere.getStartRotateY() : 0);Matrix.rotateM(rotTouch, 0, rotY, 0, 1, 0);Matrix.multiplyMM(viewMatrix, 0, rotSensor, 0, rotTouch, 0);// 参数解释://result: 存储乘法结果的矩阵数组。//resultOffset: 存储结果矩阵的数组起始偏移量。//lhs: 左操作数矩阵(left-hand side)的数组。//lhsOffset: 左操作数矩阵的数组起始偏移量。//rhs: 右操作数矩阵(right-hand side)的数组。//rhsOffset: 右操作数矩阵的数组起始偏移量。//Matrix.multiplyMM(mMatrix, 0, projectionMatrix, 0, viewMatrix, 0);Matrix.multiplyMM(mMatrix, 0, projectionMatrix, 0, viewMatrix, 0);Matrix.scaleM(mMatrix, 0, SCALE[0], SCALE[0], SCALE[0]);}@Overridepublic void setAlpha(float alpha) {super.setAlpha(alpha);mAlpha = alpha;}/*** 创建并使用opengles程序*/private void createGLPrg() {//Logger.d(TAG, "createGLPrg");if (mProgram == -1) {int vertexShader = EGLHelper.compileVertexShader(vertextShaderSource);int fragmentShader = EGLHelper.compileFragmentShader(fragmentShaderSource);//创建programe陈谷mProgram = GLES20.glCreateProgram();//将顶点着色器加入程序GLES20.glAttachShader(mProgram, vertexShader);//将片元着色器加入程序GLES20.glAttachShader(mProgram, fragmentShader);GLES20.glLinkProgram(mProgram);//从程序中获取句柄mVertexMatrixHandler = GLES20.glGetUniformLocation(mProgram, "uMatrix");mVertexPosHandler = GLES20.glGetAttribLocation(mProgram, "aPosition");mTextureHandler = GLES20.glGetUniformLocation(mProgram, "uTexture");mTexturePosHandler = GLES20.glGetAttribLocation(mProgram, "aCoordinate");mAlphaHandler = GLES20.glGetAttribLocation(mProgram, "alpha");mPointHandler = GLES20.glGetUniformLocation(mProgram, "isPoint");}//使用opengl程序if (mProgram != -1) GLES20.glUseProgram(mProgram);}@Overrideprotected void onDetachedFromWindow() {Logger.d(TAG, "onDetachedFromWindow");super.onDetachedFromWindow();GLES20.glDisableVertexAttribArray(mVertexPosHandler);GLES20.glDisableVertexAttribArray(mTexturePosHandler);GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);GLES20.glDeleteTextures(1, new int[]{mTextureId}, 0);GLES20.glDeleteProgram(mProgram);}@Overridepublic void onSurfaceCreated(GL10 gl, EGLConfig config) {Logger.d(TAG, "onSurfaceCreated");}@Overridepublic void onSurfaceChanged(GL10 gl, int width, int height) {Logger.d(TAG, "onSurfaceChanged");GLES20.glViewport(0, 0, width, height);ratio = (float) width / height;//m: 存储结果矩阵的数组。//offset: 存储结果矩阵的数组起始偏移量。//left	: 近平面左边界的 X 坐标值。//right	: 近平面右边界的 X 坐标值。//bottom: 近平面下边界的 Y 坐标值。//top	: 近平面上边界的 Y 坐标值。//near	: 近平面的 Z 坐标值(必须为正数)。//far	: 远平面的 Z 坐标值(必须为正数)。Matrix.frustumM(projectionMatrix, 0,-ratio*FRUSTUM[0], ratio*FRUSTUM[0],-FRUSTUM[0], FRUSTUM[0],NEAR_FAR[0], NEAR_FAR[3]);}void prepareTexture(){if((mTextureId < 0 || rebindTexture) && tmpBm != null){Logger.d(TAG, "setBitmap bind bitmap to texture " + mTextureId);if(mTextureId >= 0) {//check texture is bind, unbind.GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);GLES20.glDeleteTextures(1, new int[]{mTextureId}, 0);}//create texture and bind bitmap to itint[] textures = new int[1];GLES20.glGenTextures(1, textures, 0);mTextureId = textures[0];rebindTexture = false;//mTextureId is not -1, then bind Bitmap to mTextureId// 将 Bitmap 加载到纹理GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureId);// 设置纹理参数GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, tmpBm, 0);tmpBm.recycle(); // 释放 Bitmap 资源}}@Overridepublic void onDrawFrame(GL10 gl) {//Logger.d(TAG, "onDrawFrame");GLES20.glClearColor(bgRGBA[0], bgRGBA[1], bgRGBA[2], bgRGBA[3]);long ct = SystemClock.uptimeMillis();if(ct - last_fps > 1000) {last_fps = ct;fps = 0;}fps ++;prepareTexture();//drawBitmap_initBuffer();//清除颜色缓冲和深度缓冲GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);///GLES20.glEnable(GLES20.GL_DEPTH_TEST);if (mTextureId != -1) {initDefMatrix();//2/创建、编译、启动opengles着色器createGLPrg();//3.激活并绑定纹理单元///activateTexture();//5.开始绘制渲染doDraw();}}float[] bgRGBA = {0, 0, 0, 1};int fps = 0;long last_fps = SystemClock.uptimeMillis();/*** 开始绘制渲染*/SphereTexture vtSphere;public void doDraw() {//Logger.d(TAG, "doDraw");if(mMatrix == null)return;if(vtSphere == null){vtSphere = new SphereTexture(RADIUS[0], 32, 32,false);}// 绑定纹理GLES20.glActiveTexture(GLES20.GL_TEXTURE0);GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureId);GLES20.glUniform1i(mTextureHandler, 0);GLES20.glUniformMatrix4fv(mVertexMatrixHandler, 1, false, mMatrix, 0);GLES20.glVertexAttrib1f(mAlphaHandler, mAlpha);GLES20.glUniform1i(mPointHandler, vtSphere.isPoint() ? 1 : 0);vtSphere.draw(mVertexPosHandler, mTexturePosHandler);}}//Class SphereView end

球面顶点和纹理坐标的生成与渲染

import android.graphics.RectF;
import android.opengl.GLES20;
import android.opengl.Matrix;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;public class SphereTexture extends VertexTexture{private float mRadius;private int mLat, mLong;private boolean mIs180;private float[] degreeLongitude;private float[] degreeLatitude;public SphereTexture(float radius, int latitudeBands, int longitudeBands,boolean is180) {mRadius = radius;mLat = latitudeBands;mLong = longitudeBands;mIs180 = is180;init();}@Overridepublic float getStartRotateY() {return 0;//mIs180 ? 180f: -90f;}@Overrideprotected void initVertexTextureCoordinate(){if(degreeLongitude == null) {degreeLongitude = new float[]{-_PI, 	_PI, 	_PI * 2};degreeLatitude 	= new float[]{-0, 		_PI, 	_PI};}mVertexCoors = new float[(mLat + 1) * (mLong + 1) * 3];mTextureCoors = new float[(mLat + 1) * (mLong + 1) * 2];mIndices = new short[mLat * mLong * 6];int vIndex = 0;int tIndex = 0;int iIndex = 0;for (int lat = 0; lat <= mLat; lat++) {float theta = degreeLatitude[0] +  (float) lat / mLat * degreeLatitude[2];float sinTheta = (float) Math.sin(theta);float cosTheta = (float) Math.cos(theta);for (int lon = 0; lon <= mLong; lon++) {float phi = degreeLongitude[0] + (float) lon / mLong * degreeLongitude[2];//float phi =  (float) lon / longitudeBands * 2 * (MAX_DEGREE_X);float sinPhi = (float) Math.sin(phi);float cosPhi = (float) Math.cos(phi);float x = cosPhi * sinTheta;float y = cosTheta;float z = sinPhi * sinTheta;mVertexCoors[vIndex] = mRadius * x;mVertexCoors[vIndex + 1] = mRadius * y;mVertexCoors[vIndex + 2] = mRadius * z;// 生成纹理坐标float u = (float) lon / mLong;float v = (float) lat / mLat;// 生成纹理坐标/*mTextureCoors[tIndex] = u;//xmTextureCoors[tIndex + 1] = v;//y*/RectF r = getTextureArea();mTextureCoors[tIndex] = r.left + r.width() * u;//xmTextureCoors[tIndex + 1] = r.top + r.height() * v;//yif (lat < mLat && lon < mLong) {int first = lat * (mLong + 1) + lon;int second = first + mLong + 1;mIndices[iIndex++] = (short) first;mIndices[iIndex++] = (short) second;mIndices[iIndex++] = (short) (first + 1);mIndices[iIndex++] = (short) second;mIndices[iIndex++] = (short) (second + 1);mIndices[iIndex++] = (short) (first + 1);/*first		first + 1		...|----------|-------------||		   |			 ||		   |			 |second|----------|-------------||       second + 1       ||          |             ||          |             ||----------|-------------|*/}vIndex += 3;tIndex += 2;}}}@Overridepublic void updateZ(float z) {super.updateZ(z);mRadius = z;initVertexTextureCoordinate();}@Overridepublic void draw(int mVertexPosHandler, int mTexturePosHandler) {// 绑定顶点缓冲区GLES20.glEnableVertexAttribArray(mVertexPosHandler);mVertexBuffer.position(0);GLES20.glVertexAttribPointer(mVertexPosHandler, 3, GLES20.GL_FLOAT, false, 0, mVertexBuffer);// 绑定纹理坐标缓冲区GLES20.glEnableVertexAttribArray(mTexturePosHandler);mTextureBuffer.position(0);GLES20.glVertexAttribPointer(mTexturePosHandler, 2, GLES20.GL_FLOAT, false, 0, mTextureBuffer);// 绑定纹理//if(textureId > -1)GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);// 绘制球体if(!isPoint()) {GLES20.glDrawElements(GLES20.GL_TRIANGLES, getIndexCount(),GLES20.GL_UNSIGNED_SHORT, mIndexBuffer);}elseGLES20.glDrawArrays(GLES20.GL_POINTS, 0, getVertexCount());GLES20.glDisableVertexAttribArray(mVertexPosHandler);GLES20.glDisableVertexAttribArray(mTexturePosHandler);}}

最终效果:
在这里插入图片描述

参考

  1. Android OpenGLES3绘图:球形视频播放器
  2. Android 使用 OpenGL ES 绘制球面

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/74123.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

代码随想录算法训练营第三十二天 | 509.斐波那契数 70.爬楼梯 746.使用最小花费爬楼梯

509. 斐波那契数 题目链接&#xff1a;509. 斐波那契数 - 力扣&#xff08;LeetCode&#xff09; 文章讲解&#xff1a;代码随想录 视频讲解&#xff1a;手把手带你入门动态规划 | LeetCode&#xff1a;509.斐波那契数_哔哩哔哩_bilibili 思路&#xff1a;输入&#xff1a;…

拼多多 anti-token unidbg 分析

声明: 本文章中所有内容仅供学习交流使用&#xff0c;不用于其他任何目的&#xff0c;抓包内容、敏感网址、数据接口等均已做脱敏处理&#xff0c;严禁用于商业用途和非法用途&#xff0c;否则由此产生的一切后果均与作者无关&#xff01; 逆向分析 版本7.3-7.4 都试过加密没什…

【工具】BioPred一个用于精准医疗中生物标志物分析的 R 软件包

介绍 R 语言包 BioPred 提供了一系列用于精准医疗中的亚组分析和生物标志物分析的工具。它借助极端梯度提升&#xff08;XGBoost&#xff09;算法&#xff0c;并结合倾向得分加权和 A 学习方法&#xff0c;帮助优化个体化治疗规则&#xff0c;从而简化亚组识别过程。BioPred 还…

横扫SQL面试——时间序列分组与合并(会话划分)问题

横扫SQL面试题 &#x1f4cc; 时间序列分组与合并问题 &#x1f4da; 横扫SQL面试——时间序列分组与合并解析 &#x1f31f; 核心问题类型 时间序列分组&#xff08;Sessionization&#xff09; 处理具有时间维度的连续数据流&#xff0c;根据特定规则&#xff08;如时间间隔…

PCB钻孔之多边形孔分析

问题分析 在钻孔过程中&#xff0c;钻头的运动可以分为两部分&#xff1a; 公转&#xff1a;钻头的轴线绕理想轴线&#xff08;钻孔中心线&#xff09;做圆周运动。自转&#xff1a;钻头绕自身轴线做旋转运动。 由于公转和自转的叠加&#xff0c;钻尖的运动轨迹会形成复杂的…

Android源码之App启动

目录 App启动概述 App启动过程 App启动过程图 源码概述 跨进程启动 进程内启动 下面以应用桌面Launcher启动App的MainActivity来举例&#xff1a; App启动概述 首先&#xff0c;MainActivity是由Launcher组件来启动的&#xff0c;而Launcher又是通过Activity管理服务Act…

指纹浏览器技术解析:如何实现多账号安全运营与隐私保护

浏览器指纹的挑战与需求 在数字化运营场景中&#xff0c;浏览器指纹技术被广泛用于追踪用户行为。通过采集设备硬件参数&#xff08;如屏幕分辨率、操作系统&#xff09;、软件配置&#xff08;如字体、插件&#xff09;及网络特征&#xff08;如IP地址、时区&#xff09;&…

生活电子常识——cmd不能使用anaconda的python环境,导致输入python打开应用商店

前言 电脑已经安装了anaconda,从自带的Anaconda Prompt (Anaconda3)中是可以识别python环境的&#xff0c;然而切换到cmd时&#xff0c;突然发现cmd中无法识别anaconda的python环境&#xff0c;竟然打开了应用商店让我安装Python&#xff0c;这当然是不对的。 解决 这是因为…

搭建前端环境和后端环境

搭建前端环境 ①、安装vscode&#xff0c;并安装相应的插件工具 ②、安装node.js&#xff0c;可以选择当前版本&#xff0c;或者其他版本 ③、创建工作区 创建一个空文件夹&#xff0c;然后通过vscode工具打开&#xff0c;保存为后缀名为.code-workspace ④、从gitee…

Java基础知识总结(1.8)——Java 注解(持续更新)

更新时间&#xff1a;2025-03-31 Web后端专栏&#xff1a;CSDN专栏——理论-Web后端技术博客总目录&#xff1a;计算机技术系列博客——目录页 8.1 注解的概念 8.1.1 定义与作用 Java注解&#xff08;Annotation&#xff09;是Java语言自JDK1.5版本引入的核心特性&#xff0…

线程概念与控制(下)

线程概念与控制&#xff08;中&#xff09;https://blog.csdn.net/Small_entreprene/article/details/146539064?sharetypeblogdetail&sharerId146539064&sharereferPC&sharesourceSmall_entreprene&sharefrommp_from_link对于之前学习的内容&#xff0c;我们…

SQL注入之盲注技术详解

SQL注入之盲注技术详解 一、盲注基本概念盲注特点&#xff1a; 二、盲注主要类型1. 布尔盲注判断依据&#xff1a; 2. 时间盲注判断依据&#xff1a; 三、布尔盲注详细技术1. 识别布尔盲注2. 数据提取技术(1) 判断数据库类型(2) 获取数据库名长度(3) 逐字符获取数据库名(4) 获取…

OpenCV 图形API(3)高层次设计概览

操作系统&#xff1a;ubuntu22.04 OpenCV版本&#xff1a;OpenCV4.9 IDE:Visual Studio Code 编程语言&#xff1a;C11 描述 G-API 是一个异构框架&#xff0c;提供了统一的 API 来使用多个支持的后端编程图像处理流水线。 关键的设计理念是在指定使用哪些内核和设备时保持流…

阿里云Tair KVCache:打造以缓存为中心的大模型Token超级工厂

一、Tair KVCache 简介 Tair KVCache 是阿里云瑶池旗下云数据库 Tair 面向大语言模型推理场景推出的 KVCache 缓存加速服务。 随着互联网技术的演进与流量规模的激增&#xff0c;缓存技术逐渐成为系统架构的核心组件。该阶段催生了 Redis 等开源缓存数据库&#xff0c;阿里巴巴…

Open GL ES ->GLSurfaceView正交投影与透视投影方法中近远平面取值参考

坐标系 OpenGL ES使用右手坐标系&#xff0c;相机默认朝向负z方向 相机位置|vz轴<----- 0 -----> -near -----> -far -----不可见 可见区域 不可见裁剪规则 只有z值在[-near, -far]范围内的物体可见&#xff0c; 当z > -near&#xff08;在近平面前&#…

iOS自定义collection view的page size(width/height)分页效果

前言 想必大家工作中或多或少会遇到下图样式的UI需求吧 像这种cell长度不固定&#xff0c;并且还能实现的分页效果UI还是很常见的 实现 我们这里实现主要采用collection view&#xff0c;实现的方式是自定义一个UICollectionViewFlowLayout的子类&#xff0c;在这个类里对…

Java高频面试之并发编程-01

hello啊&#xff0c;各位观众姥爷们&#xff01;&#xff01;&#xff01;本baby今天来报道了&#xff01;哈哈哈哈哈嗝&#x1f436; 面试官&#xff1a;并行跟并发有什么区别&#xff1f; 并发 vs 并行&#xff1a;核心区别与场景 1. 定义对比 维度并发&#xff08;Concu…

从零开始学Rust:所有权(Ownership)机制精要

文章目录 第四章&#xff1a;Ownership 所有权核心概念关键机制引用与借用&#xff08;Reference & Borrowing&#xff09;悬垂引用问题错误示例分析解决方案引用安全规则 切片&#xff08;Slice&#xff09;内存安全保证 第四章&#xff1a;Ownership 所有权 Ownership i…

一旦懂得,有趣得紧1:词根tempt-(尝试)的两种解法

词根tempt-尝试 tempt vt.引诱&#xff1b;诱惑&#xff1b;怂恿&#xff1b;利诱&#xff1b;劝诱&#xff1b;鼓动 temptation n.引诱&#xff1b;诱惑 // tempt v.引诱 -ation 名词后缀 attempt v.&n.尝试&#xff0c;试图 // at- 加强 tempt 尝试contempt n.蔑视&am…

召唤数学精灵

1.召唤数学精灵 - 蓝桥云课 问题描述 数学家们发现了两种用于召唤强大的数学精灵的仪式&#xff0c;这两种仪式分别被称为累加法仪式 A(n) 和累乘法仪式 B(n)。 累加法仪式 A(n) 是将从1到 n 的所有数字进行累加求和&#xff0c;即&#xff1a; A(n)12⋯n 累乘法仪式 B(n) …