public void UpdateBonds(CompleteOutputDescription latestCoDesc, IBond[] bonds) { if (scheme.HandlesBonds) { scheme.SetOutputDescription(coDesc); DataFields[][] allStreams = new DataFields[1][]; IGeometryCreator[] schStreams = scheme.GetBondStreams(); GeomDataBufferStream[] geomStream = new GeomDataBufferStream[schStreams.Length]; for (int i = 0; i < geomStream.Length; i++) { allStreams[0] = schStreams[i].Fields; GeomDataTransformer.CreateBufferStream(allStreams, out geomStream[i]); } // fill buffer stream scheme.SetBondData(bonds, geomStream); } }
public void UpdateAtoms(CompleteOutputDescription coDesc, IAtom[] atoms) { if (scheme.HandlesAtoms) { scheme.SetOutputDescription(coDesc); // pass throught scheme & effects IGeometryCreator[] schStreams = scheme.GetAtomStreams(); DataFields[][] allStreams = new DataFields[1][]; GeomDataBufferStream[] geomStream = new GeomDataBufferStream[schStreams.Length]; for (int i = 0; i < geomStream.Length; i++) { allStreams[0] = schStreams[i].Fields; GeomDataTransformer.CreateBufferStream(allStreams, out geomStream[i]); } // fill buffer stream scheme.SetAtomData(atoms, geomStream); } }
public static void CreateBufferStream(ICollection <DataFields[]> streams, out GeomDataBufferStream bufferStream) { bufferStream = new GeomDataBufferStream(); // create format order Dictionary <VertexFormats, int> fields = new Dictionary <VertexFormats, int>(); List <DataFields> dataFields = new List <DataFields>(); int index = 0; foreach (DataFields[] stream in streams) { foreach (DataFields field in stream) { if (!fields.ContainsKey(field.Format)) { dataFields.Add(field); fields.Add(field.Format, index++); } } } bufferStream.Fields = new VertexFormats[dataFields.Count]; bufferStream.FieldPositions = new int[dataFields.Count]; VertexFormats format = VertexFormats.None; int pos = 0; for (int i = 0; i < dataFields.Count; i++) { bufferStream.Fields[i] = dataFields[i].Format; format |= dataFields[i].Format; bufferStream.FieldPositions[i] = pos; pos += VertexFormatStride(dataFields[i].Format); } bufferStream.Stride = pos; bufferStream.Format = format; }
public static void CreateBufferStream(ICollection<DataFields[]> streams, out GeomDataBufferStream bufferStream) { bufferStream = new GeomDataBufferStream(); // create format order Dictionary<VertexFormats,int> fields = new Dictionary<VertexFormats,int>(); List<DataFields> dataFields = new List<DataFields>(); int index = 0; foreach (DataFields[] stream in streams) { foreach (DataFields field in stream) { if (!fields.ContainsKey(field.Format)) { dataFields.Add(field); fields.Add(field.Format, index++); } } } bufferStream.Fields = new VertexFormats[dataFields.Count]; bufferStream.FieldPositions = new int[dataFields.Count]; VertexFormats format = VertexFormats.None; int pos = 0; for (int i = 0; i < dataFields.Count; i++) { bufferStream.Fields[i] = dataFields[i].Format; format |= dataFields[i].Format; bufferStream.FieldPositions[i] = pos; pos += VertexFormatStride(dataFields[i].Format); } bufferStream.Stride = pos; bufferStream.Format = format; }
public override abstract void CreateGeometryForObjects(Device device, ICollection <IBond> objs, GeomDataBufferStream geomStream, int stream, ref BufferedGeometryData buffer, CompleteOutputDescription coDesc);
public void OnNewDataSource(IAtom[] atoms, IBond[] bonds, Vector3 origin, Bounds3D bounds) { sceneGraph = new OcTree<ChemEntity>((int)bounds.radius * 2, -bounds.min); /*screenEntities.Add(new BondAngle(device, atoms[0], atoms[1], atoms[2])); screenEntities[0].Init(device); postSceneWorldEntities.Add(new BoundingBoxEntity(new BoundingBox(bounds.min, bounds.max), false, Color.LightGray.ToArgb())); postSceneWorldEntities[0].Init(device); postSceneWorldEntities.Add(new SphereAxis3D()); postSceneWorldEntities[1].Init(device);*/ sceneGraphEntities = sceneGraph.SceneItems; // create molecule entities foreach (IAtom atom in atoms) { AtomEntity aentity = AtomEntity.BuildEntity(atom); sceneGraph.Insert(aentity); /*ScreenLabelVSpaceEntity entity = new ScreenLabelVSpaceEntity(atom.ID + ":" + aentity.UId.ToString(), (Vector3)aentity.Position3D); entity.Init(device); screenEntities.Add(entity);*/ /*AtomSymbolEntity entity = new AtomSymbolEntity(aentity); entity.Init(device); postSceneViewEntities.Add(entity);*/ } //foreach (IBond bond in bonds) //{ //sceneGraph.Insert(new BondE); //} scheme.SetOutputDescription(coDesc); scheme.SetupScene(origin, bounds.radius); // pass throught scheme & effects IGeometryCreator[] schStreams = scheme.GetAtomStreams(); DataFields[] efxFields = null; //effect.DesiredData(out efxFields, false); DataFields[][] allStreams = new DataFields[1 + (efxFields != null ? 1 : 0 )][]; //if (efxFields != null) // allStreams[1] = efxFields; if (scheme.HandlesAtoms && atoms != null) { GeomDataBufferStream[] geomStream = new GeomDataBufferStream[schStreams.Length]; for (int i = 0; i < geomStream.Length; i++) { allStreams[0] = schStreams[i].Fields; GeomDataTransformer.CreateBufferStream(allStreams, out geomStream[i]); } // fill buffer stream scheme.SetAtomData(atoms, geomStream); } schStreams = scheme.GetBondStreams(); if (scheme.HandlesBonds && bonds != null) { GeomDataBufferStream[] geomStream = new GeomDataBufferStream[schStreams.Length]; for (int i = 0; i < geomStream.Length; i++) { allStreams[0] = schStreams[i].Fields; GeomDataTransformer.CreateBufferStream(allStreams, out geomStream[i]); } // fill buffer stream scheme.SetBondData(bonds, geomStream); } }
public void OnNewDataSource(IAtom[] atoms, IBond[] bonds, Vector3 origin, Bounds3D bounds) { sceneGraph = new OcTree <ChemEntity>((int)bounds.radius * 2, -bounds.min); /*screenEntities.Add(new BondAngle(device, atoms[0], atoms[1], atoms[2])); * screenEntities[0].Init(device); * * postSceneWorldEntities.Add(new BoundingBoxEntity(new BoundingBox(bounds.min, bounds.max), false, Color.LightGray.ToArgb())); * postSceneWorldEntities[0].Init(device); * postSceneWorldEntities.Add(new SphereAxis3D()); * postSceneWorldEntities[1].Init(device);*/ sceneGraphEntities = sceneGraph.SceneItems; // create molecule entities foreach (IAtom atom in atoms) { AtomEntity aentity = AtomEntity.BuildEntity(atom); sceneGraph.Insert(aentity); /*ScreenLabelVSpaceEntity entity = new ScreenLabelVSpaceEntity(atom.ID + ":" + aentity.UId.ToString(), (Vector3)aentity.Position3D); * entity.Init(device); * screenEntities.Add(entity);*/ /*AtomSymbolEntity entity = new AtomSymbolEntity(aentity); * entity.Init(device); * postSceneViewEntities.Add(entity);*/ } //foreach (IBond bond in bonds) //{ //sceneGraph.Insert(new BondE); //} scheme.SetOutputDescription(coDesc); scheme.SetupScene(origin, bounds.radius); // pass throught scheme & effects IGeometryCreator[] schStreams = scheme.GetAtomStreams(); DataFields[] efxFields = null; //effect.DesiredData(out efxFields, false); DataFields[][] allStreams = new DataFields[1 + (efxFields != null ? 1 : 0)][]; //if (efxFields != null) // allStreams[1] = efxFields; if (scheme.HandlesAtoms && atoms != null) { GeomDataBufferStream[] geomStream = new GeomDataBufferStream[schStreams.Length]; for (int i = 0; i < geomStream.Length; i++) { allStreams[0] = schStreams[i].Fields; GeomDataTransformer.CreateBufferStream(allStreams, out geomStream[i]); } // fill buffer stream scheme.SetAtomData(atoms, geomStream); } schStreams = scheme.GetBondStreams(); if (scheme.HandlesBonds && bonds != null) { GeomDataBufferStream[] geomStream = new GeomDataBufferStream[schStreams.Length]; for (int i = 0; i < geomStream.Length; i++) { allStreams[0] = schStreams[i].Fields; GeomDataTransformer.CreateBufferStream(allStreams, out geomStream[i]); } // fill buffer stream scheme.SetBondData(bonds, geomStream); } }