/// <summary> /// Called when it is time to draw a frame. /// </summary> public override void Draw() { // Clears the background Display.ClearBuffers(); Display.Shader = SceneShader; // Draws with the index buffer SceneShader.SetUniform("modelview_matrix", ModelViewMatrix); SceneShader.SetUniform("projection_matrix", ProjectionMatrix); Vector3 Position = new Vector3(0.0f, 0.0f, -5.0f); SceneShader.SetUniform("mvp_matrix", Matrix4.CreateTranslation(Position) * ModelViewMatrix * ProjectionMatrix); Plane.Draw(); SceneShader.SetUniform("mvp_matrix", Matrix4.CreateRotationY(Yaw) * ModelViewMatrix * ProjectionMatrix); Torus.Draw(); // Some dummy text SpriteBatch.Begin(); SpriteBatch.DrawString(Font, new Vector2(10, 15), Color.White, "Here's an example of shadow mapping."); SpriteBatch.End(); }
public void SetTorus(int Segments, int CurveIncrement, int TubeIncrement, float MajorRadius, float MinorRadius, float Rotation) { this.Segments = Segments + 1; CurveSegments = CurveIncrement; tubeIncrement = TubeIncrement; this.MajorRadius = MajorRadius; minorRadius = MinorRadius; this.Rotation = Rotation; GenerateMesh(); //Set this tubesegment as a child to it's pivot, so it can be turned from a pivot not centered on the object pivot = transform.parent; //Allign this tube segment so the pivot is in the center of the opening of the tube transform.localPosition -= new Vector3(MajorRadius, 0, 0); connector = new GameObject("Connector").transform; connector.SetParent(transform); float curveAngle = 2f * Mathf.PI / (float)CurveSegments; //Set the connector object at the center of the end pipe connector.localPosition = Torus.PointOnCurve(curveAngle * Segments); //Turn the connector to face out the pipe connector.localRotation = Quaternion.Euler(0, 0, (Segments / (float)CurveSegments) * 360f); RadiansCovered = Segments * curveAngle; }
public static Bowl CreateRoundRimmedBowl(double innerRadius, double outerRadius, IMaterial material) { ConvexPartSphere o = new ConvexPartSphere(new Vec3(), outerRadius, 0, 360, 90, 180); ConvexPartSphere i = new ConvexPartSphere(new Vec3(), innerRadius, 0, 360, 90, 180); Torus t = new Torus((outerRadius + innerRadius) / 2, (outerRadius - innerRadius) / 2); Bowl b = new Bowl(); b.AddObject(o); b.AddObject(i); b.AddObject(t); b.bbox = new BBox(-outerRadius, outerRadius, -outerRadius, outerRadius, -outerRadius, outerRadius); b.Material = material; return(b); }
protected override DX11IndexedGeometry GetGeom(DX11RenderContext context, int slice) { Torus t = new Torus(this.FResX[slice], this.FResY[slice], this.FSize[slice], this.FThick[slice], this.FPY[slice], this.FPX[slice], this.FPR[slice], this.FCY[slice]); return(context.Primitives.Torus(t)); }
public static void Run() { // The path to the documents directory. // Load a 3D file Scene scene = new Scene(RunExamples.GetDataFilePath("test.fbx")); // Initialize Node class object Node cubeNode = new Node("torus"); // ExStart:ConvertTorusPrimitivetoMesh // Initialize object by Torus class IMeshConvertible convertible = new Torus(); // Convert a Torus to Mesh Mesh mesh = convertible.ToMesh(); // ExEnd:ConvertTorusPrimitivetoMesh // 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. var output = RunExamples.GetOutputFilePath("TorusToMeshScene.fbx"); // Save 3D scene in the supported file formats scene.Save(output, FileFormat.FBX7400ASCII); Console.WriteLine("\n Converted the primitive Torus to a mesh successfully.\nFile saved at " + output); }
/// <summary> /// Unload contents /// </summary> public override void UnloadContent() { if (Font != null) { Font.Dispose(); } Font = null; if (Shader != null) { Shader.Dispose(); } Shader = null; if (Sprite != null) { Sprite.Dispose(); } Sprite = null; if (Trefoil != null) { Trefoil.Dispose(); } Trefoil = null; if (Torus != null) { Torus.Dispose(); } Torus = null; }
/// <summary> /// Called when it is time to draw a frame. /// </summary> public override void Draw() { // Clears the background Display.ClearBuffers(); // Aplly a rotation Matrix4 mvp = Matrix4.CreateRotationY(Yaw) * ModelViewMatrix * ProjectionMatrix; Display.Shader = Shader; // Uniforms Shader.SetUniform("modelview", mvp); Shader.SetUniform("DiffuseMaterial", new float[] { 0.0f, 0.75f, 0.75f }); Shader.SetUniform("LightPosition", new float[] { 0.25f, 0.25f, -1.0f }); Shader.SetUniform("AmbientMaterial", new float[] { 0.04f, 0.04f, 0.04f }); Shader.SetUniform("SpecularMaterial", new float[] { 0.5f, 0.5f, 0.5f }); Shader.SetUniform("Shininess", 50.0f); if (swap) { Torus.Draw(); } else { Trefoil.Draw(); } // Some dummy text Sprite.Begin(); Sprite.DrawString(Font, new Vector2(50, 25), Color.White, "Here's an example of draw buffers."); Sprite.DrawString(Font, new Vector2(50, 50), Color.White, "Press space key to swap mesh."); Sprite.End(); }
public void Update() { var player = getPlayerTransform(); var transform = getCameraTransform(); Vector3 playerPosition = player.position; Torus.GetPoint(playerPosition, out TorusPointInfo pInfo); Vector3 slope = -pInfo.minorCenterUp; Vector3 playerUp = -pInfo.minorCenterForward; Vector3 playerRight = -pInfo.minorCenterRight; Vector3 targetPosition = playerPosition + slope * config.offset.z + playerUp * config.offset.y; if (Application.isPlaying) { transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, config.smoothTime); } else { transform.position = targetPosition; } var lookAtTarget = playerPosition + slope * config.lootAtOffset.z + playerUp * config.lootAtOffset.y; var lookAt = (lookAtTarget - transform.position).normalized; var up = Vector3.Cross(playerRight, lookAt); if (Application.isPlaying) { transform.rotation = QuaternionUtil.SmoothDamp(transform.rotation, Quaternion.LookRotation(lookAt, up), ref quaternionDeriv, config.smoothTime); } else { transform.rotation = Quaternion.LookRotation(lookAt, up); } }
public static void Run() { // The path to the documents directory. string MyDir = RunExamples.GetDataDir(); MyDir = MyDir + "test.fbx"; // Load a 3D file Scene scene = new Scene(MyDir); // Initialize Node class object Node cubeNode = new Node("torus"); // ExStart:ConvertTorusPrimitivetoMesh // Initialize object by Torus class IMeshConvertible convertible = new Torus(); // Convert a Torus to Mesh Mesh mesh = convertible.ToMesh(); // ExEnd:ConvertTorusPrimitivetoMesh // 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. MyDir = RunExamples.GetDataDir() + RunExamples.GetOutputFilePath("TorusToMeshScene.fbx"); // Save 3D scene in the supported file formats scene.Save(MyDir, FileFormat.FBX7400ASCII); Console.WriteLine("\n Converted the primitive Torus to a mesh successfully.\nFile saved at " + MyDir); }
//Function to find the start angle of the torus private Vector3D findStartAngle(Torus FSA_tori, Plane FSA_startPlane, Plane FSA_endPlane, bool startplane_rev, bool endplane_rev, out double FSA_anglediff) { // Create vector3D of the normal to the plane the tori sits in Vector3D newZ = new Vector3D(FSA_tori.Frame.DirZ.UnitVector.X, FSA_tori.Frame.DirZ.UnitVector.Y, FSA_tori.Frame.DirZ.UnitVector.Z); // Create vector3d of the starting plane normal Vector3D start_planeNorm = new Vector3D(FSA_startPlane.Frame.DirZ.UnitVector.X, FSA_startPlane.Frame.DirZ.UnitVector.Y, FSA_startPlane.Frame.DirZ.UnitVector.Z); // Create vector3d of the end plane normal Vector3D end_planeNorm = new Vector3D(FSA_endPlane.Frame.DirZ.UnitVector.X, FSA_endPlane.Frame.DirZ.UnitVector.Y, FSA_endPlane.Frame.DirZ.UnitVector.Z); // Check the direction of the vectors and modify if they both point out of the body or into the body if ((startplane_rev && endplane_rev) || (!startplane_rev && !endplane_rev)) { end_planeNorm = end_planeNorm * -1.0; endplane_rev = !endplane_rev; } // Use atan2 to aquire the angle between the two planes (with direction) FSA_anglediff = Math.Atan2(Vector3D.DotProduct(newZ, Vector3D.CrossProduct(start_planeNorm, end_planeNorm)), Vector3D.DotProduct(start_planeNorm, end_planeNorm)); // Find the unit vector in the direction of the starting plane Vector3D FSA_newstartVec = Vector3D.CrossProduct(newZ, start_planeNorm); //Check to make sure the starting vector points in the correct direction if (reverse_line(FSA_newstartVec, endplane_rev, end_planeNorm)) { FSA_newstartVec = FSA_newstartVec * -1.0; } // Pass back the unit vector in the direction of the starting plane return(FSA_newstartVec); }
public static void test46() //****************************************************************************80 // // Purpose: // // TEST46 tests TORUS_5S2, TORUS_6S2 and TORUS_14S. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 03 April 2008 // // Author: // // John Burkardt // { int i; string name = ""; const double r1 = 0.5; const double r2 = 1.0; Console.WriteLine(""); Console.WriteLine("TEST46"); Console.WriteLine(" For the interior of a torus,"); Console.WriteLine(" TORUS_5S2,"); Console.WriteLine(" TORUS_6S2, and"); Console.WriteLine(" TORUS_5S2 approximate integrals."); Console.WriteLine(""); Console.WriteLine(" Inner radius = " + r1 + ""); Console.WriteLine(" Outer radius = " + r2 + ""); Console.WriteLine(" Volume = " + Torus.torus_volume_3d(r1, r2) + ""); Console.WriteLine(""); Console.WriteLine(" Rule: #5S2 #6S2 #14S"); Console.WriteLine(" F(X)"); Console.WriteLine(""); int num = functions.function_3d_num(); for (i = 1; i <= num; i++) { int function_3d_index = i; functions.function_3d_name(function_3d_index, ref name); double result1 = Torus.torus_5s2(function_3d_index, functions.function_3d, r1, r2); double result2 = Torus.torus_6s2(function_3d_index, functions.function_3d, r1, r2); double result3 = Torus.torus_14s(function_3d_index, functions.function_3d, r1, r2); Console.WriteLine(" " + name + " " + result1.ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + result2.ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + result3.ToString(CultureInfo.InvariantCulture).PadLeft(14) + ""); } }
public void TestBasic() { var torus = new Torus(); Check.That(torus.Type).IsEqualTo("torus"); Check.That(torus.MinorRadius).IsEqualTo(0.5); Check.That(torus.MajorRadius).IsEqualTo(1); }
public void TestTorusToPovCode() { var torus = new Torus("MyTorus") { MajorRadius = 5, MinorRadius = 3 }; var povCode = torus.ToPovCode(); Check.That(povCode).IsEqualTo("torus {\n 5, 3\n}"); }
public void createTorus() { Torus torus = new Torus("newobject"); torus.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f); torus.transform.parent = father.transform; torus.transform.position = spawn.position; torus.transform.rotation = spawn.rotation; Global.objDict.Add(torus.Id, torus); }
public static void test47() //****************************************************************************80 // // Purpose: // // TEST47 tests TORUS_SQUARE_5C2 and TORUS_SQUARE_14C. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 03 April 2008 // // Author: // // John Burkardt // { int i; string name = ""; const double r1 = 1.0; const double r2 = 0.125; Console.WriteLine(""); Console.WriteLine("TEST47"); Console.WriteLine(" For integrals inside a torus with square cross-section:"); Console.WriteLine(" TORUS_SQUARE_5C2 approximates the integral;"); Console.WriteLine(" TORUS_SQUARE_14C approximates the integral."); Console.WriteLine(""); Console.WriteLine(" Inner radius = " + r1 + ""); Console.WriteLine(" Outer radius = " + r2 + ""); Console.WriteLine(" Volume = " + Torus.torus_square_volume_3d(r1, r2) + ""); Console.WriteLine(""); Console.WriteLine(" F(X) 5C2 14C"); Console.WriteLine(""); int num = functions.function_3d_num(); for (i = 1; i <= num; i++) { int function_3d_index = i; functions.function_3d_name(function_3d_index, ref name); double result1 = Torus.torus_square_5c2(function_3d_index, functions.function_3d, r1, r2); double result2 = Torus.torus_square_14c(function_3d_index, functions.function_3d, r1, r2); Console.WriteLine(" " + name + " " + result1.ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + result2.ToString(CultureInfo.InvariantCulture).PadLeft(14) + ""); } }
protected override void OnInit(object sender, EventArgs e) { FixedNode fNode = new FixedNode(); Camera.LookAt(Vector3.Zero, new Vector3(0, 0, -10f)); DeviceContext.Immediate.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; torus = new Torus(5f, 0.25f, 256, 64); RenderableNode rNode = new RenderableNode(torus); fNode.AppendChild(rNode); Box box = new Box(1f); RenderableNode rNodeBox = new RenderableNode(box); //fNode.AppendChild(rNodeBox); //for (int i = 0; i < 10; i++) //{ // Quad quad = new Quad(); // quad.PositionV3 = new Vector3(0 + 1f * i, 0, -1f*i); // RenderableNode rNode = new RenderableNode(quad); // fNode.AppendChild(rNode); //} //for (int i = 0; i < 10; i++) //{ // Quad quad = new Quad(); // quad.PositionV3 = new Vector3(0 + 1f * i, 0.5f, -1.5f * i); // ((IColorMaterial)quad.Material).DiffuseColor = new Color4(1f, 0, 0); // RenderableNode rNode = new RenderableNode(quad); // fNode.AppendChild(rNode); //} Scene.Tree.RootNode.AppendChild(fNode); Scene.BuildRenderScene(); Hud = Hud.FromDescription(Game.Context.Device, new HudDescription( width: Game.Context.Settings.ScreenWidth, height: Game.Context.Settings.ScreenHeight, zNear: Game.CurrentRenderer.Camera.NearClip, zFar: Game.CurrentRenderer.Camera.FarClip, cameraEnabled: true, multithreaded: true )); OdysseyUI.CurrentHud = Hud; Game.Logger.Activate(); Hud.BeginDesign(); Hud.Init(); Hud.EndDesign(); }
void OnWizardCreate() { //float diameter = radius * 2f; //float circumference = Mathf.PI * diameter; //float interval = 360f / (circumference / (thickness * 2f)); GameObject torus = new GameObject("Torus"); Torus.CreateTorusMesh(torus, radius, thickness, color, tubes); Selection.activeObject = torus; }
public void TestConstructor() { var torus = new Torus("MyTorus") { MajorRadius = 5, MinorRadius = 3 }; Check.That(torus.Type).IsEqualTo("torus"); Check.That(torus.Name).IsEqualTo("MyTorus"); Check.That(torus.MajorRadius).IsEqualTo(5); Check.That(torus.MinorRadius).IsEqualTo(3); }
Vector4 calculateTorusPoint(int i) { float alpha = 6.28318530718f * (i / (float)ELEMENTS); float voltage = Mathf.Sin(((alpha + (Time.time * speed)) * (constantCurrent ? frequencyOverTotalLength : numberOfWinds))); //alpha += (Time.time * speed); //alpha %= 6.28f; float wind = alpha * numberOfWinds; Vector3 torusPoint = Torus.encodeToThreeTorus(alpha, wind); return(new Vector4(torusPoint.x, torusPoint.z, torusPoint.y, voltage)); }
void Update() { if (target) { Torus.GetPoint(target.position, out TorusPointInfo pInfo); transform.position = pInfo.targetPoint + pInfo.minorCenterForward * offset.y + pInfo.minorCenterRight * offset.x + pInfo.minorCenterUp * offset.z; transform.LookAt(target); } else { GameMain.ErrorTracking.Add($"{nameof(target)} not set on {nameof(DirectionalLightFollowPlayer)} GameObject={name}"); } }
Vector4 calculateTorusPoint(int i) { float alpha = 6.28318530718f * (i / 1024f); float voltage = Mathf.Sin((alpha * windingNumber)); alpha += (Time.time * speed); //alpha %= 6.28f; float wind = alpha * windingNumber; Vector3 torusPoint = Torus.encodeToThreeTorus(alpha, wind); return(new Vector4(torusPoint.x, torusPoint.z, torusPoint.y, voltage)); }
void GenerateMesh() { //Create a new mesh Mesh mesh = new Mesh(); mesh.name = "TubeMesh"; //Pass the mesh to this object's meshFilter meshFilter.mesh = mesh; List <Vector3> vertices = new List <Vector3>(); Torus = new Torus { MajorRadius = MajorRadius, MinorRadius = minorRadius }; float curveAngle = 2f * Mathf.PI / (float)CurveSegments; float pipeAngle = 2f * Mathf.PI / (float)tubeIncrement; for (int i = 0; i < Segments; i++) { for (int j = 0; j < tubeIncrement; j++) { vertices.Add(Torus.PointOnTorus(i * curveAngle, j * pipeAngle)); } } mesh.vertices = vertices.ToArray(); List <int> triangles = new List <int>(); for (int i = 1; i < Segments; i++) { for (int j = 0; j < tubeIncrement; j++) { int row = i * tubeIncrement; int lastRow = (i - 1) * tubeIncrement; int column = j; int nextColumn = (j + 1) % tubeIncrement; //Make the triangles in reverse order to invert the normals //Make a triangle with the vertex one row behind this one and the vertex one row behind and one column over triangles.Add(lastRow + column); triangles.Add(lastRow + nextColumn); triangles.Add(row + column); //Make a triangle with the vertex one column over and the vertex one row behind and one column over triangles.Add(lastRow + nextColumn); triangles.Add(row + nextColumn); triangles.Add(row + column); } } mesh.triangles = triangles.ToArray(); mesh.RecalculateNormals(); }
//private float orbitDistance; // Use this for initialization protected override void Start() { base.Start(); if (this.orbitCenter != null) { float orbitDistance = Mathf.Abs(Vector3.Distance(this.gameObject.transform.position, this.orbitCenter.transform.position)); this.torus = new GameObject(); this.torus.transform.position = this.orbitCenter.transform.position; Torus.CreateTorusMesh(this.torus, orbitDistance, 0.007f, Color.white); } }
public static void Main(string[] Args) { // base class Shape3d basic = new Shape3d(); // tori Torus torus1 = new Torus(10, 5, new Vector3(25, 2, -3)); Torus torus2 = new Torus(5, 5); Torus torus3 = new Torus(5, 10); // dodecahedron Dodecahedron dodeceda = new Dodecahedron(15, new Vector3(420, 420, 420)); // triangular prism Triangularprism prism1 = new Triangularprism(10, 9, 5, 25); Triangularprism prism2 = new Triangularprism(3, 3, 3, 25, new Vector3(1, 2, 3)); // show casing them, does not give any errors ArrayList shapesList = new ArrayList(); // shapesList.Add(basic); // shapesList.Add(torus1); // shapesList.Add(torus2); // shapesList.Add(torus3); // shapesList.Add(dodeceda); // shapesList.Add(prism1); // shapesList.Add(prism2); foreach (Shape3d shape in shapesList) { shape.draw(); Console.WriteLine(""); } // accessing the getter / setter of a class // Console.WriteLine("The lateral surface area of prism1 is {0}", prism1.lateralsurfacearea); /* --------- PROBLEMATIC SHAPES, UNCOMMENT AT OWN RISK --------- */ // tori // Torus err_torus1 = new Torus(10, 0); // Torus err_torus2 = new Torus(0, 5); // dodecahedron // Dodecahedron err_dodeceda = new Dodecahedron(-5); // triangular prism // Triangularprism err_prism1 = new Triangularprism(10, 1, 1, 25); // Triangularprism err_prism2 = new Triangularprism(1, 10, 1, 25); // Triangularprism err_prism3 = new Triangularprism(1, 1, 10, 25); }
// Use this for initialization void Start() { Runner = GameObject.Find("Runner"); FiveCell = GameObject.Find("5-Cell"); A = FiveCell.GetComponent <Renderer> (); EightCell = GameObject.Find("8-Cell"); B = EightCell.GetComponent <Renderer> (); RP2 = GameObject.Find("RP2"); C = RP2.GetComponent <Renderer> (); RP2cut = GameObject.Find("RP2 Cut Open"); D = RP2cut.GetComponent <Renderer> (); Torus = GameObject.Find("Torus"); E = Torus.GetComponent <Renderer> (); M = Runner.GetComponent <MeshLoader>(); }
public void Update() { Reset(); if (Application.isPlaying && playerPhysicsConfig.enableMove) { Collide(); Rotate(); Move(); } else { Torus.GetPoint(playerPhysicsConfig.debugMajorAngle, playerPhysicsConfig.debugMinorAngle, out TorusPointInfo pInfo); transform.position = pInfo.targetPoint; transform.rotation = Quaternion.LookRotation(-pInfo.minorCenterUp, -pInfo.minorCenterForward); } }
private SDF ACube() { SDF obj = new Cylinder(25f, 125f); var c1 = new Cylinder(25f, 125f); var c2 = new Rotation(c1, 90, 0, 0); var c3 = new Rotation(c1, 0, 0, 90); var cylinders = new Union(c1, new Union(c2, c3)); var t1 = new Torus(24f, 5f); var t2 = new Rotation(t1, 90, 0, 0); var t3 = new Rotation(t1, 0, 0, 90); var torus = new Union(t1, new Union(t2, t3)); SDF cube = new Cube(75f); cube = new Subtraction(cube, cylinders); return(new Union(cube, torus)); }
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 PrepareForConfigGeneration() { if (Topology == TopologiesTypes.Mesh) { Mesh NewMesh = new Mesh(Int32.Parse(TopologyArguments[0]), Int32.Parse(TopologyArguments[1])); NewMesh.CreateNetlist(); NewMesh.CreateRouting(Algorithm); TopologyNetlist = Common.MatrixToString(NewMesh.GetNetlist()); TopologyRouting = Common.MatrixToString(NewMesh.GetRouting()); TopologyDescription = Topology + "-(" + TopologyArguments[0] + ", " + TopologyArguments[1] + ")"; } else if (Topology == TopologiesTypes.Torus) { Torus NewTorus = new Torus(Int32.Parse(TopologyArguments[0]), Int32.Parse(TopologyArguments[1])); NewTorus.CreateNetlist(); NewTorus.CreateRouting(); TopologyNetlist = Common.MatrixToString(NewTorus.GetNetlist()); TopologyRouting = Common.MatrixToString(NewTorus.GetRouting()); TopologyDescription = Topology + "-(" + TopologyArguments[0] + ", " + TopologyArguments[1] + ")"; } else if (Topology == TopologiesTypes.Circulant) { Circulant NewCirculant = new Circulant(Int32.Parse(TopologyArguments[0]), Int32.Parse(TopologyArguments[1]), Int32.Parse(TopologyArguments[2])); NewCirculant.CreateNetlist(); NewCirculant.CreateRouting(NewCirculant.AdjacencyMatrix(NewCirculant.GetNetlist(), Int32.Parse(TopologyArguments[0])), NewCirculant.GetNetlist(), Algorithm, AlgorithmArguments); TopologyNetlist = Common.MatrixToString(NewCirculant.GetNetlist()); TopologyRouting = Common.MatrixToString(NewCirculant.GetRouting()); TopologyDescription = Topology + "-(" + TopologyArguments[0] + ", " + TopologyArguments[1] + ", " + TopologyArguments[2] + ")"; } else if (Topology == TopologiesTypes.OptimalCirculant) { Circulant NewCirculant = new Circulant(Int32.Parse(TopologyArguments[0])); NewCirculant.CreateNetlist(); NewCirculant.CreateRouting(NewCirculant.AdjacencyMatrix(NewCirculant.GetNetlist(), Int32.Parse(TopologyArguments[0])), NewCirculant.GetNetlist(), Algorithm, AlgorithmArguments); TopologyNetlist = Common.MatrixToString(NewCirculant.GetNetlist()); TopologyRouting = Common.MatrixToString(NewCirculant.GetRouting()); TopologyDescription = Topology + "-(" + TopologyArguments[0] + ", " + NewCirculant.S1.ToString() + ", " + NewCirculant.S2.ToString() + ")"; } }
public override void Build() { vp = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT); vp.NumSamples = 4; backgroundColor = ColorUtils.BLACK; tracer = new RayCast(this); Ambient a = new Ambient(); a.ScaleRadiance = 1.0f; AmbientLight = a; Pinhole pinhole = new Pinhole(new Vec3(0.0, 80.0, 210), new Vec3(0.0, 0.0, 0.0), new Vec3(0.0, 1.0, 0.0), 500); Camera = pinhole; PointLight l = new PointLight(); l.Color = ColorUtils.WHITE; l.SetLocation(100, 100, 200); l.ScaleRadiance = 3.0f; l.Shadows = true; AddLight(l); Phong m = new Phong(); m.SetColor(ColorUtils.BLUE); m.SetKa(0.2f); m.SetKd(0.65f); m.SetKs(0.4f); m.SetExp(64.0f); Torus t = new Torus(45, 1); t.Material = m; AddObject(t); }
private void OnLoaded(object sender, RoutedEventArgs e) { Torus torus = new Torus("torus", 2f, 0.5f, 4, 4); Camera camera = new Camera( "camera", new DenseVector(new[] { 0f, 0f, 5f, 1f }), new DenseVector(new[] { 0f, 0f, 0f, 0f }), 0.1f, 10f, 60f, (float)SceneCanvas.ActualWidth, (float)SceneCanvas.ActualHeight ); _sceneViewModel = new SceneViewModel(SceneCanvas); _sceneViewModel.Add(camera); _sceneViewModel.Add(torus); GeometryListBox.DataContext = _sceneViewModel; }
public static Bowl Create(double innerRadius, double outerRadius, bool roundRimmedBowl, IMaterial material) { ConvexPartSphere o = new ConvexPartSphere(new Vec3(), outerRadius, 0, 360, 90, 180); ConvexPartSphere i = new ConvexPartSphere(new Vec3(), innerRadius, 0, 360, 90, 180); Bowl b = new Bowl(); b.AddObject(o); b.AddObject(i); if (roundRimmedBowl) { Torus t = new Torus((outerRadius + innerRadius) / 2, (outerRadius - innerRadius) / 2); b.AddObject(t); } else { Annulus a = new Annulus(new Vec3(), new Vec3(0, 1, 0), innerRadius, outerRadius); b.AddObject(a); } b.bbox = new BBox(-outerRadius, outerRadius, -outerRadius, outerRadius, -outerRadius, outerRadius); b.Material = material; return(b); }
internal static extern bool ON_Surface_IsTorus(IntPtr pConstSurface, ref Torus torus, double tolerance, [MarshalAs(UnmanagedType.U1)]bool computeTorus);
internal static extern IntPtr ON_Torus_RevSurfaceForm(ref Torus torus);
internal static extern IntPtr ON_Torus_GetNurbForm(ref Torus torus);
/// <summary> /// Test scene for Toruses by Jan Navratil, (c) 2012 /// </summary> public static void Toroids( IRayScene sc ) { Debug.Assert( sc != null ); // CSG scene: CSGInnerNode root = new CSGInnerNode( SetOperation.Union ); root.SetAttribute( PropertyName.REFLECTANCE_MODEL, new PhongModel() ); root.SetAttribute( PropertyName.MATERIAL, new PhongMaterial( new double[] { 0.5, 0.5, 0.5 }, 0.2, 0.7, 0.2, 16 ) ); sc.Intersectable = root; // Background color: sc.BackgroundColor = new double[] { 0.0, 0.15, 0.2 }; // Camera: sc.Camera = new StaticCamera( new Vector3d( 0.0, 0.0, -10.0 ), new Vector3d( 0.0, -0.04, 1.0 ), 60.0 ); // Light sources: sc.Sources = new LinkedList<ILightSource>(); sc.Sources.Add( new AmbientLightSource( 1.8 ) ); sc.Sources.Add( new PointLightSource( new Vector3d( -5.0, 3.0, -3.0 ), 2.0 ) ); // --- NODE DEFINITIONS ---------------------------------------------------- Sphere s; Torus t; t = new Torus( 2.0, 1.0 ); t.SetAttribute( PropertyName.COLOR, new double[] { 0, 0, 0.7 } ); t.SetAttribute( PropertyName.TEXTURE, new CheckerTexture( 50, 20, new double[] { 0.9, 0.9, 0 } ) ); root.InsertChild( t, Matrix4d.Scale( 0.8 ) * Matrix4d.CreateRotationX( 0.9 ) * Matrix4d.CreateTranslation( 2.7, 0.6, 0.0 ) ); t = new Torus( 1.0, 1.5 ); t.SetAttribute( PropertyName.COLOR, new double[] { 1, 0, 0 } ); t.SetAttribute( PropertyName.TEXTURE, new CheckerTexture( 40, 40, new double[] { 0.8, 1.0, 1.0 } ) ); CSGInnerNode donut = new CSGInnerNode( SetOperation.Difference ); donut.InsertChild( t, Matrix4d.Identity ); s = new Sphere(); s.SetAttribute( PropertyName.COLOR, new double[] { 0.5, 0.5, 0.5 } ); s.SetAttribute( PropertyName.TEXTURE, new CheckerTexture( 100, 100, new double[] { 1, 0.5, 0 } ) ); donut.InsertChild( s, Matrix4d.Scale( 3 ) * Matrix4d.CreateTranslation( 0, -3, 0 ) ); root.InsertChild( donut, Matrix4d.CreateRotationX( 0.8 ) * Matrix4d.CreateTranslation( -2.5, 0.0, 0.0 ) ); int number = 14; for ( int i = 0; i < number; i++ ) { t = new Torus( 0.2, 0.01 + 0.185 * i / number ); t.SetAttribute( PropertyName.COLOR, new double[] { 1, 1, 1 } ); root.InsertChild( t, Matrix4d.CreateRotationX( 0.5 * i ) * Matrix4d.CreateTranslation( 10.0 * (1.0 * i / number) - 4.7, -2.5, 0 ) ); } }
internal static extern void CRhinoDisplayPipeline_DrawTorus(IntPtr pPipeline, ref Torus torus, int argb, int thickness);