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); }
/// <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); }
/// <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); }
/// <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); }
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; } }
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); } }
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); }
/// <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; }
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; }
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); }
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]++; } }
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); }
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()); }
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)); }
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); }
public static void Main() { double r = 3.0, h = 5.0; Dimensions c = new Circle(r); Dimensions s = new Sphere(r); Dimensions l = new Cylinder(r, h); Console.WriteLine("Area of Circle = {0}", string.Format("{0:0.00}", c.Area())); Console.WriteLine("Area of Sphere = {0}", string.Format("{0:0.00}", s.Area())); Console.WriteLine("Area of Cylinder = {0}", string.Format("{0:0.00}", l.Area())); Console.ReadLine(); }
public override void Execute(ref WooState state) { if (state._Objects > 0) { state._Objects--; Vector3 val = new Vector3(0.0, 0.5, 0.0); val.y *= state._Scale.y; val.Mul(state._Rotation); Cylinder newCylinder = new Cylinder(new Vector3(state._Position.x + val.x, state._Position.y + val.y, state._Position.z + val.z), state._Scale * 0.5, state._Rotation); newCylinder._Material = GenerateMaterial(state); newCylinder.CreateElement(state._Preview, state._Parent); } }
/// <summary> /// Constructs a new character controller. /// </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="proneHeight">Height of the character body while prone.</param> /// <param name="radius">Radius of the character body.</param> /// <param name="margin">Radius of 'rounding' applied to the cylindrical body. Higher values make the cylinder's edges more rounded. /// The margin is contained within the cylinder's height and radius, so it must not exceed the radius or height of the cylinder. /// To change the collision margin later, use the CharacterController.CollisionMargin property.</param> /// <param name="mass">Mass of the character body.</param> /// <param name="maximumTractionSlope">Steepest slope, in radians, that the character can maintain traction on.</param> /// <param name="maximumSupportSlope">Steepest slope, in radians, that the character can consider a support.</param> /// <param name="standingSpeed">Speed at which the character will try to move while crouching with a support that provides traction. /// Relative velocities with a greater magnitude will be decelerated.</param> /// <param name="crouchingSpeed">Speed at which the character will try to move while crouching with a support that provides traction. /// Relative velocities with a greater magnitude will be decelerated.</param> /// <param name="proneSpeed">Speed at which the character will try to move while prone with a support that provides traction. /// Relative velocities with a greater magnitude will be decelerated.</param> /// <param name="tractionForce">Maximum force that the character can apply while on a support which provides traction.</param> /// <param name="slidingSpeed">Speed at which the character will try to move while on a support that does not provide traction. /// Relative velocities with a greater magnitude will be decelerated.</param> /// <param name="slidingForce">Maximum force that the character can apply while on a support which does not provide traction</param> /// <param name="airSpeed">Speed at which the character will try to move with no support. /// The character will not be decelerated while airborne.</param> /// <param name="airForce">Maximum force that the character can apply with no support.</param> /// <param name="jumpSpeed">Speed at which the character leaves the ground when it jumps</param> /// <param name="slidingJumpSpeed">Speed at which the character leaves the ground when it jumps without traction</param> /// <param name="maximumGlueForce">Maximum force the vertical motion constraint is allowed to apply in an attempt to keep the character on the ground.</param> public CharacterController( Vector3 position = new Vector3(), float height = 1.7f, float crouchingHeight = 1.7f * .7f, float proneHeight = 1.7f * 0.3f, float radius = 0.6f, float margin = 0.1f, float mass = 10f, float maximumTractionSlope = 0.8f, float maximumSupportSlope = 1.3f, float standingSpeed = 8f, float crouchingSpeed = 3f, float proneSpeed = 1.5f, float tractionForce = 1000, float slidingSpeed = 6, float slidingForce = 50, float airSpeed = 1, float airForce = 250, float jumpSpeed = 4.5f, float slidingJumpSpeed = 3, float maximumGlueForce = 5000 ) { if (margin > radius || margin > crouchingHeight || margin > height) throw new ArgumentException("Margin must not be larger than the character's radius or height."); 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 = margin; //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; ContactCategorizer = new CharacterContactCategorizer(maximumTractionSlope, maximumSupportSlope); QueryManager = new QueryManager(Body, ContactCategorizer); SupportFinder = new SupportFinder(Body, QueryManager, ContactCategorizer); HorizontalMotionConstraint = new HorizontalMotionConstraint(Body, SupportFinder); HorizontalMotionConstraint.PositionAnchorDistanceThreshold = radius * 0.25f; VerticalMotionConstraint = new VerticalMotionConstraint(Body, SupportFinder, maximumGlueForce); StepManager = new StepManager(Body, ContactCategorizer, SupportFinder, QueryManager, HorizontalMotionConstraint); StanceManager = new StanceManager(Body, crouchingHeight, proneHeight, QueryManager, SupportFinder); PairLocker = new CharacterPairLocker(Body); StandingSpeed = standingSpeed; CrouchingSpeed = crouchingSpeed; ProneSpeed = proneSpeed; TractionForce = tractionForce; SlidingSpeed = slidingSpeed; SlidingForce = slidingForce; AirSpeed = airSpeed; AirForce = airForce; JumpSpeed = jumpSpeed; SlidingJumpSpeed = slidingJumpSpeed; //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); }
private void Branch(Cylinder parent, Float size) { Cylinder branch = new Cylinder(); branch.Texture = Library.Textures.DarkWood; Vector end = (new PovRandom().Vector() + (-0.5, 0, -0.5)) * (size * 3); branch.BasePoint = parent.CapPoint; branch.CapPoint = parent.CapPoint + end; branch.Radius = size * 0.1; this.Add(branch); size = size * 0.5; if (size > 1) { this.AddBranches(branch, size); } }
/// <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; }
/// <summary> /// This makes a tube. You're gonna have lots of these in a list in a level. /// </summary> /// <param name="pos">Position to start with.</param> /// <param name="x">True if facing the x axis, false if facing y axis.</param> /// <param name="forward">This is actually the opposite of what it should be.</param> public Tube(Vector3 pos, bool x, bool forward) : base(delegate { return Resources.tubeModel; }, false, null, pos) { Ent = new Cylinder(pos, 4, 0.5f); Ent.Material = tubeMaterial; Ent.Tag = this; Forward = forward; //this.x = x; //TargetTime = 1; if(!x) Ent.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.PiOver2); //Ent.IsAffectedByGravity = false; Ent.CollisionInformation.Events.PairTouching += OnCollision; Ent.CollisionInformation.Events.CollisionEnded += OffCollision; Ent.CollisionInformation.CollisionRules.Group = tubeGroup; rotationDirection = x ? Vector3.UnitY : -Vector3.UnitX; Ent.Orientation = Quaternion.CreateFromAxisAngle(rotationDirection, MathHelper.ToRadians(random.Next(0, 360))) * Ent.Orientation; OriginalOrientation = Ent.Orientation; //motor = new RevoluteJoint(null, Ent, ModelPosition, rotationDirection); //motor.Motor.Settings.Mode = MotorMode.VelocityMotor; //motor.Motor.Settings.VelocityMotor.Softness *= 9; //motor.Motor.IsActive = true; //motor.Motor.Settings.Servo.SpringSettings.StiffnessConstant = 0; //motor.Motor.Settings.Servo.SpringSettings.DampingConstant /= 10; //motor.Motor.Settings.Servo.BaseCorrectiveSpeed = MathHelper.TwoPi * GameManager.Space.TimeStepSettings.TimeStepDuration; //m1 = new SingleEntityAngularMotor(Ent); //m1.Settings.Mode = MotorMode.Servomechanism; //m1.Settings.Servo.SpringSettings.StiffnessConstant = 0; //AdditionalRotation = Quaternion.Identity; //rebuildCurve(); //m2 = new SingleEntityLinearMotor(Ent, ModelPosition); //m2.Settings.Mode = MotorMode.Servomechanism; //m2.Settings.Servo.Goal = ModelPosition; //m2.Settings.Servo.SpringSettings.StiffnessConstant = 0; //m2.Settings.Servo.SpringSettings.DampingConstant /= 4; }
public void CurvedEdges() { var cylinder = Cylinder.Create(10, 10); cylinder.SegmentAngle = 270; Body.Create(cylinder); var face = cylinder.GetSubshapeReference(SubshapeType.Face, 1); var edge = cylinder.GetSubshapeReference(SubshapeType.Edge, 0); var taper = Taper.Create(cylinder.Body, face, edge, 22.5); Assert.IsTrue(taper.Make(Shape.MakeFlags.None)); AssertHelper.IsSameModel(taper, Path.Combine(_BasePath, "CurvedEdges1")); edge = cylinder.GetSubshapeReference(SubshapeType.Edge, 4); taper.BaseEdgeOrVertex = edge; Assert.IsTrue(taper.Make(Shape.MakeFlags.None)); AssertHelper.IsSameModel(taper, Path.Combine(_BasePath, "CurvedEdges2")); }
/// <summary> /// Creates a new instance of the <see cref="BoardAxes"/> class. /// </summary> public BoardAxes() { textModels = new Collection <SolidText>(); axesModels = new Collection <Cylinder>(); Cylinder xAxis = CreateXAxis(); Cylinder zAxis = CreateZAxis(); Cylinder yAxis = CreateYAxis(); ModelVisual3D xLabels = CreateXAxisLabels(); ModelVisual3D zLabels = CreateZAxisLabels(); ModelVisual3D yLabels = CreateYAxisLabels(); Children.Add(xAxis); Children.Add(zAxis); Children.Add(yAxis); Children.Add(xLabels); Children.Add(zLabels); Children.Add(yLabels); }
public void GroupHasBoundingBoxThatContainsItsChildren_ShouldWork() { var s = new Sphere(); s.Transform = Transformation.Translation(2, 5, -3) * Transformation.Scaling(2, 2, 2); var c = new Cylinder(); c.Minimum = -2; c.Maximum = 2; c.Transform = Transformation.Translation(-4, -1, 4) * Transformation.Scaling(0.5, 1, 0.5); var group = new Group(); group.AddShape(s); group.AddShape(c); var box = group.GetBounds(); Assert.Equal(new Point(-4.5, -3, -5), box.Min, PointComparer); Assert.Equal(new Point(4, 7, 4.5), box.Max, PointComparer); }
private void DrawCylinder(OpenGL gl) { gl.Disable(OpenGL.GL_AUTO_NORMAL); gl.PushMatrix(); gl.Translate(0f, -1f, 0f); gl.Rotate(-90f, 0f, 0f); Cylinder cil = new Cylinder { Height = 10, BaseRadius = 2, TopRadius = 2 }; cil.NormalGeneration = Normals.Smooth; cil.CreateInContext(gl); cil.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render); gl.PopMatrix(); gl.Enable(OpenGL.GL_AUTO_NORMAL); }
public void SpawnNewCylinder() //Save the cylinder to the past and add it to the cylinder sheet { Cylinder newCylinder = Instantiate(prefab); Vector3 position = new Vector3(transform.position.x, cylinders[cylinders.Count - 1].transform.position.y - cylinders[cylinders.Count - 1].transform.localScale.z, transform.position.z); newCylinder.transform.localPosition = position; newCylinder.transform.localScale = new Vector3(0.01f, 0.6f, 0.01f); Scale = 0.01f; PlayerPrefs.SetFloat("Scale", Scale); newCylinder.transform.SetParent(parent); cylinders.Add(newCylinder); cylindersNum = cylindersNum + 1; PlayerPrefs.SetInt("CylinderNum", cylindersNum); }
public static void ParseDb(string path) { using (var file = new StreamReader(path)) { string[] templateDbLengthsString = file.ReadLine().Split(new Char[] { ' ' }); templateDbLengths = new int[templateDbLengthsString.Length]; for (int i = 0; i < templateDbLengthsString.Length; i++) { templateDbLengths[i] = Int32.Parse(templateDbLengthsString[i]); } string[] templateIndicesString = file.ReadLine().Split(new Char[] { ' ' }); templateIndices = new uint[templateIndicesString.Length]; for (int i = 0; i < templateIndicesString.Length; i++) { templateIndices[i] = UInt32.Parse(templateIndicesString[i]); } file.ReadLine(); contiguousCylinders = new Cylinder[templateIndices.Length]; for (int i = 0; i < templateIndices.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()); contiguousCylinders[i] = curCylinder; file.ReadLine(); } } }
public override void Initialize(ContentArchive content, Camera camera) { camera.Yaw = 0; camera.Pitch = 0; camera.Position = new Vector3(0, 0, 5); Simulation = Simulation.Create(BufferPool, new DemoNarrowPhaseCallbacks(), new DemoPoseIntegratorCallbacks(new Vector3(0, 0, 0))); var a = new Cylinder(1f, 1f); var b = new Cylinder(1f, 1f); var localOffsetB = new Vector3(.1f, 1.1f, 0.1f); var localOrientationB = Quaternion.CreateFromAxisAngle(Vector3.Normalize(new Vector3(1, 1, 1)), MathHelper.Pi * 1.5f); Simulation.Bodies.Add(BodyDescription.CreateConvexKinematic(new Vector3(), Simulation.Shapes, a)); Simulation.Bodies.Add(BodyDescription.CreateConvexKinematic(new RigidPose(localOffsetB, localOrientationB), Simulation.Shapes, b)); CylinderWide aWide = default, bWide = default;
public static Cylinder PutNewRandomCylinderOnHook(string hook) { Hook h = new Hook(hook); if (h.CylinderID != 0) { return(Cylinder.LoadCylinder(h.CylinderID)); } if (h.IsRackValid()) { Cylinder c = CreateNewRandomCylinder(); h.CylinderID = c.Cylinder_ID; return(c); } return(null); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); Renderer.Initialize(this); defaultTexture = Content.Load <Texture2D>("default"); light = new DirectionalLight(); light.Direction = new Vector3(0, -0.3f, 0.5f); light.Color = Color.Red; geomCube = new Cube(GraphicsDevice); geomCube.Position = new Vector3(2, 1, 0); geomCube.Color = new Color(1.0f, 0.0f, 0.0f); geomCylinder = new Cylinder(GraphicsDevice, 5); geomCylinder.Position = new Vector3(4, 1, 0); geomCylinder.Color = new Color(1.0f, 1.0f, 0.0f); geomSphere = new Sphere(GraphicsDevice, 3); geomSphere.Position = new Vector3(6, 1, 0); geomSphere.Color = new Color(0.0f, 1.0f, 0.0f); geomTorus = new Torus(GraphicsDevice); geomTorus.Position = new Vector3(8, 1, 0); geomTorus.Color = new Color(0.0f, 1.0f, 1.0f); teapot = new Mesh(Content.Load <Model>("Teapot")) { Size = new Vector3(0.5f, 0.5f, 0.5f), Position = new Vector3(10, 0, 0), Texture = defaultTexture }; cube = new Mesh(Content.Load <Model>("cube")) { Position = new Vector3(0, 1, -5), Size = new Vector3(2, 4, 2), Rotation = new Vector3(45, 0, 45), Texture = defaultTexture }; }
public void DrawCylinder(ref Vector3 position, float height, float radius, ref Quaternion rotation, ref Color color, bool depthTest = true) { var cmd = new Cylinder() { Position = position, Height = height, Radius = radius, Rotation = rotation, Color = color }; var msg = new Renderable(ref cmd); if (depthTest) { renderablesWithDepth.Add(msg); totalPrimitives.Cylinders++; } else { renderablesNoDepth.Add(msg); totalPrimitivesNoDepth.Cylinders++; } }
public CircularPrintbed(float radius, Color color, Color lineColor, float rotationX = 0, float rotationY = 0) { float height = 0.01f; var printbed = Cylinder.With() .Position(new Point3D(0, 0, -height)) .Height(height) .Radius(radius) .RotationX(rotationX) .RotationY(rotationY) .Color(color) .Build(); var linePoints = GetLinePoints(radius) .RotateXYX(rotationX, rotationY, 0); var lines = new Renderable(lineColor, linePoints, RenderableType.Lines); _parts.Add(printbed); _parts.Add(lines); }
public void LocalBoundsConsidersAllChildren() { var s = new Sphere(); s.SetTransform(Transform.Translate(2, 5, -3) * Transform.Scale(2f)); var c = new Cylinder { Minimum = -2, Maximum = 2 }; c.SetTransform(Transform.Translate(-4, -1, 4) * Transform.Scale(0.5f, 1, 0.5f)); var g = new Group(); g.AddChild(s); g.AddChild(c); var b = g.LocalBounds(); b.Min.Should().Be(new Point(-4.5f, -3, -5)); b.Max.Should().Be(new Point(4f, 7, 4.5f)); }
public void NoAutoFaceDetection() { Context.InitWithView(500); var ctx = Context.Current; // Create a shape with a planar face, but without an opposite face var cylinder = Cylinder.Create(10, 10); var body = Body.Create(cylinder); var face = cylinder.GetSubshapeReference(SubshapeType.Face, 1); var edge = cylinder.GetSubshapeReference(SubshapeType.Edge, 0); var taper = Taper.Create(cylinder.Body, face, edge, 22.5); taper.BaseParameter = 0.0; Assert.IsTrue(taper.Make(Shape.MakeFlags.None)); ctx.Document.AddChild(body); ctx.ViewportController.ZoomFitAll(); // Start tool ctx.WorkspaceController.Selection.SelectEntity(body); Assert.IsTrue(ToolboxCommands.CreateEtchingMask.CanExecute()); ToolboxCommands.CreateEtchingMask.Execute(); var tool = ctx.WorkspaceController.CurrentTool as EtchingMaskEditTool; Assert.IsNotNull(tool); Assert.IsNotNull(ctx.WorkspaceController.CurrentToolAction); // Check selection filter ctx.MoveTo(150, 300); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "NoAutoFaceDetection02")); ctx.MoveTo(250, 250); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "NoAutoFaceDetection01")); ctx.ClickAt(250, 250); Assert.IsNull(ctx.WorkspaceController.CurrentToolAction); // Component should exist, even if it can not work correctly var component = body.FindComponent <EtchingMaskComponent>(); Assert.IsNotNull(component); Assert.IsFalse(component.IsValid); }
/// <summary> /// Constructs a new character controller with the default configuration. /// </summary> public CharacterController() { Body = new Cylinder(Vector3.Zero, 1.7f, .6f, 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); }
// ç±» public void testClass() { MyClass p1 = new MyClass(); MyClass p2 = new MyClass(6, 7); Console.WriteLine("CoOrds #1 at {0}", p1); Console.WriteLine("CoOrds #2 at {0}", p2); Circle ring = new Circle(2); Cylinder tube = new Cylinder(2, 3); Console.WriteLine("Area of the circle = {0:F2}", ring.Area()); Console.WriteLine("Area of the cylinder = {0:F2}", tube.Area()); TimePeriod ti = new TimePeriod(3600*5); Console.WriteLine("Setid time is {0}", ti.hours); ShapeStatic.TestSe(); }
private GasEndPoint MakeInstalledCylinder(IDataReader reader, DataAccessOrdinals ordinals, DataAccessTransaction trx) { short position = SqlSafeGetShort(reader, ordinals["POSITION"]); string partNumber = SqlSafeGetString(reader, ordinals["PARTNUMBER"]); // Try and get the Factory Cylinder information for the part number. // Note that there may not be any factory cylinder info available if the // part number is for a new cylinder type that's unknown to to iNet. FactoryCylinder factoryCylinder = null; if (partNumber != string.Empty) { factoryCylinder = new FactoryCylinderDataAccess().FindByPartNumber(partNumber, trx); } Cylinder cylinder; if (factoryCylinder != null) { cylinder = new Cylinder(factoryCylinder); } else { cylinder = new Cylinder(); cylinder.PartNumber = partNumber; } string installationTypeString = SqlSafeGetString(reader, ordinals["INSTALLATIONTYPE"]); GasEndPoint.Type installationType = (GasEndPoint.Type)Enum.Parse(typeof(GasEndPoint.Type), installationTypeString, true); GasEndPoint gep = new GasEndPoint(cylinder, position, installationType); gep.Cylinder.FactoryId = SqlSafeGetString(reader, ordinals["FACTORYID"]); gep.Cylinder.ExpirationDate = SqlSafeGetDate(reader, ordinals["EXPIRATIONDATE"]); gep.Cylinder.RefillDate = SqlSafeGetDate(reader, ordinals["REFILLDATE"]); string pressure = SqlSafeGetString(reader, ordinals["PRESSURE"]); gep.Cylinder.Pressure = (PressureLevel)Enum.Parse(typeof(PressureLevel), pressure, true); return(gep); }
public void IntersectContrainedCylinder() { Cylinder cyl = new Cylinder(); cyl.MinHeight = 1.0f; cyl.MaxHeight = 2.0f; Point org01 = new Point(0, 1.5f, 0); Point org02 = new Point(0, 3, -5); Point org03 = new Point(0, 0, -5); Point org04 = new Point(0, 2, -5); Point org05 = new Point(0, 1, -5); Point org06 = new Point(0, 1.5f, -2); Vector3 d01 = new Vector3(0.1f, 1, 0).Normalize(); Vector3 d02 = new Vector3(0, 0, 1).Normalize(); Vector3 d03 = new Vector3(0, 0, 1).Normalize(); Vector3 d04 = new Vector3(0, 0, 1).Normalize(); Vector3 d05 = new Vector3(0, 0, 1).Normalize(); Vector3 d06 = new Vector3(0, 0, 1).Normalize(); Ray r01 = new Ray(org01, d01); Ray r02 = new Ray(org02, d02); Ray r03 = new Ray(org03, d03); Ray r04 = new Ray(org04, d04); Ray r05 = new Ray(org05, d05); Ray r06 = new Ray(org06, d06); List <Intersection> xs01 = cyl.LocalIntersects(r01); List <Intersection> xs02 = cyl.LocalIntersects(r02); List <Intersection> xs03 = cyl.LocalIntersects(r03); List <Intersection> xs04 = cyl.LocalIntersects(r04); List <Intersection> xs05 = cyl.LocalIntersects(r05); List <Intersection> xs06 = cyl.LocalIntersects(r06); Assert.Empty(xs01); Assert.Empty(xs02); Assert.Empty(xs03); Assert.Empty(xs04); Assert.Empty(xs05); Assert.Equal(2, xs06.Count); }
public static Cylinder PutNewRandomCylinderOnLoadingStation(int ls_nr, int diameter = 0) { Unit ls = Unit.GetUnit(ls_nr); Hook ls_hook_out = Hook.LoadingStation(ls_nr, false); ls_hook_out.ClearID(); if (ls_nr == 13) { Hook.LS03a.ClearID(); } //bool inside = ls.PosAxis04 == 1; Hook ls_hook = Hook.LoadingStation(ls_nr, true); if (ls_hook.CylinderID != 0) { Cylinder cc = ls_hook.Cylinder; if (diameter > 0 && cc.Cylinder_ID != 0) { cc.Diameter = diameter; cc.Update(); } if (cc.Cylinder_ID != 0) { return(Cylinder.LoadCylinder(ls_hook.CylinderID)); } } Cylinder c = CreateNewRandomCylinder(); ls_hook.CylinderID = c.Cylinder_ID; if (diameter > 0) { c.Diameter = diameter; c.Update(); } return(c); }
static void Main(string[] args) { do { try { Circle circle = new Circle(); Cube cube = new Cube(); ITransform transform = circle; Report(circle); Report(cube); Report(transform); Pyramide pyramide = new Pyramide { B = 2, H = 3 }; Report(pyramide); pyramide.Transform(2); Report(pyramide); ITransform[] transforms = new ITransform[3]; transforms[0] = new Cube { Rib = 2 }; transforms[1] = new Circle { Rad = 2 }; transforms[2] = new Cylinder { H = 2, R = 3 }; Array.ForEach(transforms, Report); Array.ForEach(transforms, transform1 => transform1.Transform(2)); Array.ForEach(transforms, Report); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("Press Esc to exit or another button to continue"); } while (Console.ReadKey().Key != ConsoleKey.Escape); }
public static bool CylinderCylinderOverlappingCheck(Cylinder primitiveA, Cylinder primitiveB) { if (!primitiveA.IsPositive && primitiveB.IsPositive) { return(NegCylinderPosCylinderOverlappingCheck(primitiveA, primitiveB, 1)); } if (primitiveA.IsPositive && !primitiveB.IsPositive) { return(NegCylinderPosCylinderOverlappingCheck(primitiveB, primitiveA, 2)); } if (primitiveA.IsPositive && primitiveB.IsPositive) { return(PosCylinderPosCylinderOverlappingCheck(primitiveA, primitiveB)); } if (!primitiveA.IsPositive && !primitiveB.IsPositive) { return(false); } return(false); }
static Group HexagonSide() { var mat = new PhongMaterial(Util.FromHex("#7bc74d")) { Specular = .5f, Shininess = 800 }; var edge = new Cylinder(Translation(0, 0, -1) * RotationY(-MathF.PI / 6f) * RotationZ(-MathF.PI / 2f) * Scale(.25f, 1, .25f)) { Minimum = 0, Maximum = 1, Material = mat }; var s = new Sphere(Translation(0, 0, -1) * Scale(.25f)) { Material = mat }; var side = new Group(); side.AddChildren(edge, s); return(side); }
static void Main(string[] args) { Point zorg = new Point(2, 3, 5); Circle bob = new Circle(4, 2, 2, 0); Square sally = new Square(3, 3, 5); Rectangle stan = new Rectangle(4, 4, 10, 5); Cylinder felix = new Cylinder(4.5, 8, 3, 7, 10); AbstractShape shozape; shozape = bob; string output = zorg.Name + " " + zorg + "\n" + bob.Name + " " + bob + "\n" + sally.Name + " " + sally + "\n" + stan.Name + " " + stan + "\n" + felix.Name + " " + felix + "\n"; MessageBox.Show(output); }
private static void makeLaserStand() { OSCADObject center = new Cube(Inches.One, Inches.Half, Inches.One * 1.2, true); OSCADObject outerColumn = new Cylinder(Inches.One, Inches.One, true).Resize(Inches.One * 1.5, Inches.Half * 1.5, Inches.One); var bnds = outerColumn.Bounds(); OSCADObject bottom = new Cylinder(Inches.One, Inches.One, true) .Resize(Inches.One * 2, Inches.Half * 2, Inches.One) .Translate(0, 0, 0); var obj = (outerColumn) + bottom; bnds = obj.Bounds(); var cap = makeStandCap(); obj = obj + cap.Translate(0, 0, bnds.ZMax - Inches.Sixteenth); obj.ToFile("laserStand2").Open(); }
private static void TestCase03() { // Normal vector on a cylinder Shape cyl = new Cylinder(); var point = new[] { Tuple.Point(1, 0, 0), Tuple.Point(0, 5, -1), Tuple.Point(0, -2, 1), Tuple.Point(-1, 1, 0) }; var normal = new[] { Tuple.Vector(1, 0, 0), Tuple.Vector(0, 0, -1), Tuple.Vector(0, 0, 1), Tuple.Vector(-1, 0, 0) }; MethodInfo mi = cyl.GetType().GetMethod("LocalNormalAt", BindingFlags.NonPublic | BindingFlags.Instance); for (int i = 0; i < 4; ++i) { Tuple n = (Tuple)mi.Invoke(cyl, new[] { point[i], null }); Assert.Equal(normal[i], n); } }
public static void makeACBrackets() { double width = Inches.One * 6.5; double height = Inches.One; double depth = Inches.One; double thickness = Inches.Quarter; var mainBox = new Cube(width, depth, height, true); var cutout = mainBox.Clone().Scale(1.1, 1, 1).Translate(0, thickness, thickness); var hole = new Cylinder(Inches.Eigth, Inches.One * 2, true) { Resolution = 30 }.Rotate(90, 0, 0); var whole = mainBox - cutout - hole.Translate(0, 0, Inches.Quarter) - hole.Clone().Translate(-Inches.One * 2, 0, Inches.Quarter) - hole.Clone().Translate(+Inches.One * 2, 0, Inches.Quarter); whole.ToFile("acBracket"); }
public override void Visit(Cylinder visitable) { if (visitable.IsInvisible()) { return; } if (visitable.Top is PlaneImageBrush) { throw new NotImplementedException(); } var solidColorBrush = visitable.Top as SolidColorBrush; if (solidColorBrush == null) { return; } var diameter = (int)(Math.Max(visitable.RTop, visitable.RBottom) * 2); InternalResult = FromColor(visitable, solidColorBrush.Color, new Size(diameter, diameter)); }
/// <summary> /// TODO 3.3: Draw one port pillar /// <summary> public void DrawPillar(OpenGL gl, float transX, float transZ) { gl.PushMatrix(); gl.Translate(transX, pillarTranslateY, transZ); gl.Scale(20f, 170f, 20f); gl.Rotate(-90f, 1, 0, 0); Glu.gluQuadricTexture(Glu.gluNewQuadric(), 1); gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureMaterials.WOOD]); gl.Color(0.2f, 0.2f, 0.2f); Cylinder pillar = new Cylinder { TopRadius = 1 }; pillar.CreateInContext(gl); pillar.Render(gl, RenderMode.Render); gl.PopMatrix(); }
public static void makePaddle() { double holeSize = Inches.One + Inches.Eigth; double holeHeight = Inches.One; double shaftSize = holeSize + Inches.Quarter; double totalLength = Inches.One * 8; double totalWidth = Inches.One * 5; var blade = new Sphere() { Resolution = 80 }.Resize(totalLength, totalWidth, Inches.One * 2); var copy = blade.Clone().Translate(0, 0, -Inches.One).Scale(1.4, 1.4, 1.1); blade = blade - copy; //var gap = new Cube(Inches.One, Inches.One * 8, Inches.One*8, true).Translate(blade.Bounds().XMin, 0, 0); //blade = blade - gap; OSCADObject shaft = new Cylinder(shaftSize, totalLength / 4, true) { Resolution = 80 }.Rotate(0, 90, 0); var hole = new Cylinder(holeSize, holeHeight * 2, true) { Resolution = 80 }.Rotate(0, 90, 0).Translate(shaft.Bounds().XMin, 0, 0); blade = blade - hole.Translate(blade.Bounds().XMin + Inches.Half, 0, +Inches.Quarter); shaft = shaft - hole; shaft = shaft.Translate(blade.Bounds().XMin + Inches.Half, 0, +Inches.Quarter); var gapCloser = new Sphere(shaftSize) { Resolution = 80 }.Translate(shaft.Bounds().XMax, 0, +Inches.Quarter); var whole = (blade + shaft + gapCloser).Rotate(180, 0, 0); whole.ToFile("paddle").Open(); }
public AxisGizmo(Color color, Vector3D axis) { this.Axis = axis; this.color = color; Vector3D rotationAxis = new Vector3D(axis.Z, 0, axis.X); this.circle = new Circle(); this.circle.Thickness = 1; this.circle.Color = color; this.circle.Radius = 0.5; this.circle.Transform = new RotateTransform3D(new AxisAngleRotation3D(axis, 90)); this.Children.Add(this.circle); cylinder = new Cylinder(); cylinder.Radius = 0.49; cylinder.Length = 0.15; cylinder.Transform = new RotateTransform3D(new AxisAngleRotation3D(axis, 90)); cylinder.Material = new DiffuseMaterial(new SolidColorBrush(Colors.Transparent)); this.Children.Add(cylinder); }
internal static extern IntPtr ON_Cylinder_GetNurbForm(ref Cylinder cylinder);
static void Main() { double radius = 2.5; double height = 3.0; Circle ring = new Circle(radius); Cylinder tube = new Cylinder(radius, height); Console.WriteLine("Area of the circle = {0:F2}", ring.Area()); Console.WriteLine("Area of the cylinder = {0:F2}", tube.Area()); // Keep the console window open in debug mode. Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
internal static extern IntPtr ON_Extrusion_CreatePipe(ref Cylinder cylinder, double otherRadius, [MarshalAs(UnmanagedType.U1)]bool capBottom, [MarshalAs(UnmanagedType.U1)]bool capTop);
/// <summary> /// Constructs a new demo. /// </summary> /// <param name="game">Game owning this demo.</param> public ReverseTrikeDemo(DemosGame game) : base(game) { game.Camera.Position = new Vector3(0, 2, 15); Space.Add(new Box(new Vector3(0, -5, 0), 20, 1, 20)); var body = new Box(new Vector3(0, 0, 0), 2, 1, 3, 10); body.CollisionInformation.LocalPosition = new Vector3(0, .8f, 0); Space.Add(body); #region First Wheel var wheel = new Cylinder(body.Position + new Vector3(-1.3f, 0, -1.5f), .2f, .5f, 4); wheel.Material = new Material(1.5f, 1.5f, 0); wheel.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Forward, MathHelper.PiOver2); //Preventing the occasional pointless collision pair can speed things up. CollisionRules.AddRule(body, wheel, CollisionRule.NoBroadPhase); //Connect the wheel to the body. var ballSocketJoint = new BallSocketJoint(body, wheel, wheel.Position); var swivelHingeAngularJoint = new SwivelHingeAngularJoint(body, wheel, Vector3.Up, Vector3.Right); //Motorize the wheel. drivingMotor1 = new RevoluteMotor(body, wheel, Vector3.Left); drivingMotor1.Settings.VelocityMotor.Softness = .2f; //Let it roll when the user isn't giving specific commands. drivingMotor1.IsActive = false; steeringMotor1 = new RevoluteMotor(body, wheel, Vector3.Up); steeringMotor1.Settings.Mode = MotorMode.Servomechanism; //The constructor makes a guess about how to set up the constraint. //It can't always be right since it doesn't have all the information; //in this case, it chooses the basis and test axis incorrectly. //This leads to a 'flipping' behavior when the wheel is rolling //(the test axis is 'rolling' with the wheel, and passes over //a singularity which causes a flip). //To fix this, we configure the constraint directly. //The basis is aligned with how the wheel is set up; we choose 'up' as //the motorized axis, and right/forward to define the angle measurement plane. //The test axis is set to be perpendicular to the wheel's rotation so that //it only measures the steering angle. //If you're curious, the angle measurement is just a Math.Atan2. //The current world test axis is dotted against the two plane axes (Right and Forward here). //This gives an x and y value. These can be plugged into Atan2 just like when //you compute an angle on a normal 2d graph. steeringMotor1.Basis.SetWorldAxes(Vector3.Up, Vector3.Right); steeringMotor1.TestAxis = Vector3.Right; //Add the wheel and connection to the space. Space.Add(wheel); Space.Add(ballSocketJoint); Space.Add(swivelHingeAngularJoint); Space.Add(drivingMotor1); Space.Add(steeringMotor1); #endregion #region Second Wheel wheel = new Cylinder(body.Position + new Vector3(1.3f, 0, -1.5f), .2f, .5f, 4); wheel.Material = new Material(1.5f, 1.5f, 0); wheel.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Forward, MathHelper.PiOver2); //Preventing the occasional pointless collision pair can speed things up. CollisionRules.AddRule(body, wheel, CollisionRule.NoBroadPhase); //Connect the wheel to the body. ballSocketJoint = new BallSocketJoint(body, wheel, wheel.Position); swivelHingeAngularJoint = new SwivelHingeAngularJoint(body, wheel, Vector3.Up, Vector3.Right); //Motorize the wheel. drivingMotor2 = new RevoluteMotor(body, wheel, Vector3.Left); drivingMotor2.Settings.VelocityMotor.Softness = .2f; //Let it roll when the user isn't giving specific commands. drivingMotor2.IsActive = false; steeringMotor2 = new RevoluteMotor(body, wheel, Vector3.Up); steeringMotor2.Settings.Mode = MotorMode.Servomechanism; //Configure the motor. See wheel 1 for more description. steeringMotor2.Basis.SetWorldAxes(Vector3.Up, Vector3.Right); steeringMotor2.TestAxis = Vector3.Right; //Add the wheel and connection to the space. Space.Add(wheel); Space.Add(ballSocketJoint); Space.Add(swivelHingeAngularJoint); Space.Add(drivingMotor2); Space.Add(steeringMotor2); #endregion #region Third Wheel wheel = new Cylinder(body.Position + new Vector3(0, -.3f, 1.5f), .2f, .5f, 4); wheel.Material = new Material(1.5f, 1.5f, 0); wheel.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Forward, MathHelper.PiOver2); //Preventing the occasional pointless collision pair can speed things up. CollisionRules.AddRule(body, wheel, CollisionRule.NoBroadPhase); //Connect the wheel to the body. ballSocketJoint = new BallSocketJoint(body, wheel, wheel.Position); //Notice that the third wheel isn't a swivel hinge, it's just a revolute axis. //This lets it roll, but prevents flopping around like the wheels of a grocery cart. //Could have used a RevoluteJoint solver group here, but this shows it's possible to do //the same things without using the combo-constraints. var revoluteAngularJoint = new RevoluteAngularJoint(body, wheel, Vector3.Right); //Add the wheel and connection to the space. Space.Add(wheel); Space.Add(ballSocketJoint); Space.Add(revoluteAngularJoint); #endregion int xLength = 180; int zLength = 180; float xSpacing = 8f; float zSpacing = 8f; var heights = new float[xLength, zLength]; for (int i = 0; i < xLength; i++) { for (int j = 0; j < zLength; j++) { float x = i - xLength / 2; float z = j - zLength / 2; //heights[i,j] = (float)(x * y / 1000f); heights[i, j] = (float)(10 * (Math.Sin(x / 8) + Math.Sin(z / 8))); //heights[i,j] = 3 * (float)Math.Sin(x * y / 100f); //heights[i,j] = (x * x * x * y - y * y * y * x) / 1000f; } } //Create the terrain. var terrain = new Terrain(heights, new AffineTransform( new Vector3(xSpacing, 1, zSpacing), Quaternion.Identity, new Vector3(-xLength * xSpacing / 2, -10, -zLength * zSpacing / 2))); Space.Add(terrain); game.ModelDrawer.Add(terrain); }
internal static extern bool ON_Surface_IsCylinder(IntPtr pConstSurface, ref Cylinder cylinder, double tolerance, [MarshalAs(UnmanagedType.U1)]bool computeCylinder);
internal static extern IntPtr ON_Cylinder_RevSurfaceForm(ref Cylinder cylinder);
internal static extern bool ON_TextureMapping_SetCylinderMapping(IntPtr pTextureMapping, ref Cylinder pCylinder, [MarshalAs(UnmanagedType.U1)]bool capped);
internal static extern int ON_Intersect_LineCylinder(ref Line line, ref Cylinder cylinder, ref Point3d point1, ref Point3d point2);
internal static extern IntPtr ON_Brep_FromCylinder(ref Cylinder cylinder, [MarshalAs(UnmanagedType.U1)]bool capBottom, [MarshalAs(UnmanagedType.U1)]bool capTop);