- Home /
How to overlap a model with it's wireframe properly
I am currently trying to have an overlay of a selected model's wireframe over the actual model itself. It needs to be done in scripting , because later I need to have the ability to color line segments in the model. I have been trying to use GL to get it to work. Currently all I can do is draw lines on the window. What I need is for the line to be projected into the world space. This is my current code, and as you can see I was fiddling with some other bits in an attempt to get it projected. (very simple as I am just trying to get the concept down)
using UnityEngine;
using System.Collections;
public class nodeDisplay : MonoBehaviour {
public Material mat;
public GameObject curObj;
void Update() {
}
void OnPostRender() {
GL.PushMatrix();
mat.SetPass(0);
//GL.LoadOrtho();
GL.LoadIdentity();
GL.Begin(GL.LINES);
//GL.modelview = Matrix4x4.TRS(curObj.transform.position, curObj.transform.rotation, curObj.transform.lossyScale);
GL.Color(Color.red);
GL.Vertex(new Vector3(0, 1, 0));
GL.Vertex(new Vector3(1, 0, 0));
GL.End();
GL.PopMatrix();
}
}
I have also tried to use GL.wireframe with camera layers, but that simply cannot do what I need it to later with vertex highlighting. I have also looked at this post: [url]http://forum.unity3d.com/threads/8814-Wireframe-3D[/url] which just left me thinking there should be an better way as the code provided (that fits with my code needs) tends to leave out edges: [url]http://forum.unity3d.com/threads/8814-Wireframe-3D?p=64326&viewfull=1#post64326[/url] . Thanks to any help that you can give.