本文整理汇总了C#中Cylinder类的典型用法代码示例。如果您正苦于以下问题:C# Cylinder类的具体用法?C# Cylinder怎么用?C# Cylinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cylinder类属于命名空间,在下文中一共展示了Cylinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CharacterController
/// <summary>
/// Constructs a new character controller with the default configuration.
/// </summary>
public CharacterController()
{
Body = new Cylinder(Vector3.Zero, 3.0f, 1.2f, 10);
Body.IgnoreShapeChanges = true; //Wouldn't want inertia tensor recomputations to occur when crouching and such.
Body.CollisionInformation.Shape.CollisionMargin = .1f;
//Making the character a continuous object prevents it from flying through walls which would be pretty jarring from a player's perspective.
Body.PositionUpdateMode = PositionUpdateMode.Continuous;
Body.LocalInertiaTensorInverse = new Matrix3X3();
//TODO: In v0.16.2, compound bodies would override the material properties that get set in the CreatingPair event handler.
//In a future version where this is changed, change this to conceptually minimally required CreatingPair.
Body.CollisionInformation.Events.DetectingInitialCollision += RemoveFriction;
Body.LinearDamping = 0;
SupportFinder = new SupportFinder(this);
HorizontalMotionConstraint = new HorizontalMotionConstraint(this);
VerticalMotionConstraint = new VerticalMotionConstraint(this);
StepManager = new StepManager(this);
StanceManager = new StanceManager(this);
QueryManager = new QueryManager(this);
//Enable multithreading for the sphere characters.
//See the bottom of the Update method for more information about using multithreading with this character.
IsUpdatedSequentially = false;
PhysicsManager.Space.Add(this);
}
示例2: ExecuteFigureCreationCommand
public override void ExecuteFigureCreationCommand(string[] splitFigString)
{
switch (splitFigString[0])
{
case "circle":
{
Vector3D center = Vector3D.Parse(splitFigString[1]);
double radius = double.Parse(splitFigString[2]);
currentFigure = new Circle(center, radius);
break;
}
case "cylinder":
{
Vector3D bottom = Vector3D.Parse(splitFigString[1]);
Vector3D top = Vector3D.Parse(splitFigString[2]);
double radius = double.Parse(splitFigString[3]);
currentFigure = new Cylinder(bottom, top, radius);
break;
}
}
base.ExecuteFigureCreationCommand(splitFigString);
}
示例3: RayCastTestDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public RayCastTestDemo(DemosGame game)
: base(game)
{
Space.Add(new Box(new Vector3(0, -0.5f, 0), 50, 1, 50));
//Put whatever you'd like to ray cast here.
var capsule = new Capsule(new Vector3(0, 1.2f, 0), 1, 0.6f);
capsule.AngularVelocity = new Vector3(1, 1, 1);
Space.Add(capsule);
var cylinder = new Cylinder(new Vector3(0, 5, 0), 2, .5f);
cylinder.AngularVelocity = new Vector3(1, -1, 1);
Space.Add(cylinder);
var points = new List<Vector3>();
var random = new Random(0);
for (int k = 0; k < 40; k++)
{
points.Add(new Vector3(1 * (float)random.NextDouble(), 3 * (float)random.NextDouble(), 2 * (float)random.NextDouble()));
}
var convexHull = new ConvexHull(new Vector3(0, 10, 0), points);
convexHull.AngularVelocity = new Vector3(-1, 1, 1);
Space.Add(convexHull);
game.Camera.Position = new Vector3(-10, 5, 10);
game.Camera.Yaw((float)Math.PI / -4f);
game.Camera.Pitch(-(float)Math.PI / 9f);
//Starter ray.
origin = new Vector3(10, 5, 0);
direction = new Vector3(-3, -1, 0);
}
示例4: ParseQuery
public static void ParseQuery(string path)
{
using (var file = new StreamReader(path))
{
Cylinder[] queryCylinders = new Cylinder[Int32.Parse(file.ReadLine())];
file.ReadLine();
file.ReadLine();
for (int i = 0; i < queryCylinders.Length; i++)
{
Cylinder curCylinder = new Cylinder();
string curCylinderString = file.ReadLine();
uint[] curCylinderUInt = new uint[curCylinderString.Length];
for (int j = 0; j < curCylinderUInt.Length; j++)
{
curCylinderUInt[j] = UInt32.Parse(curCylinderString[j].ToString());
}
curCylinder.Values = CylinderTestsHelper.ConvertArrayUintToBinary(curCylinderUInt);
curCylinder.Angle = Double.Parse(file.ReadLine());
curCylinder.Norm = Double.Parse(file.ReadLine());
queryCylinders[i] = curCylinder;
file.ReadLine();
}
query = new Template(queryCylinders);
}
}
示例5: Run
public static void Run()
{
// Initialize scene object
Scene scene = new Scene();
// Initialize Node class object
Node cubeNode = new Node("cylinder");
// ExStart:ConvertCylinderPrimitivetoMesh
// Initialize object by Cylinder class
IMeshConvertible convertible = new Cylinder();
// Convert a Cylinder to Mesh
Mesh mesh = convertible.ToMesh();
// ExEnd:ConvertCylinderPrimitivetoMesh
// Point node to the Mesh geometry
cubeNode.Entity = mesh;
// Add Node to a scene
scene.RootNode.ChildNodes.Add(cubeNode);
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir() + RunExamples.GetOutputFilePath("CylinderToMeshScene.fbx");
// Save 3D scene in the supported file formats
scene.Save(MyDir, FileFormat.FBX7400ASCII);
Console.WriteLine("\n Converted the primitive Cylinder to a mesh successfully.\nFile saved at " + MyDir);
}
示例6: StanceManager
/// <summary>
/// Constructs a stance manager for a character.
/// </summary>
/// <param name="characterBody">The character's body entity.</param>
/// <param name="crouchingHeight">Crouching height of the character.</param>
/// <param name="proneHeight">Prone height of the character.</param>
/// <param name="queryManager">Provider of queries used by the stance manager to test if it is okay to change stances.</param>
/// <param name="supportFinder">Support finder used by the character.</param>
public StanceManager(Cylinder characterBody, float crouchingHeight, float proneHeight, QueryManager queryManager, SupportFinder supportFinder)
{
this.QueryManager = queryManager;
this.SupportFinder = supportFinder;
this.characterBody = characterBody;
standingHeight = characterBody.Height;
if (crouchingHeight < standingHeight)
this.crouchingHeight = crouchingHeight;
else
throw new ArgumentException("Crouching height must be less than standing height.");
if (proneHeight < crouchingHeight)
this.proneHeight = proneHeight;
else
throw new ArgumentException("Prone height must be less than crouching height.");
//We can share the real shape with the query objects.
currentQueryObject = new ConvexCollidable<CylinderShape>(characterBody.CollisionInformation.Shape);
standingQueryObject = new ConvexCollidable<CylinderShape>(new CylinderShape(StandingHeight, characterBody.Radius) { CollisionMargin = currentQueryObject.Shape.CollisionMargin });
crouchingQueryObject = new ConvexCollidable<CylinderShape>(new CylinderShape(CrouchingHeight, characterBody.Radius) { CollisionMargin = currentQueryObject.Shape.CollisionMargin });
proneQueryObject = new ConvexCollidable<CylinderShape>(new CylinderShape(proneHeight, characterBody.Radius) { CollisionMargin = currentQueryObject.Shape.CollisionMargin });
//Share the collision rules between the main body and its query objects. That way, the character's queries return valid results.
currentQueryObject.CollisionRules = characterBody.CollisionInformation.CollisionRules;
standingQueryObject.CollisionRules = characterBody.CollisionInformation.CollisionRules;
crouchingQueryObject.CollisionRules = characterBody.CollisionInformation.CollisionRules;
proneQueryObject.CollisionRules = characterBody.CollisionInformation.CollisionRules;
}
示例7: BuildStick
void BuildStick(Vector3 position, int linkCount, out List<Bone> bones, out List<Entity> boneEntities)
{
//Set up a bone chain.
bones = new List<Bone>();
boneEntities = new List<Entity>();
var previousBoneEntity = new Cylinder(position, 1, .2f);
var previousBone = new Bone(previousBoneEntity.Position, previousBoneEntity.Orientation, previousBoneEntity.Radius, previousBoneEntity.Height);
bones.Add(previousBone);
boneEntities.Add(previousBoneEntity);
for (int i = 1; i < linkCount; i++)
{
var boneEntity = new Cylinder(previousBone.Position + new Vector3(0, 1, 0), 1, .2f);
var bone = new Bone(boneEntity.Position, boneEntity.Orientation, boneEntity.Radius, boneEntity.Height);
bones.Add(bone);
boneEntities.Add(boneEntity);
//Make a relationship between the two bones and entities.
CollisionRules.AddRule(previousBoneEntity, boneEntity, CollisionRule.NoBroadPhase);
Vector3 anchor = (previousBoneEntity.Position + boneEntity.Position) / 2;
//var dynamicsBallSocketJoint = new BallSocketJoint(previousBoneEntity, boneEntity, anchor);
//var dynamicsAngularFriction = new NoRotationJoint(previousBoneEntity, boneEntity);
//Space.Add(dynamicsBallSocketJoint);
//Space.Add(dynamicsAngularFriction);
var ballSocket = new IKBallSocketJoint(previousBone, bone, anchor);
var angularJoint = new IKAngularJoint(previousBone, bone);
previousBone = bone;
previousBoneEntity = boneEntity;
}
}
示例8: ExecuteFigureCreationCommand
public override void ExecuteFigureCreationCommand(string[] splitFigString)
{
switch (splitFigString[0])
{
case "circle":
{
Vector3D a = Vector3D.Parse(splitFigString[1]);
double b = double.Parse(splitFigString[2]);
currentFigure = new Circle(a, b);
break;
}
case "cylinder":
{
Vector3D a = Vector3D.Parse(splitFigString[1]);
Vector3D b = Vector3D.Parse(splitFigString[2]);
double r = double.Parse(splitFigString[3]);
currentFigure = new Cylinder(a, b, r);
break;
}
default:
{
base.ExecuteFigureCreationCommand(splitFigString);
break;
}
}
this.EndCommandExecuted = false;
}
示例9: CharacterController
/// <summary>
/// Constructs a new character controller with the most common configuration options.
/// </summary>
/// <param name="position">Initial position of the character.</param>
/// <param name="height">Height of the character body while standing.</param>
/// <param name="crouchingHeight">Height of the character body while crouching.</param>
/// <param name="radius">Radius of the character body.</param>
/// <param name="mass">Mass of the character body.</param>
public CharacterController(Vector3 position, float height, float crouchingHeight, float radius, float mass)
{
Body = new Cylinder(position, height, radius, mass);
Body.IgnoreShapeChanges = true; //Wouldn't want inertia tensor recomputations to occur when crouching and such.
Body.CollisionInformation.Shape.CollisionMargin = .1f;
//Making the character a continuous object prevents it from flying through walls which would be pretty jarring from a player's perspective.
Body.PositionUpdateMode = PositionUpdateMode.Continuous;
Body.LocalInertiaTensorInverse = new Matrix3X3();
//TODO: In v0.16.2, compound bodies would override the material properties that get set in the CreatingPair event handler.
//In a future version where this is changed, change this to conceptually minimally required CreatingPair.
Body.CollisionInformation.Events.DetectingInitialCollision += RemoveFriction;
Body.LinearDamping = 0;
SupportFinder = new SupportFinder(this);
HorizontalMotionConstraint = new HorizontalMotionConstraint(this);
VerticalMotionConstraint = new VerticalMotionConstraint(this);
StepManager = new StepManager(this);
StanceManager = new StanceManager(this, crouchingHeight);
QueryManager = new QueryManager(this);
//Enable multithreading for the characters.
IsUpdatedSequentially = false;
//Link the character body to the character controller so that it can be identified by the locker.
//Any object which replaces this must implement the ICharacterTag for locking to work properly.
Body.CollisionInformation.Tag = new CharacterSynchronizer(Body);
}
示例10: GoalPostObject
public GoalPostObject(Vector3 p, Model m, int h, float r)
{
position = p;
model = m;
post1 = new Cylinder(new Vector3(p.X - 6.5f, h / 2, p.Z), h, r);
post2 = new Cylinder(new Vector3(p.X + 6.5f, h / 2, p.Z), h, r);
}
示例11: GenerateTemplateDb
public static void GenerateTemplateDb(
int givenCylinderDbCount, int givenTemplateDbCount, int givenCylinderCellsCount)
{
cylinderDbCount = givenCylinderDbCount;
templateDbCount = givenTemplateDbCount;
cylinderCellsCount = givenCylinderCellsCount;
db = new Cylinder[cylinderDbCount];
templateIndices = new int[cylinderDbCount];
templateDbLengths = new int[templateDbCount];
for (int i = 0; i < cylinderDbCount; i++)
{
Cylinder curCylinder = new Cylinder();
// For further randomness (so that cylinders don't have very similar norms)
double curThreshold = rnd.NextDouble();
uint[] curCylinderValues = new uint[cylinderCellsCount];
for (int j = 0; j < cylinderCellsCount; j++)
{
double x = rnd.NextDouble();
curCylinderValues[j] = x < curThreshold ? (uint)0 : 1; // Cast necessary? o_o
}
curCylinder.Values = curCylinderValues;
curCylinder.Angle = rnd.NextDouble() * 2 * Math.PI;
curCylinder.Norm = CylinderHelper.CalculateCylinderNorm(curCylinder.Values);
db[i] = curCylinder;
}
// Thresholds again for further randomness (not a uniform distribution between templates)
double[] templateThresholds = new double[templateDbCount - 1];
for (int i = 0; i < templateDbCount - 1; i++)
{
templateThresholds[i] = rnd.NextDouble();
}
for (int i = 0; i < cylinderDbCount; i++)
{
double x = rnd.NextDouble();
int curTemplateIndex = 0;
for (int j = 0; j < templateDbCount - 1; j++)
{
if (x > templateThresholds[j])
{
curTemplateIndex++;
}
}
templateIndices[i] = curTemplateIndex;
templateDbLengths[curTemplateIndex]++;
}
}
示例12: Main
public static void Main(string[] args)
{
// Test Program for Lab401
Circle c1 = new Circle(), c2 = new Circle(1.5, 5.0, 2), c3 = new Circle(c2);
Console.WriteLine(c1 + "\n" + c2 + "\n" + c3);
Cylinder cl1 = new Cylinder(), cl2 = new Cylinder(c3), cl3 = new Cylinder(1, 1, 3, 4);
Cylinder cl4 = new Cylinder(cl3);
Console.WriteLine(cl1 + "\n" + cl2 + "\n" + cl3 + "\n" + cl4);
}
示例13: Main
static void Main()
{
double r = 3.0, h = 5.0;
Shape c = new Circle(r);
Shape s = new Sphere(r);
Shape l = new Cylinder(r, h);
// Display results:
Console.WriteLine("Area of Circle = {0:F2}", c.Area());
Console.WriteLine("Area of Sphere = {0:F2}", s.Area());
Console.WriteLine("Area of Cylinder = {0:F2}", l.Area());
}
示例14: StepManager
float upStepMargin = .1f; //There's a little extra space above the maximum step height to start the obstruction and downcast test rays. Helps when a step is very close to the max step height.
#endregion Fields
#region Constructors
/// <summary>
/// Constructs a new step manager for a character.
/// </summary>
/// <param name="characterBody">The character's body.</param>
/// <param name="contactCategorizer">Contact categorizer used by the character.</param>
/// <param name="supportFinder">Support finder used by the character.</param>
/// <param name="queryManager">Query provider to use in checking for obstructions.</param>
/// <param name="horizontalMotionConstraint">Horizontal motion constraint used by the character. Source of 3d movement direction.</param>
public StepManager(Cylinder characterBody, CharacterContactCategorizer contactCategorizer, SupportFinder supportFinder, QueryManager queryManager, HorizontalMotionConstraint horizontalMotionConstraint)
{
this.characterBody = characterBody;
currentQueryObject = new ConvexCollidable<CylinderShape>(characterBody.CollisionInformation.Shape);
ContactCategorizer = contactCategorizer;
SupportFinder = supportFinder;
QueryManager = queryManager;
HorizontalMotionConstraint = horizontalMotionConstraint;
//The minimum step height is just barely above where the character would generally find the ground.
//This helps avoid excess tests.
minimumUpStepHeight = CollisionDetectionSettings.AllowedPenetration * 1.1f;// Math.Max(0, -.01f + character.Body.CollisionInformation.Shape.CollisionMargin * (1 - character.SupportFinder.sinMaximumSlope));
}
示例15: CylinderObject
public CylinderObject(Vector3 pos, float altura, float raio, Vector3? scale = null, float mass = 10,Matrix? orientation = null,MaterialDescription md=null)
: base(md,mass)
{
if (!orientation.HasValue)
orientation = Matrix.Identity;
if (!scale.HasValue)
scale = Vector3.One;
entity = new Cylinder(pos, altura * scale.Value.Y, raio * scale.Value.X, mass);
this.scale = scale.Value;
entity.Orientation = Quaternion.CreateFromRotationMatrix(orientation.Value);
}