public override void PreRender() { UpdateGeometry(); // figuring out a decent line width is tricky. Want to be responsive to camera // pos, so line doesn't get super-thick when zoomed in. So we want to measure // screen-space radius. But off-screen vertices are a problem. So, only consider // vertices within a level, pointing-forward view cone (can't be actual view cone // because then line thickness changes as you turn head!). // // Also sub-sample verts for efficiency. Probably we don't need to do this // every frame...but how to distribute? if (EnableLineRenderer) { float fNewWidth = VRUtil.EstimateStableCurveWidth(GetScene(), GetLocalFrame(CoordSpace.SceneCoords), curve, SceneGraphConfig.DefaultSceneCurveVisualDegrees); if (fNewWidth > 0) { visibleWidth = fNewWidth; LineRenderer r = root.GetComponent <LineRenderer>(); r.startWidth = r.endWidth = visibleWidth; } } }
void update_geometry(FScene s) { if (bUpdatePending == false && curve_timestamp == curve.Timestamp) { return; } if (curve.VertexCount < 2) { return; } update_vertices(s); int N = (curve.Closed) ? curve.VertexCount + 1 : curve.VertexCount; Vector3f[] vertices = new Vector3f[N]; for (int i = 0; i < N; ++i) { vertices[i] = (Vector3f)curve[i % curve.VertexCount]; } curveObject.SetVertices(vertices); float fWidth = VRUtil.EstimateStableCurveWidth(s, Frame3f.Identity, curve, SceneGraphConfig.DefaultSceneCurveVisualDegrees); if (fWidth > 0) { curveObject.SetLineWidth(fWidth); } bUpdatePending = false; curve_timestamp = curve.Timestamp; }
void update_geometry(FScene s) { if (bUpdatePending == false && curve_timestamp == curve.Timestamp) { return; } if (curve.VertexCount < 2) { return; } update_vertices(s); verticesf.Clear(); buffer.Clear(); for (int i = 0; i < curve.VertexCount; ++i) { buffer.Add(curve[i % curve.VertexCount]); } if (CurveProcessorF != null) { CurveProcessorF(buffer); } int Nmod = buffer.Count; int N = (curve.Closed) ? buffer.Count + 1 : buffer.Count; for (int i = 0; i < N; ++i) { verticesf.Add((Vector3f)buffer[i % Nmod]); } curveObject.SetVertices(verticesf); float fWidth = VRUtil.EstimateStableCurveWidth(s, Frame3f.Identity, curve, SceneGraphConfig.DefaultSceneCurveVisualDegrees); if (fWidth > 0) { curveObject.SetLineWidth(fWidth); } bUpdatePending = false; curve_timestamp = curve.Timestamp; }