本文整理汇总了C#中Cube类的典型用法代码示例。如果您正苦于以下问题:C# Cube类的具体用法?C# Cube怎么用?C# Cube使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Cube类属于命名空间,在下文中一共展示了Cube类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getCubeEffectDefinition
public static EffectDefinition getCubeEffectDefinition(Cube.CubeEffect_e effect)
{
if (EFFECT_DEFS.ContainsKey(effect)) {
return EFFECT_DEFS[effect];
}
return new EffectDefinition();
}
示例2: Main
static void Main(string[] args)
{
// Create four-element Shape array
Shape[] shapes = new Shape[4];
// Populate array with objects that implement Shape
shapes[0] = new Square(10); //length of side is 10
shapes[1] = new Circle(5); //radius is 5
shapes[2] = new Sphere(5); //radius is 5
shapes[3] = new Cube(10); //length of side is 10
// Process each element in array shapes
foreach (Shape shape in shapes)
{
if (shape is TwoDimensionalShape)
{
Console.WriteLine(shape);
Console.WriteLine("The area is {0:N} square units.", shape.Area);
Console.WriteLine();
}
else
{
// Downcast Shape reference to ThreeDimensionalShape
ThreeDimensionalShape Shape = (ThreeDimensionalShape)shape;
Console.WriteLine(shape);
Console.WriteLine("The area is {0:N} square units.", shape.Area);
Console.WriteLine("The volume is {0:N} cubic units.", Shape.Volume);
Console.WriteLine();
}
}
Console.Read();
}
示例3: MazeCube
/// <summary>
/// Default constructor
/// </summary>
/// <param name="cube">
/// A <see cref="Cube"/>
/// </param>
public MazeCube(Cube cube)
{
this.cube = cube;
cube.userData = this;
this.cube.TiltEvent += OnTilt;
this.cube.ButtonEvent += OnButton;
}
示例4: FormSceneSample
/// <summary>
/// Initializes a new instance of the <see cref="FormSceneSample"/> class.
/// </summary>
public FormSceneSample()
{
InitializeComponent();
sceneControl1.MouseDown += new MouseEventHandler(FormSceneSample_MouseDown);
sceneControl1.MouseMove += new MouseEventHandler(FormSceneSample_MouseMove);
sceneControl1.MouseUp += new MouseEventHandler(sceneControl1_MouseUp);
// Add some design-time primitives.
sceneControl1.Scene.SceneContainer.AddChild(new
UnU.OpenGL.SceneGraph.Primitives.Grid());
sceneControl1.Scene.SceneContainer.AddChild(new
UnU.OpenGL.SceneGraph.Primitives.Axies());
// Create a light.
Light light = new Light()
{
On = true,
Position = new Vertex(3, 10, 3),
GLCode = OpenGL.GL_LIGHT0
};
// Add the light.
sceneControl1.Scene.SceneContainer.AddChild(light);
// Create a sphere.
Cube cube = new Cube();
cube.AddEffect(arcBallEffect);
// Add it.
sceneControl1.Scene.SceneContainer.AddChild(cube);
// Add the root element to the tree.
AddElementToTree(sceneControl1.Scene.SceneContainer, treeView1.Nodes);
}
示例5: Calculate
public CubeMesh Calculate(ref int visualVertexCount, ref int collisionVertexCount, Cube[,,] cubes, CubeLegend cubeLegend, ColliderType colliderType, string cubeTag) {
// TODO: Put this back in when preprocessor directives are supported in Boo
// Use UNITY_EDITOR
//CubeGeneratorProgressEditor.ReportCube(chunk.gridPosition, gridPosition) if chunk
// TODO: Vector3i.zero
// TODO: Cached cube position of the chunk
var position = (indexes - (chunk.dimensionsInCubes * chunk.gridPosition)).ToVector3() * cubeSize;
var meshData = new CubeMesh();
if(!AdjacentCubeExistsInsideChunk(cubes, indexes.Down)) AddSide(Direction.Down, position, ref visualVertexCount, cubeLegend, meshData);
if(!AdjacentCubeExistsInsideChunk(cubes, indexes.Up)) AddSide(Direction.Up, position, ref visualVertexCount, cubeLegend, meshData);
if(!AdjacentCubeExistsInsideChunk(cubes, indexes.Right)) AddSide(Direction.Right, position, ref visualVertexCount, cubeLegend, meshData);
if(!AdjacentCubeExistsInsideChunk(cubes, indexes.Left)) AddSide(Direction.Left, position, ref visualVertexCount, cubeLegend, meshData);
if(!AdjacentCubeExistsInsideChunk(cubes, indexes.Front)) AddSide(Direction.Front, position, ref visualVertexCount, cubeLegend, meshData);
if(!AdjacentCubeExistsInsideChunk(cubes, indexes.Back)) AddSide(Direction.Back, position, ref visualVertexCount, cubeLegend, meshData);
if (cubeLegend.cubeDefinitions[type].hasCollision) {
if(colliderType == ColliderType.MeshColliderPerChunk) {
if(!AdjacentCubeExistsInsideChunkWithCollision(cubes, cubeLegend, indexes.Down)) AddCollisionSide(Direction.Down, position, ref collisionVertexCount, cubeLegend, meshData);
if(!AdjacentCubeExistsInsideChunkWithCollision(cubes, cubeLegend, indexes.Up)) AddCollisionSide(Direction.Up, position, ref collisionVertexCount, cubeLegend, meshData);
if(!AdjacentCubeExistsInsideChunkWithCollision(cubes, cubeLegend, indexes.Right)) AddCollisionSide(Direction.Right, position, ref collisionVertexCount, cubeLegend, meshData);
if(!AdjacentCubeExistsInsideChunkWithCollision(cubes, cubeLegend, indexes.Left)) AddCollisionSide(Direction.Left, position, ref collisionVertexCount, cubeLegend, meshData);
if(!AdjacentCubeExistsInsideChunkWithCollision(cubes, cubeLegend, indexes.Front)) AddCollisionSide(Direction.Front, position, ref collisionVertexCount, cubeLegend, meshData);
if(!AdjacentCubeExistsInsideChunkWithCollision(cubes, cubeLegend, indexes.Back)) AddCollisionSide(Direction.Back, position, ref collisionVertexCount, cubeLegend, meshData);
}
else if(colliderType == ColliderType.BoxColliderPerCube) {
// TODO: Defer this until the game objects are being created for async compatibility
// if(generateCollider) CreateCollision(cubeTag);
}
}
return meshData;
}
示例6: addEffect
public void addEffect(Cube.CubeEffect_e effect)
{
if (effects.Contains(effect)) {
return;
}
effects.Add(effect);
}
示例7: Configure
public void Configure()
{
Cube = FindObjectOfType<Cube>();
if ( Node == null ) return;
if ( Node.Type == NodeTypeEnum.Start )
{
var go = Instantiate( Cube.StartPointPrefab ) as GameObject;
if ( go != null )
{
go.transform.parent = transform;
go.transform.localPosition = Vector3.zero;
go.transform.localEulerAngles = new Vector3( -90, 0, 0 );
}
}
else if ( Node.Type == NodeTypeEnum.End )
{
var go = Instantiate( Cube.EndPointPrefab ) as GameObject;
if ( go != null )
{
go.transform.parent = transform;
go.transform.localPosition = Vector3.zero;
go.transform.localEulerAngles = new Vector3( -90, 0, 0 );
}
}
Node.Quad = this;
StartCoroutine( WaitForFrame() );
}
示例8: Main
static void Main(string[] args)
{
string command = Console.ReadLine();
while(command != "End")
{
string[] tokens = command.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
switch(tokens[0])
{
case "Cube":
Cube cube = new Cube(double.Parse(tokens[1]));
Console.WriteLine("{0:F3}", VolumeCalculator.CubeVolume(cube));
break;
case "Cylinder":
Cylinder cylinder = new Cylinder(double.Parse(tokens[1]), double.Parse(tokens[2]));
Console.WriteLine("{0:F3}", VolumeCalculator.CylinderVolume(cylinder));
break;
case "TrianglePrism":
TriangularPrism prism = new TriangularPrism(double.Parse(tokens[1]), double.Parse(tokens[2]),
double.Parse(tokens[3]));
Console.WriteLine("{0:F3}", VolumeCalculator.TriangularPrismVolume(prism));
break;
}
command = Console.ReadLine();
}
}
示例9: Solve
/// <summary>
/// Solves the cube and returns the list of the movements to be done.
/// </summary>
/// <returns>List of movements to be sent to the robot</returns>
public List<Movement> Solve(String inputCubeString)
{
// isto não existirá! é apenas para testarmos enviando como entrada do Solver um cubo em formato string
// para testarmos o algoritmo dos movimentos... na implementação final, esta linha
// No algoritmo real, passo da visão já fornecerá a estrutura do cubo montada
Cube = TranslateInputStringToCube(inputCubeString);
// valida o cubo, primeiramente
if (!Cube.Validate())
return new List<Movement>();
// traduz cubo para a entrada da DLL
inputCubeString = TranslateCubeToSolverInput(Cube);
// chama dll em C
String outputOfSolver = SolveRubikCube(inputCubeString);
// traduz movimentos retornados para uma lista de Movement (movements)
// os RotateFaceMovement.PositionFace não estão preenchidos, pois nesta etapa,
// ainda não se tem esta informação. eles serão preenchdiso no AdjustMovementsBasedOnTheClaws
List<Movement> movements = TranslateStringToListOfMovements(outputOfSolver);
// add rotation movements to bring faces to the robot claws
AdjustMovementsBasedOnTheClaws(movements);
return movements;
}
示例10: ToString
/// <summary>
/// Converts this object to an OpenSCAD script
/// </summary>
/// <returns>Script for this object</returns>
public override string ToString()
{
OSCADObject inner = new Cube(new Vector3(this.Size.X - WallThickness*2,
this.Size.Y - WallThickness*2,
this.Size.Z - WallThickness*2),
this.Center);
if (!this.Bottom && !this.Top)
{
((Cube)inner).Size.Z += WallThickness * 4;
}
else if (!this.Top)
{
((Cube)inner).Size.Z += WallThickness*2;
inner = inner.Translate(0, 0, WallThickness);
}
else if (!this.Bottom)
{
((Cube)inner).Size.Z += WallThickness*2;
inner = inner.Translate(0, 0, -WallThickness);
}
if (!this.Center)
{
inner = inner.Translate(this.WallThickness, this.WallThickness, this.WallThickness);
}
OSCADObject box = new Cube(this.Size, this.Center) - inner;
return box.ToString();
}
示例11: Robot
public Robot(World w, Vector2 pos)
{
cube = new Cube(new Vector3(pos.X, 0, pos.Y), RM.GetTexture("robot"));
Position = pos;
Direction = new Vector2(0, 0);
CanRun = false;
supportsCamera = true;
HudIcons.Add(new HudIcon() { text = "Robocam", texture = RM.GetTexture("camera"), Action = (() => w.ToggleCamera(this)) });
HudIcons.Add(new HudIcon() { text = "Move", texture = RM.GetTexture("arrowupicon"), Action = (() => moving = !moving) });
HudIcons.Add(new HudIcon() { text = "Turn left", texture = RM.GetTexture("arrowlefticon"), Action = (() => {
Matrix cameraRotation = Matrix.CreateRotationY(0.05f);
Vector3 rotTarget = LookDir.ToVector3();
var result = Vector3.Transform(rotTarget, cameraRotation);
LookDir = result.ToVector2();
lastCamDir = result;
}), OnDown = true });
HudIcons.Add(new HudIcon()
{
text = "Turn right",
texture = RM.GetTexture("arrowrighticon"),
Action = (() =>
{
Matrix cameraRotation = Matrix.CreateRotationY(-0.05f);
Vector3 rotTarget = LookDir.ToVector3();
var result = Vector3.Transform(rotTarget, cameraRotation);
LookDir = result.ToVector2();
lastCamDir = result;
}),
OnDown = true
});
HudIcons.Add(new HudIcon() { text = "Grab/drop", texture = RM.GetTexture("grabicon"), Action = ToggleGrab });
}
示例12: DrawTo
/// <summary>
/// Draws to the supplied cube.
/// </summary>
/// <param name='cube'>
/// The cube to which the room should be drawn.
/// </param>
public void DrawTo(Cube cube)
{
// draw the background
cube.FillScreen(bgColor);
// draw the center
cube.FillRect(passageColor, segmentSize, segmentSize, segmentSize, segmentSize);
// draw open passages
for (int i=0; i<entryStates.Length; i++)
{
if (entryStates[i] == EntryState.Closed) continue;
int x=segmentSize, y=segmentSize;
switch ((Cube.Side)i)
{
case Cube.Side.BOTTOM:
y = 2*segmentSize;
break;
case Cube.Side.LEFT:
x = 0;
break;
case Cube.Side.RIGHT:
x = 2*segmentSize;
break;
case Cube.Side.TOP:
y = 0;
break;
}
cube.FillRect(passageColor, x, y, segmentSize, segmentSize);
}
// paint the cube
cube.Paint();
}
示例13: Main
//TODO: fixup display of numbers to match .net
static void Main()
{
// Input the side:
System.Console.Write("Enter the side: ");
double side = 5;//double.Parse(System.Console.ReadLine());
// Compute the areas:
Square s = new Square(side);
Cube c = new Cube(side);
// Display the results:
System.Console.Write("Area of the square =");
System.Console.WriteLine(s.Area);
System.Console.Write("Area of the cube =");
System.Console.WriteLine(c.Area);
// System.Console.WriteLine();
// Input the area:
System.Console.Write("Enter the area: ");
double area = 125; //double.Parse(System.Console.ReadLine());
// Compute the sides:
s.Area = area;
c.Area = area * 6;
// Display the results:
System.Console.Write("Side of the square = ");
System.Console.WriteLine((int)s.side);
System.Console.Write("Side of the cube = ");
System.Console.WriteLine((int)c.side);
}
示例14: SideOf
public Cube.Side SideOf(Cube c)
{
if (this._neighbors[(int)Cube.Side.TOP] == c) return Cube.Side.TOP;
if (this._neighbors[(int)Cube.Side.RIGHT] == c) return Cube.Side.RIGHT;
if (this._neighbors[(int)Cube.Side.LEFT] == c) return Cube.Side.LEFT;
if (this._neighbors[(int)Cube.Side.BOTTOM] == c) return Cube.Side.BOTTOM;
return Cube.Side.NONE;
}
示例15: AlarmPanel
public AlarmPanel(Vector2 pos)
: base(pos)
{
workTime = 0;
cube = new Cube(new Vector3(pos.X, 0, pos.Y), RM.GetTexture("work"));
cube.ScaleVector = new Vector3(8, 1, 8);
cube.SetPosition(Position.ToVector3());
}