如何使用GL库在unity3d游戏编程中unity 绘制网格形状

GL 图像库_unity3d游戏脚本制作教程-游戏蛮牛出品
Unity 脚本手册
Low-level graphics library.
底层的图像库。
Use this class to manipulate active transformation matrices,
issue rendering commands similar to OpenGL's immediate mode and do other low-level
graphics tasks. Note that in almost all cases using
is more efficient than
using immediate mode drawing.
这个类进行底层的矩阵变换。通过用函数命令来实现。这和OpenGL(和D3D不同的图形库)的立即模式一样。注意在大部分情况下用[转载]unity3D调用GL任意画线
为什么画不上?
此文是对某位大神文章的翻译,忘记从哪摘抄的了 原文使用js写的
我把它改成C#。此文存在一个问题,当屏幕上有texture的话,貌似texture上画不上。期待高手一块解决。另外当快速拖动鼠标时,发现画的曲线不够平滑,正在尝试用贝塞尔解决,期待高手一块探讨。
using UnityE
using System.C
public class joint{
& public Vector3
& public Vector3
public class example : MonoBehaviour {
Event e& ; &
&&& private
Vector3 orgP &
&&& private
Vector3 endP &
&& &private bool
canDrawLines& = &
&& &ArrayList
&& &ArrayList
&Material lineM
&temppos=new ArrayList();
&posAL=new& ArrayList();
&if(Input.GetMouseButton(0))
& canDrawLines = &
&if(e.type!=null &canDrawLines)
if(e.type == EventType.MouseDown) &
&&&&&&&&&&&&
orgPos=Input.mouseP &
&&&&&&&&&&&&
endPos=Input.mouseP &
&&&&&&&&&&&&&
if(e.type==EventType.MouseDrag) &
&&&&&&&&&&&&
endPos=Input.mouseP &
&temppos.Add(Input.mousePosition);
x1=(((Vector3)temppos[0])-((Vector3)temppos[3]));
&&&&&&&&&&&&
GLDrawLine(orgPos,endPos); &
&&&&&&&&&&&&
orgPos=Input.mouseP &
&print(temppos.Count);
if(e.type==EventType.MouseUp) &
&&&&&&&&&&&
// orgPos=Input.mouseP &
&&&&&&&&&&&&
endPos=Input.mouseP &
GLDrawLine(Vector3 beg ,Vector3 end ) &
//print("GLDrawLine???"); &
if(!canDrawLines) &
GL.PushMatrix (); &
&&& GL.LoadOrtho
beg.x=beg.x/Screen. &
end.x=end.x/Screen. &
beg.y=beg.y/Screen. &
end.y=end.y/Screen. &
joint tmpJoint = new joint(); &
tmpJoint.org= &
tmpJoint.end= &
posAL.Add(tmpJoint); &
lineMaterial.SetPass( 0 ); &
&&& GL.Begin(
GL.LINES ); &
&&& GL.Color(
new Color(1,1,1,0.5f) ); &
&&& for(int i=
0;i&posAL.Ci++) &
joint tj& =(joint)posAL[i];
Vector3 tmpBeg& = tj. &
Vector3 tmpEnd=tj. &
GL.Vertex3( tmpBeg.x,tmpBeg.y,tmpBeg.z ); &
GL.Vertex3( tmpEnd.x,tmpEnd.y,tmpEnd.z ); &
&&& GL.End();
&&& //print("beg
is:"+beg+"end is:"+end); &
&&& GL.PopMatrix
//Debug.DrawLine(beg,end); &
&& &void OnGUI()
if(GUI.Button(new& Rect(150,0,100,50),"End
Lines")) &
ClearLines(); &
ClearLines() &
&&& canDrawLines
posAL.Clear(); &
OnPostRender() { &
GLDrawLine(orgPos,endPos); &
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。产考资料:/Documentation/TriangulationByEarClipping.pdf预览图:整体效果预览:插件菜单栏:mesh编辑:插件脚本预览:插件下载地址unity 4.6 导出的包。如果版本太低。导入不了。可以回复下。链接:/s/1jGGKJ4M 密码:8pwl原文地址/808.html核心脚本[C#] 纯文本查看复制代码?001002003004005006007008009010011012013014015016017018019020021022023024025026027028029030031032033034035036037038039040041042043044045046047048049050051052053054055056057058059060061<div class="line number62 index61 alt1" style=" word-wrap: break- border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: rgb(108, 226, 108) ! bottom: auto ! float: none ! height: auto ! left: auto ! line-height: 1.1em ! margin: 0px ! outline: 0px ! ov
Unity3D教程手册(unitymanual)
 文章为作者独立观点,不代表大不六文章网立场
unitymanual游戏蛮牛 ---
中国最大的手机游戏开发者技术社区! 热门文章最新文章unitymanual游戏蛮牛 ---
中国最大的手机游戏开发者技术社区! &&&&违法和不良信息举报电话:183-
举报邮箱:Copyright(C)2017 大不六文章网}

我要回帖

更多关于 unity 绘制曲线 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信