unity植物树木模型
unity植物树木模型资源
1.模型效果图
内含大量树的模型,植物的模型大概上百种吧
第一个资源
第二个资源
我就截取一部分吧
有需要可以自取
https://download.csdn.net/download/qq_42603590/86406562
没有积分的可以私聊,没有及时回复的话请见谅最多半天哦,抱拳了
喜欢的点个赞,关注一下在走吧.谢谢
最后贴点摄像机移动的代码,添加树还能旋转一下看一看,不喜勿喷
注释可以不用管,直接挂到摄像头上面,在拖一个地板在地面就可以了
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
//using UnityEngine.PostProcessing;
using UnityEngine.UI;public class CameraMove : MonoBehaviour
{//旋转变量float rotateY;float initialY;float Camerdis;Vector3 rayPoint;float newDis;float oldDis;private Vector3 point;private int isforward;//标记摄像机的移动方向private float eulerAngles_x;private float eulerAngles_y;private float distancePoint;//绕点旋转距离// public Texture2D ZoomView, PanView, OrbitView, FPSView;//public Text PO;public float Xpos;public float Ypos;public Camera cam;public bool UIclipMove = false;//是否在ui上限制移动bool LookFps=false;//高度限制public float maxHigh = 4000;public float minHigh = 1; // 嫌弃摄像机太高了就调成合适的高度0 public float maxX = 13000;public float minX = -27000;public float maxZ = 25000;public float minZ = -35000;// Use this for initializationpublic GameObject escObj;//public GameObject LightOBJ;//private void Awake()//{// Screen.SetResolution(1920, 1080, false);//}void Start(){Camerdis = 1;rayPoint = cam.transform.forward * 800 + cam.transform.position;//ShowOrHideObj();cameraRot = transform.localRotation;}//void FixedUpdate()//{// //if (Input.GetKeyDown(KeyCode.Escape))// //{// // escObj.SetActive(true);// //}// if (EventSystem.current.IsPointerOverGameObject())// {// return;// }// //Camerdis = (float)Math.Round(cam.transform.position.y, 2);// if (Input.touchCount == 1)// {// if (Input.touches[0].phase == TouchPhase.Moved&& Camera.main.ScreenToViewportPoint(Input.touches[0].position).x>0.2f)// {// Translation(0.005f);// }// else if (Input.touches[0].phase == TouchPhase.Moved && Camera.main.ScreenToViewportPoint(Input.touches[0].position).x <0.2f)// {// float moveX = Input.GetAxis("Mouse X") * Camerdis * 0.002f;// Camera.main.transform.Translate(Vector3.forward * moveX);// }// }// if (Input.touchCount == 2)// {// 记录两个手指的位置// //Vector2 nposition1 = new Vector2();// //Vector2 nposition2 = new Vector2();// 记录手指的每帧移动距离// //Vector2 deltaDis1 = new Vector2();// //Vector2 deltaDis2 = new Vector2();// //if (Input.GetTouch(0).phase == TouchPhase.Moved && Input.GetTouch(1).phase == TouchPhase.Moved) //第二个手指// //{// // nposition1 = Input.GetTouch(0).position; //第一个手指屏幕坐标// // nposition2 = Input.GetTouch(1).position; //第二个手指屏幕坐标// // deltaDis1 = Input.GetTouch(0).deltaPosition;// // deltaDis2 = Input.GetTouch(1).deltaPosition;// // newDis = Vector3.Distance(nposition1, nposition2);// // if (newDis > oldDis)// // {// // isforward = 1;// // }// // else// // {// // isforward = -1;// // }// // //记录旧的触摸位置// // oldDis = newDis;// // //移动摄像机// // // Camera.main.transform.Translate(isforward * Vector3.forward * Time.deltaTime * (Mathf.Abs(deltaDis2.x + deltaDis1.x) + Mathf.Abs(deltaDis1.y + deltaDis2.y)) * Camerdis * 0.1f);// // Camera.main.transform.Translate(isforward * Vector3.forward * Time.deltaTime * Camerdis * 0.1f);// // PO.text = isforward.ToString();// //}// //else// //{// if (Input.touches[0].phase == TouchPhase.Moved)// { // RotatePoint();// } // }//}public void ExitQ(){Application.Quit();}//控制高度void ControlHigh(){float highY = transform.position.y;float highX = transform.position.x;float highZ = transform.position.z;highY = Mathf.Clamp(highY, minHigh, maxHigh);highX = Mathf.Clamp(highX, minX, maxX);highZ = Mathf.Clamp(highZ, minZ, maxZ);//transform.position = new Vector3(transform.position.x, highY, transform.position.z);transform.position = new Vector3(highX, highY, highZ);//AmbientOcclus();//控制AO}// Update is called once per framevoid Update(){//if (UIclipMove)//{//if (EventSystem.current.IsPointerOverGameObject())//{// return;//}//}//transform.LookAt(escObj.transform);//if (Gamemanager._instatic.isMove)//{// return;//}//if (Input.touchCount <= 0 && Camera.main.ScreenToViewportPoint(Input.mousePosition).x < Xpos && Camera.main.ScreenToViewportPoint(Input.mousePosition).y > Ypos)//{//if (EventSystem.current.IsPointerOverGameObject())//{// return;//}//if (Input.GetMouseButtonUp(1) || Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(2))光标重置//{// Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);//}if (Input.GetMouseButton(2))//按住左键平移{// Cursor.SetCursor(PanView, Vector2.zero, CursorMode.Auto);Translation(0.03f);ControlHigh();//ShowOrHideObj();}if (!EventSystem.current.IsPointerOverGameObject()){if (Input.GetAxis("Mouse ScrollWheel") < 0){RayPoint();transform.Translate(Vector3.back * Camerdis * 0.1f);ControlHigh();//ShowOrHideObj();}if (Input.GetAxis("Mouse ScrollWheel") > 0){RayPoint();transform.Translate(Vector3.forward * Camerdis * 0.1f);ControlHigh();//ShowOrHideObj();}}if (Input.GetMouseButtonDown(1)|| Input.GetMouseButtonDown(0)){eulerAngles_y = this.transform.eulerAngles.x;eulerAngles_x = this.transform.eulerAngles.y;RayPoint();ControlHigh();//ShowOrHideObj();distancePoint = Vector3.Distance(transform.position, rayPoint);}if (Input.GetMouseButton(1))//右键旋转{// Cursor.SetCursor(OrbitView, Vector2.zero, CursorMode.Auto);RotatePoint();ControlHigh();//ShowOrHideObj();}KeyTranslation();//}//if (Input.GetKeyDown(KeyCode.F10))//{// if (LookFps == false)// {// LookFps = true;// }// else// {// LookFps = false;// }//}//if (LookFps)//{// lookFPS();//}}void Translation(float sheep)//平移控制{float moveX = Input.GetAxis("Mouse X") ;float moveY = Input.GetAxis("Mouse Y") ;//自身坐标的z轴投影到世界坐标的z轴,用自身坐标的y轴和z轴的值乘 自身的相对欧拉角的x的三角函数。float tranY = moveY * (float)Math.Sin(Math.Round(this.transform.localRotation.eulerAngles.x, 2) * Math.PI / 180.0);float tranZ = moveY * (float)Math.Cos(Math.Round(this.transform.localRotation.eulerAngles.x, 2) * Math.PI / 180.0);transform.Translate(new Vector3(-moveX, -tranY, -tranZ) * Camerdis* sheep, Space.Self);}void Rotation()//旋转控制{initialY = this.transform.localRotation.eulerAngles.y;rotateY = 0;rotateY += Input.GetAxis("Mouse X") * 2f;var rotation = Quaternion.Euler(this.transform.localRotation.eulerAngles.x, rotateY + initialY, 0);transform.rotation = rotation;}void RayPoint()//射线得到碰撞点,针对绕点旋转{Ray ray = cam.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));//射线 // Ray ray = cam.ScreenPointToRay(Input.mousePosition);//射线 RaycastHit hit;if (Physics.Raycast(ray, out hit))//发射射线(射线,射线碰撞信息,射线长度,射线会检测的层级) {rayPoint = new Vector3(hit.point.x, hit.point.y, hit.point.z);Camerdis = (float)Math.Round(cam.transform.position.y- hit.point.y, 2)+10;}//else//{// rayPoint = transform.forward*0.005f + transform.position;//摄像机前方 800 点// //Camerdis = (float)Math.Round(cam.transform.position.y, 2) ;//}}float a = 0;public float XSensitivity = 2f;public float YSensitivity = 2f;//是否平滑public bool smooth;//平滑参数public float smoothTime = 5f;//相机private Quaternion cameraRot;Quaternion quaternion;void RotatePoint()//绕点旋转{eulerAngles_x += (Input.GetAxis("Mouse X")*2);eulerAngles_y -= (Input.GetAxis("Mouse Y")*2);eulerAngles_y = ClampAngle(eulerAngles_y, 3,89);quaternion = Quaternion.Euler(eulerAngles_y, eulerAngles_x, 0);Vector3 vector = quaternion * new Vector3(0, 0, -distancePoint) + rayPoint;transform.rotation = Quaternion.Slerp(transform.localRotation, quaternion, 20f * Time.deltaTime);if (Input.GetKey(KeyCode.LeftControl))//右键旋转{return;}transform.position = Vector3.Lerp(transform.position, vector, Time.deltaTime * 20f);//}void Euler()//当前物体的欧拉角{Vector3 eulerAngles = this.transform.eulerAngles;this.eulerAngles_x = eulerAngles.y;if (eulerAngles.x > 80){this.eulerAngles_y = 80;}else if (eulerAngles.x < 10){this.eulerAngles_y = 10;}else{this.eulerAngles_y = eulerAngles.x;}}//键盘控制void KeyTranslation()//平移控制{float moveX = Input.GetAxis("Horizontal") * Time.deltaTime * 6;float moveY = Input.GetAxis("Vertical") * Time.deltaTime * 6;if (moveX == 0 && moveY == 0){return;}//自身坐标的z轴投影到世界坐标的z轴,用自身坐标的y轴和z轴的值乘 自身的相对欧拉角的x的三角函数。float tranY = moveY * (float)Math.Sin(Math.Round(this.transform.localRotation.eulerAngles.x, 2) * Math.PI / 180.0);float tranZ = moveY * (float)Math.Cos(Math.Round(this.transform.localRotation.eulerAngles.x, 2) * Math.PI / 180.0);transform.Translate(new Vector3(moveX, tranY, tranZ) * Camerdis * 0.05f, Space.Self);}//角度限制private static float ClampAngle(float angle, float min, float max){if (angle < -360)angle += 360;if (angle > 360)angle -= 360;return Mathf.Clamp(angle, min, max);}}
unity植物树木模型相关推荐
- 三维植物树木模型 Maxtree – Plant Models Vol 74
maxtree–工厂模型第74卷 大小解压后:2.34G 信息: 植物模型第74卷是高质量的三维植物模型的集合.包括12个物种,共72个单一模式. 获取地址:三维植物树木模型 Maxtree – Pl ...
- unity 批量导入模型工具_零基础的Unity图形学笔记3:使用多模型UV与优化模型导出...
前文所说,贴图多UV,直接命名对应贴图就可以. 模型的多套UV,则需要在3DMAX里编辑. 这篇文章主要解决两个问题: 如何正确使用多模型UV? 从3DMAX导出,到shader使用 如何优化模型导出 ...
- unity 飞机 残骸模型_训练残骸模式– Java 8中的改进实现
unity 飞机 残骸模型 Venkat Subramaniam在今天的演讲中提到了有关"级联方法"模式或"火车残骸"模式的内容,如下所示: >someO ...
- unity相机围绕模型转_围绕我们的业务模型和风险进行安全测试
unity相机围绕模型转 When we create an environment and consider our security testing from development to pro ...
- Unity学习记录——模型与动画
Unity学习记录--模型与动画 前言 本文是中山大学软件工程学院2020级3d游戏编程与设计的作业7 编程题:智能巡逻兵 1.学习参考 除去老师在课堂上讲的内容,本次作业代码与操作主要参考了 ...
- Unity批量给模型上同一个材质
Unity批量给模型上同一个材质 第一步:先选择所有要上材质的模型: 第二步:将创建的材质拖到右侧属性栏:
- unity导入FBX模型时出现材质丢失,模型为白膜的情况
unity导入FBX模型时出现材质丢失,模型为白膜的情况 导入模型后点击该模型 修改属性即可:
- Unity Shader Lab 模型切线和法线
DCC和unreal中的法线与切线 (maya) 绿:法线, 红:切线, 蓝:副切线(ue4) uv channel 0 法线由DCC软件确定,一般使用两种:(该点为三根线的端点) 三根法线合一,为相 ...
- unity导出.obj模型文件
unity导出.obj模型文件 最近使用realworldterrain生成真实地形遇到一个问题,就是该地形的坐标轴没有在中心位置,这样在旋转缩放操作时候就有各种问题,效果不好,于是想到先导出该地形为 ...
最新文章
- Emai乱码——解决的“迂回”战术
- @select注解模糊查询_mybatis @SelectProvider 注解, 打赌你没有用过
- 计算机端口封闭,如何查询局域网内被封的电脑端口?
- LOL手游2.3版本终于来临,国服玩家满意新增的皮肤吗?
- js 字符转换,小驼峰转大写字母开头并且加空格 changeDate -》 Change Date
- 计算机本地连接怎么找不到了,网络,本地连接不见了解决办法
- 阿里云重磅发布RDS for SQL Server AlwaysOn集群版
- 设计思路工作笔记-使用当天时间戳的差值读取实时数据绕过错误数据
- CSRF verification failed. Request aborted.
- python异步教程_Python开发异步任务Celery的使用教程!
- YUV420及YUV422格式的采集存储方式
- 元数据管理在数据仓库的实践应用
- 前端使用阿里巴巴矢量图库的图标大全
- ES6 Symbol基本用法
- 如何计算离职率(2)?
- PSSP Based on Data Partition and Semi-Random Subspace Method 论文笔记
- 基于GNN网络的session推荐模型(知识图谱技术在推荐场景的应用)
- Vue packages version mismatch
- 搭建表白墙 公众号_韶大表白墙 第十季 第75期 | 篮球共青杯决赛体教1班穿黑色衣服的0号...
- 【AIOT】语音学习