private void renderedControl1_Rendered(object sender, RenderEventArgs e) { int tickCount = Environment.TickCount; float deltaTime = (tickCount - _previousTickCount) / 1000f; _previousTickCount = tickCount; _simulator.Update(deltaTime); _framesCount++; int secondsCount = (tickCount - _startTickCount) / 1000; if (secondsCount != 0) { label.Text = String.Format("FPS: {0}", _framesCount / secondsCount); } //draw scene var render = e.Render; render.BeginScene(); render.Draw(() => { _simulator.ActorsFactory.AcceptVisit(_renderingVisitor); }, Lights.Point(new Vector3(0, 5, -6), new Vector3(1, 1, 1)), Cameras.LookAt(new Vector3(0, 15, -30), new Vector3(0, 0, 0), new Vector3(0, 1, 0)), Cameras.Perspective(render.GetAspectRatio()), Buffers.Clear(0.2f, 0.2f, 0.4f, 1), Buffers.ClearDepth(), Shaders.Phong ); render.EndScene(); renderedControl1.Invalidate(); }
private void clearData() { Machines = 0; ProcessesAmount = 0; Processes.Clear(); Buffers.Clear(); Inputs.Clear(); PreparedTransitions.Clear(); }
private void renderedControl1_Rendered(object sender, RenderEventArgs e) { //update simulation int tickCount = Environment.TickCount; float deltaTime = (tickCount - _previousTickCount) / 1000f; _previousTickCount = tickCount; _simulator.Update(deltaTime); _framesCount++; int secondsCount = (tickCount - _startTickCount) / 1000; if (secondsCount != 0) { label.Text = String.Format("FPS: {0}", _framesCount / secondsCount); } //add forces //foreach (IRigidBody forceRigidBody in _forceBodies) //{ // forceRigidBody.Forces.AddForce(1000 * Vectors.ZAxis); //} //draw scene var render = e.Render; render.BeginScene(); render.Draw(() => { foreach (IRigidBody rigidBody in _simulator.ActorsFactory.Elements) { if (rigidBody.FixtureFactory.Element is ISimpleFixture) { var simpleFixture = (ISimpleFixture)rigidBody.FixtureFactory.Element; DrawSimpleFixture(simpleFixture, render, rigidBody); } else { throw new NotImplementedException(); } } }, Lights.Point(new Vector3(0, 5, -6), new Vector3(1, 1, 1)), Cameras.LookAt(new Vector3(0, 15, -30), new Vector3(0, 0, 0), new Vector3(0, 1, 0)), Cameras.Perspective(render.GetAspectRatio()), Buffers.Clear(0.2f, 0.2f, 0.4f, 1), Buffers.ClearDepth(), Shaders.Phong ); render.EndScene(); renderedControl1.Invalidate(); }
//データのバイナリ読み込み public void Read(BinaryReader reader) { Buffers.Clear(); int count = reader.ReadInt32(); for (int i = 0; i < count; ++i) { Buffers.Add(reader.ReadString(), reader.ReadBuffer()); } }
private void gd_DeviceReset(object sender, EventArgs e) { Invalidated = true; Buffers.Clear(); for (var i = 0; i < 3; i++) { Buffers.Add( RenderUtils.CreateRenderTarget(base.GraphicsDevice, 1, SurfaceFormat.Color, base.GraphicsDevice.Viewport.Width, base.GraphicsDevice.Viewport.Height) ); } Invalidated = false; }
private void gd_DeviceReset(object sender, EventArgs e) { Invalidated = true; Buffers.Clear(); for (var i = 0; i < 3; i++) { Buffers.Add( PPXDepthEngine.CreateRenderTarget(base.GraphicsDevice, 1, 0, SurfaceFormat.Color, Width, Height, DepthFormat.None) ); } Invalidated = false; }
private void DrawScene(RenderEventArgs e) { var render = e.Render; render.Draw(() => { DrawScene(render); }, Lights.Point(new Vector3(0, 5, -6), new Vector3(1, 1, 1)), Cameras.LookAt(new Vector3(0, 15, -30), new Vector3(0, 0, 0), new Vector3(0, 1, 0)), Cameras.Perspective(render.GetAspectRatio()), Buffers.Clear(0.2f, 0.2f, 0.4f, 1), Buffers.ClearDepth(), Shaders.Phong ); }
public void GenBuffers(int bwidth, int bheight) { foreach (var buffer in Buffers) { buffer.Dispose(); } Buffers.Clear(); ResetMatrices(bwidth, bheight); ScreenWidth = bwidth; ScreenHeight = bheight; for (var i = 0; i < NumBuffers; i++) { int width = bwidth + ScrollBuffer; int height = bheight + ScrollBuffer; switch (i) { case 2: //World2D.BUFFER_OBJID width = 1; height = 1; break; case 3: //World2D.BUFFER_THUMB case 4: width = 1024; height = 1024; break; case 5: width = 576; height = 576; break; } if (NumBuffers == 2) { width = height = 1024; //special case, thumb only. } var depthformat = FSOEnvironment.SoftwareDepth ? DepthFormat.Depth24Stencil8 : DepthFormat.Depth24; //stencil is used for software depth Buffers.Add( PPXDepthEngine.CreateRenderTarget(Device, 1, 0, SurfaceFormats[i], width, height, (AlwaysDS[i] || (!FSOEnvironment.UseMRT && !FSOEnvironment.SoftwareDepth)) ? depthformat : DepthFormat.None) ); } }
public static void Clear() { lock (lck) { if (Buffers == null) { return; } foreach (SourceBuffer buffer in Buffers.Values.ToArray()) { buffer.Dispose(); } Buffers.Clear(); } }
public override void CleanUp() { foreach (var material in Materials) { material.CleanUp(); } Materials.Clear(); foreach (var kvp in Buffers) { kvp.Value.CleanUp(); } Buffers.Clear(); GL.DeleteVertexArray(vao); }
//データを書き込み public void MakeBuffer(List <T> ioList) { Buffers.Clear(); ioList.ForEach( x => { if (Buffers.ContainsKey(x.SaveKey)) { Debug.LogError(string.Format("Save data Key [{0}] is already exsits. Please use another key.", x.SaveKey)); } else { Profiler.BeginSample("MakeBuffer : " + x.SaveKey); byte[] buffer = BinaryUtil.BinaryWrite(x.OnWrite); Buffers.Add(x.SaveKey, buffer); Profiler.EndSample(); } } ); }
private void DrawScene(RenderEventArgs e) { var render = e.Render; render.Draw(() => { foreach (RigidBody rigidBody in _simulation.RigidBodies) { render.Draw((IModel)rigidBody.UserData, new Transforming(rigidBody.Pose.ToStandard()), Materials.DeepPink.Glossy.Shinness.Glossy.Shinness); } }, Lights.Point(new Vector3(0, 5, -6), new Vector3(1, 1, 1)), Cameras.LookAt(new Vector3(0, 15, -30), new Vector3(0, 0, 0), new Vector3(0, 1, 0)), Cameras.Perspective(render.GetAspectRatio()), Buffers.Clear(0.2f, 0.2f, 0.4f, 1), Buffers.ClearDepth(), Shaders.Phong ); }
public void ResizeBuffer(int width, int height) { _Width = width; _Height = height; var numBuffers = AllBuffers.Count; foreach (var buf in AllBuffers) { buf.Dispose(); } Buffers.Clear(); AllBuffers.Clear(); for (var i = 0; i < numBuffers; i++) { Buffers.Add( PPXDepthEngine.CreateRenderTarget(base.GraphicsDevice, 1, 0, SurfaceFormat.Color, Width, Height, DepthFormat.None) ); } AllBuffers = new List <RenderTarget2D>(Buffers); }
// Call Create method public bool CreateObjects() { // Create acquisition object if (Acquisition != null && !Acquisition.Initialized) { if (Acquisition.Create() == false) { DestroyObjects(); return(false); } } // Create buffer object if (Buffers != null && !Buffers.Initialized) { if (Buffers.Create() == false) { DestroyObjects(); return(false); } Buffers.Clear(); } // Create Xfer object if (Xfer != null && !Xfer.Initialized) { if (Xfer.Create() == false) { DestroyObjects(); return(false); } } return(true); }
/// <summary> /// Runs once at end of export. Serializes the gltf /// properties and wites out the *.gltf and *.bin files. /// </summary> public void Finish() { Debug.WriteLine("Finishing..."); // TODO: [RM] Standardize what non glTF spec elements will go into // this "BIM glTF superset" and write a spec for it. Gridlines below // are an example. // Add gridlines as gltf nodes in the format: // Origin {Vec3<double>}, Direction {Vec3<double>}, Length {double} FilteredElementCollector col = new FilteredElementCollector(_doc) .OfClass(typeof(Grid)); var grids = col.ToElements(); foreach (Grid g in grids) { Line l = g.Curve as Line; var origin = l.Origin; var direction = l.Direction; var length = l.Length; var xtras = new glTFExtras(); var grid = new GridParameters(); grid.origin = new List <double>() { origin.X, origin.Y, origin.Z }; grid.direction = new List <double>() { direction.X, direction.Y, direction.Z }; grid.length = length; xtras.GridParameters = grid; xtras.UniqueId = g.UniqueId; xtras.parameters = Util.GetElementParameters(g, true); var gridNode = new glTFNode(); gridNode.name = g.Name; gridNode.extras = xtras; Nodes.AddOrUpdateCurrent(g.UniqueId, gridNode); rootNode.children.Add(Nodes.CurrentIndex); } if (_singleBinary) { int bytePosition = 0; int currentBuffer = 0; foreach (var view in BufferViews) { if (view.buffer == 0) { bytePosition += view.byteLength; continue; } if (view.buffer != currentBuffer) { view.buffer = 0; view.byteOffset = bytePosition; bytePosition += view.byteLength; } } glTFBuffer buffer = new glTFBuffer(); buffer.uri = "monobuffer.bin"; buffer.byteLength = bytePosition; Buffers.Clear(); Buffers.Add(buffer); using (FileStream f = File.Create(_directory + "monobuffer.bin")) { using (BinaryWriter writer = new BinaryWriter(f)) { foreach (var bin in binaryFileData) { foreach (var coord in bin.vertexBuffer) { writer.Write((float)coord); } //foreach (var normal in bin.normalBuffer) //{ // writer.Write((float)normal); //} foreach (var index in bin.indexBuffer) { writer.Write((int)index); } foreach (var batchId in bin.batchIdBuffer) { writer.Write((float)batchId); } } } } } // Package the properties into a serializable container glTF model = new glTF(); model.asset = new glTFVersion(); model.scenes = Scenes; model.nodes = Nodes.List; model.meshes = Meshes.List; model.materials = Materials.List; model.buffers = Buffers; model.bufferViews = BufferViews; model.accessors = Accessors; // Write the *.gltf file string serializedModel = JsonConvert.SerializeObject(model, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); File.WriteAllText(_filename, serializedModel); if (!_singleBinary) { // Write the *.bin files foreach (var bin in binaryFileData) { using (FileStream f = File.Create(_directory + bin.name)) { using (BinaryWriter writer = new BinaryWriter(f)) { foreach (var coord in bin.vertexBuffer) { writer.Write((float)coord); } //foreach (var normal in bin.normalBuffer) //{ // writer.Write((float)normal); //} foreach (var index in bin.indexBuffer) { writer.Write((int)index); } foreach (var batchId in bin.batchIdBuffer) { writer.Write((float)batchId); } } } } } }
public Action BuffClear() { return(act(() => Buffers.Clear())); }
public Action BuffClear() { return(new Action(() => Buffers.Clear())); }
public void Reset() { Buffers.Clear(); reachLast = false; }