Mesh系列文章 - 自定义Mesh
就是在做项目的过程中,有用到三角形的,今天就写一下如何自定义三角形?
先截个图,让大家有个感性认识!
//引用
using UnityEngine;
using System.Collections;
public class Draw : MonoBehaviour
{
//三个物体的变换
public Transform a1;
public Transform a2;
public Transform a3;
void Awake()
{
//添加Mesh Filter(模型网格)和Mesh Renderer(模型渲染)组件
gameObject.AddComponent<MeshFilter>();
gameObject.AddComponent<MeshRenderer>();
//对模型的材质赋值个颜色
gameObject.renderer.material.color=Color.green;
//获取模型网格
Mesh mesh = GetComponent<MeshFilter>().mesh;
//清楚模型的顶点和三角形索引
mesh.Clear();
//变换三个物体的坐标到代码所挂物体上的局部坐标!
Vector3 v1 = gameObject.transform.InverseTransformPoint(a1.position);
Vector3 v2 = gameObject.transform.InverseTransformPoint(a2.position);
Vector3 v3 = gameObject.transform.InverseTransformPoint(a3.position);
//然后赋值顶点
mesh.vertices = new Vector3[] { v1, v2, v3 };
//赋值三角形的索引
mesh.triangles = new int[] { 0, 1, 2 };
}
}
Mesh系列文章 - 自定义Mesh的更多相关文章
- 解密蓝牙mesh系列
解密蓝牙mesh系列 https://mp.weixin.qq.com/s/KdVhkgcmHIboA0xPFqFCgQ 1.NRF52832 & NRF52840 BLE mesh 协议栈 ...
- 【Flutter 实战】17篇动画系列文章带你走进自定义动画
老孟导读:Flutter 动画系列文章分为三部分:基础原理和核心概念.系统动画组件.8篇自定义动画案例,共17篇. 动画核心概念 在开发App的过程中,自定义动画必不可少,Flutter 中想要自定义 ...
- 系列文章:云原生Kubernetes日志落地方案
在Logging这块做了几年,最近1年来越来越多的同学来咨询如何为Kubernetes构建一个日志系统或者是来求助在这过程中遇到一系列问题如何解决,授人以鱼不如授人以渔,于是想把我们这些年积累的经验以 ...
- EF和MVC系列文章导航:EF Code First、DbContext、MVC
对于之前一直使用webForm服务器控件.手写ado.net操作数据库的同学,突然来了EF和MVC,好多新概念泉涌而出,的确犹如当头一棒不知所措.本系列文章可以帮助新手入门并熟练使用EF和MVC,有了 ...
- WPF自定义控件与样式(15)-终结篇 & 系列文章索引 & 源码共享
系列文章目录 WPF自定义控件与样式(1)-矢量字体图标(iconfont) WPF自定义控件与样式(2)-自定义按钮FButton WPF自定义控件与样式(3)-TextBox & Ric ...
- 不可或缺 Windows Native 系列文章索引
[源码下载] 不可或缺 Windows Native 系列文章索引 作者:webabcd 1.不可或缺 Windows Native (1) - C 语言: hello c 介绍不可或缺 Window ...
- Gradle学习系列之五——自定义Property
在本系列的上篇文章中,我们讲到了增量式构建,在本篇文章中,我们将讲到如何自定义Project的Property. 请通过以下方式下载本系列文章的Github示例代码: git clone https: ...
- 重新想象 Windows 8 Store Apps 系列文章索引
[源码下载][重新想象 Windows 8.1 Store Apps 系列文章] 重新想象 Windows 8 Store Apps 系列文章索引 作者:webabcd 1.重新想象 Windows ...
- 重新想象 Windows 8.1 Store Apps 系列文章索引
[源码下载] [重新想象 Windows 8 Store Apps 系列文章] 重新想象 Windows 8.1 Store Apps 系列文章索引 作者:webabcd 1.重新想象 Windows ...
随机推荐
- OpenGL Vertex Array
转载 http://blog.csdn.net/dreamcs/article/details/7699603
- 对于(function(){}())和function(){}实例的作用域分析(里面有很多问题……)
今天在群里看到一个问题,让我纠结了好一会.下面是我的分析,感觉里面还有很多问题,关于作用域还是不太理解,希望大家看到问题第一时间反馈给我,看到实在受不了的地方说几句都没关系,谢谢. 请看题: 1.对象 ...
- poj 3026 bfs+prim Borg Maze
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9718 Accepted: 3263 Description The B ...
- android设置图片自适应控件大小
在XML文件的ImageView属性中加上:android:scaleType="fitXY"
- 查看daemon使用技巧
una ~ # ps -ef|egrep "*d$"或"[a-z]d" //查看现有的服务器上都有哪些服务器进程.root 3509 ...
- VirtualBox共享文件夹等高级特性
转自: http://blog.csdn.net/longerzone/article/details/32119457 http://www.oschina.net/translate/10-vir ...
- Shortest Word Distance
Given a list of words and two words word1 and word2, return the shortest distance between these two ...
- RTX登录其他系统
前台: <html> <head> <title>签名验证</title> <meta http-equiv="Content-Lang ...
- xml 解析 java 基础复习
document 解析 sax 解析 dom4j 解析(摘自csdn redarmychen) dom4j是一个Java的XML API,类似于jdom,用来读写XML文件的.dom4j是一个非常 ...
- iOS 中的Push Notifications简单实现(APNS)
Android中的通知只有一种,就是Local Notifications,而iOS中除了Local Notifications外,还有一种Push Notifications.ios的这2种noti ...