public override Object Clone() { SpringStyle res = new SpringStyle(); res.Width = Width; res.Spring = Spring; return(res); }
private void DrawSprings(DxRenderContext renderContext, Cell cell, SimParams parameters, float normalizer) { SlimDX.Direct3D11.Device device = DeviceContext.Device; DxMesh tube = parameters.GetValue(SimParameter.Int.Spring_Type) == 0 ? Meshes.GetMesh("rod") : Meshes.GetMesh("spring"); SetMesh(device, tube); var prevMode = DeviceContext.Device.ImmediateContext.InputAssembler.PrimitiveTopology; PrimitiveTopology[] modes = { PrimitiveTopology.LineList, PrimitiveTopology.TriangleList }; for (int j = 0; j < modes.Length; j++) { DeviceContext.Device.ImmediateContext.InputAssembler.PrimitiveTopology = modes[j]; foreach (ChromosomePair pair in cell.ChromosomePairs) { Spring spring = pair.Spring; if (spring != null) { SpringStyle springStyle = renderContext.StyleAspect.Resolve <SpringStyle>(spring); ConstBuffer.Material = springStyle.Spring; float scale = (float)spring.Length * normalizer; Matrix transform = Matrix.Scaling((float)springStyle.Width, (float)springStyle.Width, scale); transform *= RotationVectors(new Vector3(0, 0, -1), new Vector3((float)(spring.RightJoint.X - spring.LeftJoint.X), (float)(spring.RightJoint.Y - spring.LeftJoint.Y), (float)(spring.RightJoint.Z - spring.LeftJoint.Z))); transform *= Matrix.Translation((float)spring.LeftJoint.X * normalizer, (float)spring.LeftJoint.Y * normalizer, (float)spring.LeftJoint.Z * normalizer); ConstBuffer.World = Matrix.Transpose(transform); SetBuffer(device, ConstBuffer); DrawMesh(device, tube); } } } DeviceContext.Device.ImmediateContext.InputAssembler.PrimitiveTopology = prevMode; }
public StyleCollection() { List <StyleObject> _allStyles = new List <StyleObject>(); AllStyles = _allStyles; Poles = new PoleStyle(); _allStyles.Add(Poles); Tubes = new TubeStyle(); _allStyles.Add(Tubes); Chromosomes = new ChromosomeStyle(); _allStyles.Add(Chromosomes); Springs = new SpringStyle(); _allStyles.Add(Springs); Cell = new CellStyle(); _allStyles.Add(Cell); }