This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void InitMarchingCubesAlgorithm() | |
{ | |
// We need to calculate a list of the poly counts for each configuration of 'solid' and 'air' vertices. | |
// There are eight vertices, each one representing a bit of a byte. | |
// Look-up array for polygon count value that indicates how many (up to 5) polygons we need to create. | |
var pc = new byte[256]; | |
// Look-up array for polygon edge connections, indicating which edges we need to connect together. | |
var ec = new EdgeConnections[256]; | |
// Vertex neighbors. Each vertex of a cube has three neighbor vertices. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
* Managed3D: A 3D Graphics API for .NET and Mono - http://gearedstudios.com/ * | |
* Copyright © 2009-2012 William 'cathode' Shelley. All Rights Reserved. * | |
* This software is released under the terms and conditions of the MIT/X11 * | |
* license. See the 'license.txt' file for details. * | |
*****************************************************************************/ | |
using System; | |
using System.Runtime.InteropServices; | |
using System.Diagnostics.Contracts; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Managed3D.Geometry; | |
using System.Diagnostics.Contracts; | |
using Managed3D.SceneGraph; | |
namespace Managed3D.Rendering.Software | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void InitMarchingCubesAlgorithmFancier() | |
{ | |
// Even fancier. We'll use a LINQ query to build the lookup tables for Marching Cubes. | |
var result = from i in Enumerable.Range(0, 256) | |
let f = new Func<int, int>(s => (i & (1 << s)) >> s) | |
let verts = from j in Enumerable.Range(0, 8) | |
select f(j) | |
select verts; // not complete yet | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void CheckUsage(object owner, string operationId) | |
{ | |
// New code | |
Contract.Requires<InvalidOperationException>(owner == this.owner, "End was called on a different object than Begin"); | |
Contract.Requires<InvalidOperationException>(null != this.operationId, "End was called multiple times for this operation."); | |
Contract.Requires<InvalidOperationException>(operationId == this.operationId, "End operation type was different than Begin."); | |
// Old code | |
if (!object.ReferenceEquals(owner, this.owner)) | |
throw new InvalidOperationException("End was called on a different object than Begin"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Frame GetFrame(long index) | |
{ | |
IAsyncResult result = this.BeginGetFrame(null, index); | |
var frame = this.EndGetFrame(result); | |
return frame; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Initializes a new instance of the <see cref="FilterInputFrames"/> class. | |
/// </summary> | |
/// <param name="owner">The filter that is rendering a frame to which the input frames will be used.</param> | |
/// <param name="currentIndex">The frame index being rendered.</param> | |
public FilterInputFrames(Filter owner, long currentIndex) | |
{ | |
Contract.Requires(owner != null); | |
Contract.Requires(currentIndex >= 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public unsafe void WriteToBitmap(System.Drawing.Bitmap bitmap) | |
{ | |
Contract.Requires(bitmap != null); | |
var bmpData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); | |
unchecked | |
{ | |
int* ptr = (int*)bmpData.Scan0.ToPointer(); | |
fixed (Vector4f* cptr = &(this.Pixels[0])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Gets the position on the current polygon at which the specified edge intersects it. | |
/// </summary> | |
/// <param name="line"></param> | |
/// <returns></returns> | |
public Vector3 GetIntersection(Edge3 line) | |
{ | |
// Set up vector variables; | |
Vector3 a, b, c, p, q; | |
a = this.A.ToVector3(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TGABitstreamHeader header; | |
header.IdLength = buffer.ReadByte(); | |
header.ColorMapType = (TGAColorMapType)buffer.ReadByte(); | |
header.ImageType = (TGAImageType)buffer.ReadByte(); | |
header.ColorMapOrigin = buffer.ReadUInt16(); | |
header.ColorMapLength = buffer.ReadUInt16(); | |
header.ColorMapDepth = buffer.ReadByte(); | |
header.XOrigin = buffer.ReadUInt16(); | |
header.YOrigin = buffer.ReadUInt16(); | |
header.Width = buffer.ReadUInt16(); |
OlderNewer