public override void BeforeGraph(Support.NativeList <LinePosition> lines) { Step = 0; Segment = 0; }
public override void BeforeGraph(Support.NativeList <GeometryLinePosition> lines) { Step = 0; }
public virtual void BeforeGraph(Support.NativeList <GeometryLinePosition> lines) { Step = 0; }
public virtual float GetSegment(Support.NativeList <GeometryLinePosition> lines) { return(Segement); }
public virtual float GetInterval(Support.NativeList <GeometryLinePosition> lines) { return(Interval); }
public void BuildGraph(Support.NativeList <LinePosition> position, Support.NativeList <LineUV> uv, float halfWidth) { BeforeGraph(position); LineUV rectUV = new LineUV(); rectUV.SetUV(); Vector3 cur, tar; bool drawing = true; float remainLength = GetSegment(position); bool isContinued = false; do { var normal = GetNormalDir(); NextStartPoint(out cur); isContinued = NextEndPoint(out tar); //NextStartPoint(out tar); float dist = Vector3.Distance(ref cur, ref tar); var dir = tar - cur; dir.Normalize(); Vector3 extDir = Vector3.Cross(dir, normal); extDir.Normalize(); while (dist >= remainLength) { if (drawing) { var end = cur + dir * remainLength; var l = new LinePosition(); l.SetLine(ref cur, ref end, ref extDir, halfWidth); //position.Add(l); //uv.Add(rectUV); unsafe { position.Add(l); uv.Add(rectUV); } drawing = false; dist -= remainLength; remainLength = GetInterval(position); cur = end; } else { drawing = true; dist -= remainLength; cur = cur + dir * remainLength; remainLength = GetSegment(position); extDir = Vector3.Cross(dir, normal); extDir.Normalize(); } } if (drawing) { var end = cur + dir * dist; var l = new LinePosition(); l.SetLine(ref cur, ref end, ref extDir, halfWidth); remainLength = remainLength - dist; //position.Add(l); //uv.Add(rectUV); unsafe { position.Add(l); uv.Add(rectUV); } dist = 0; } else { remainLength = remainLength - dist; dist = 0; } } while (isContinued); }
public void AddDefaultColorBuff(CRenderContext rc, CGfxMeshPrimitives result) { if (result == null) { return; } var mesh = result.GeometryMesh; if (mesh == null) { return; } CVertexBuffer colorbuff = mesh.GetVertexBuffer(EVertexSteamType.VST_Color); if (colorbuff != null) { return; } CVertexBuffer posbuff = mesh.GetVertexBuffer(EVertexSteamType.VST_Position); if (posbuff == null) { return; } var blob = new Support.CBlobObject(); posbuff.GetBufferData(rc, blob); int vertNum = 0; unsafe { vertNum = (int)blob.Size / sizeof(Vector3); } if (vertNum == 0) { return; } Support.NativeList <Byte4> Colors = new Support.NativeList <Byte4>(); var color = new Byte4(); color.X = 255; color.Y = 255; color.Z = 255; color.W = 255; for (int i = 0; i < vertNum; i++) { Colors.Add(color); } var dpDesc = new CDrawPrimitiveDesc(); dpDesc.SetDefault(); dpDesc.NumPrimitives = (UInt32)vertNum; result.SetAtom(0, 0, ref dpDesc); UInt32 resourceSize = 0; unsafe { var vbDesc = new CVertexBufferDesc(); vbDesc.CPUAccess = (UInt32)ECpuAccess.CAS_WRITE; { vbDesc.InitData = Colors.UnsafeAddressAt(0); vbDesc.Stride = (UInt32)sizeof(Byte4); vbDesc.ByteWidth = (UInt32)(sizeof(Byte4) * Colors.Count); var vb = rc.CreateVertexBuffer(vbDesc); mesh.BindVertexBuffer(EVertexSteamType.VST_Color, vb); resourceSize += vbDesc.ByteWidth; } result.ResourceState.ResourceSize = (UInt32)(resourceSize); mesh.Dirty = true; } result.ResourceState.StreamState = EStreamingState.SS_Valid; result.ResourceState.KeepValid = true; }