override protected void OnUserBeginTwoHandGrab( Vector3 primaryHand, Vector3 secondaryHand, bool secondaryHandInObject) { base.OnUserBeginTwoHandGrab(primaryHand, secondaryHand, secondaryHandInObject); m_LockedManipulationAxis = GetInferredManipulationAxis( primaryHand, secondaryHand, secondaryHandInObject); }
public _DragAvatar( OverlayState overlayState, T data = default, Axis?axis = null, Offset initialPosition = null, Offset dragStartPoint = null, Widget feedback = null, Offset feedbackOffset = null, _OnDragEnd onDragEnd = null ) { if (feedbackOffset == null) { feedbackOffset = Offset.zero; } D.assert(overlayState != null); this.overlayState = overlayState; this.data = data; this.axis = axis; this.dragStartPoint = dragStartPoint ?? Offset.zero; this.feedback = feedback; this.feedbackOffset = feedbackOffset ?? Offset.zero; this.onDragEnd = onDragEnd; _entry = new OverlayEntry(_build); this.overlayState.insert(_entry); _position = initialPosition ?? Offset.zero; updateDrag(initialPosition); }
public static Tensor reduce_variance(Tensor input_tensor, Axis?axis = null, bool keepdims = false, string name = null) { if (name == null) { name = "reduce_variance"; } // else {name = name;} return(tf_with(ops.name_scope(name, "reduce_variance", new[] { input_tensor }), scope => { var means = reduce_mean(input_tensor, axis: axis, keepdims: true); if (means.dtype.is_integer()) { throw new TypeError("Input must be either real or complex"); } var diff = input_tensor - means; Tensor squared_deviations; if (diff.dtype.is_complex()) { var real_dtype = diff.dtype.real_dtype(); squared_deviations = real( gen_math_ops.mul(conj(diff), diff)); } else { squared_deviations = gen_math_ops.square(diff); } return reduce_mean(squared_deviations, axis: axis, keepdims: keepdims); })); }
public static Matrix4 createCylindricalProjectionTransform( float radius, float angle, float perspective = 0.001f, Axis?orientation = null ) { D.assert(perspective >= 0 && perspective <= 1.0); if (orientation == null) { orientation = Axis.vertical; } Matrix4 result = Matrix4.identity(); result.setEntry(3, 2, -perspective); result.setEntry(2, 3, -radius); result.setEntry(3, 3, perspective * radius + 1.0f); result = result * (( orientation == Axis.horizontal ? Matrix4.rotationY(angle) : Matrix4.rotationX(angle) ) * Matrix4.translationValues(0.0f, 0.0f, radius)) as Matrix4; return(result); }
public LongPressDraggable( T data, Key key = null, Widget child = null, Widget feedback = null, Axis?axis = null, Widget childWhenDragging = null, Offset feedbackOffset = null, DragAnchor dragAnchor = DragAnchor.child, int?maxSimultaneousDrags = null, VoidCallback onDragStarted = null, DraggableCanceledCallback onDraggableCanceled = null, DragEndCallback onDragEnd = null, VoidCallback onDragCompleted = null ) : base( key: key, child: child, feedback: feedback, data: data, axis: axis, childWhenDragging: childWhenDragging, feedbackOffset: feedbackOffset, dragAnchor: dragAnchor, maxSimultaneousDrags: maxSimultaneousDrags, onDragStarted: onDragStarted, onDraggableCanceled: onDraggableCanceled, onDragEnd: onDragEnd, onDragCompleted: onDragCompleted ) { }
public _TabLabelBarRenderer( List <RenderBox> children = null, Axis?direction = null, MainAxisSize?mainAxisSize = null, MainAxisAlignment?mainAxisAlignment = null, CrossAxisAlignment?crossAxisAlignment = null, VerticalDirection?verticalDirection = null, _LayoutCallback onPerformLayout = null ) : base( children: children, direction: direction.Value, mainAxisSize: mainAxisSize.Value, mainAxisAlignment: mainAxisAlignment.Value, crossAxisAlignment: crossAxisAlignment.Value, verticalDirection: verticalDirection.Value ) { D.assert(direction != null); D.assert(mainAxisSize != null); D.assert(mainAxisAlignment != null); D.assert(crossAxisAlignment != null); D.assert(verticalDirection != null); D.assert(onPerformLayout != null); this.onPerformLayout = onPerformLayout; }
public Draggable( Key key = null, Widget child = null, Widget feedback = null, T data = default, Axis?axis = null, Widget childWhenDragging = null, Offset feedbackOffset = null, DragAnchor dragAnchor = DragAnchor.child, Axis?affinity = null, int?maxSimultaneousDrags = null, VoidCallback onDragStarted = null, DraggableCanceledCallback onDraggableCanceled = null, DragEndCallback onDragEnd = null, VoidCallback onDragCompleted = null ) : base(key) { D.assert(child != null); D.assert(feedback != null); D.assert(maxSimultaneousDrags == null || maxSimultaneousDrags >= 0); this.child = child; this.feedback = feedback; this.data = data; this.axis = axis; this.childWhenDragging = childWhenDragging; this.feedbackOffset = feedbackOffset ?? Offset.zero; this.dragAnchor = dragAnchor; this.affinity = affinity; this.maxSimultaneousDrags = maxSimultaneousDrags; this.onDragStarted = onDragStarted; this.onDraggableCanceled = onDraggableCanceled; this.onDragEnd = onDragEnd; this.onDragCompleted = onDragCompleted; }
public RenderUnconstrainedBox( Alignment alignment = null, Axis?constrainedAxis = null, RenderBox child = null ) : base(alignment, child) { this._constrainedAxis = constrainedAxis; }
/// <summary> /// Computes the mean of elements across dimensions of a tensor. /// Reduces `input_tensor` along the dimensions given in `axis`. /// Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each /// entry in `axis`. If `keepdims` is true, the reduced dimensionsare retained with length 1. /// If `axis` is None, all dimensions are reduced, and a tensor with a single element is returned. /// </summary> /// <param name="input_tensor"> The tensor to reduce. Should have numeric type.</param> /// <param name="axis">The dimensions to reduce. If `None` (the default), reduces all /// dimensions.Must be in the range `[-rank(input_tensor), rank(input_tensor))`.</param> /// <param name="keepdims"> If true, retains reduced dimensions with length 1.</param> /// <param name="name"> A name for the operation (optional).</param> public static Tensor reduce_mean(Tensor input_tensor, Axis?axis = null, bool keepdims = false, string name = null, int?reduction_indices = null) { var r = _ReductionDims(input_tensor, axis); var axis_tensor = axis == null ? r : ops.convert_to_tensor(axis); var m = gen_math_ops.mean(input_tensor, axis_tensor, keepdims, name); return(_may_reduce_to_scalar(keepdims, axis_tensor, m)); }
/// <summary> /// Computes the "logical and" of elements across dimensions of a tensor. /// </summary> /// <param name="input_tensor"></param> /// <param name="axis"></param> /// <param name="keepdims"></param> /// <param name="name"></param> /// <returns></returns> public static Tensor reduce_all(Tensor input_tensor, Axis?axis = null, bool keepdims = false, string name = null) { var all = gen_math_ops._all(input_tensor, _ReductionDims(input_tensor, axis), keepdims, name: name); return(_may_reduce_to_scalar(keepdims, axis, all)); }
override protected void OnUserBeginInteracting() { base.OnUserBeginInteracting(); m_LockedManipulationAxis = null; if (m_TintableMeshes != null) { Shader.SetGlobalFloat("_UserIsInteractingWithStencilWidget", 1.0f); } }
internal static DoubleLinkAxis?ConvertTree(Axis?axis) { if (axis == null) { return(null); } return(new DoubleLinkAxis(axis, ConvertTree((Axis?)axis.Input))); }
private void Control_MouseUp(object sender, MouseEventArgs e) { if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { Unhighlight(); _selectedAxis = null; _pressedAxis = null; _dragPlane = null; } }
public class RenderUnconstrainedBox : RenderAligningShiftedBox {//, DebugOverflowIndicatorMixin public RenderUnconstrainedBox( AlignmentGeometry alignment = null, TextDirection?textDirection = null, Axis?constrainedAxis = null, RenderBox child = null ) : base(alignment, textDirection, child) { D.assert(alignment != null); _constrainedAxis = constrainedAxis; }
//constructor internal DoubleLinkAxis(Axis axis, DoubleLinkAxis?inputaxis) : base(axis.TypeOfAxis, inputaxis, axis.Prefix, axis.Name, axis.NodeType) { this.next = null; this.Urn = axis.Urn; this.abbrAxis = axis.AbbrAxis; if (inputaxis != null) { inputaxis.Next = this; } }
/// <summary> /// Initializes a new instance of the <see cref="ResizeFilter"/> class. /// </summary> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="method">The resize method.</param> /// <param name="anchorLocation">The anchor location, for when cropping is used.</param> public ResizeFilter(int width, int height, ResizeMethod method, AnchorLocation anchorLocation, Axis?constrainAxis = null) { this.TargetSize = new Size(width, height); this.ResizeMethod = method; this.AnchorLocation = anchorLocation; this.Resolution = Resolution.Screen; this.CompositingQuality = CompositingQuality.HighQuality; this.InterpoliationMode = InterpolationMode.HighQualityBicubic; this.BackgroundColour = Color.White; this.ConstrainAxis = constrainAxis; }
public Rotation CreateRotationFromSides( CubeCoords coords1, CubeSide side1, CubeCoords coords2, CubeSide side2) { int left1 = coords1.Left; int top1 = coords1.Top; int depth1 = coords1.Depth; int left2 = coords2.Left; int top2 = coords2.Top; int depth2 = coords2.Depth; if (side1 == side2 && coords1 != coords2) { bool invert; Axis? equalsWay = GetEqualsWay(side1, left1, top1, depth1, left2, top2, depth2, out invert); if (equalsWay == null) return null; Axis rotation = (Axis)equalsWay; int layer = CoordsHelper.GetLayerFromAxis(rotation, coords1); return new Rotation(rotation, layer, !invert); } else if (coords1 == coords2 && side1 != side2) { int sum = (int)Axis.Left + (int)Axis.Top + (int)Axis.Depth; Axis axis1 = CoordsHelper.GetAxisFromSide(side1); Axis axis2 = CoordsHelper.GetAxisFromSide(side2); Axis rotation = (Axis)(sum - (int)axis1 - (int)axis2); int layer = CoordsHelper.GetLayerFromAxis(rotation, coords1); bool clockwise = false; for (int i = 0; i < rotationRules.GetLength(0); i++) { if (rotationRules[i, 0] == side1 && rotationRules[i, 1] == side2) { clockwise = true; break; } } return new Rotation(rotation, layer, clockwise); } return null; }
/// <summary> /// Computes the sum of elements across dimensions of a tensor. /// </summary> /// <param name="input"></param> /// <param name="axis"></param> /// <returns></returns> public Tensor reduce_sum(Tensor input, Axis?axis = null, Axis?reduction_indices = null, bool keepdims = false, string name = null) { if (keepdims) { return(math_ops.reduce_sum(input, axis: constant_op.constant(axis ?? reduction_indices), keepdims: keepdims, name: name)); } else { return(math_ops.reduce_sum(input, axis: constant_op.constant(axis ?? reduction_indices))); } }
public static ExpressionAnimation StartExpressionAnimation( [NotNull] this ScrollViewer scroller, [NotNull] UIElement target, Axis sourceXY, Axis?targetXY = null, bool invertSourceAxis = false) { CompositionPropertySet scrollSet = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scroller); string sign = invertSourceAxis ? "-" : string.Empty; ExpressionAnimation animation = scrollSet.Compositor.CreateExpressionAnimation($"{sign}scroll.Translation.{sourceXY}"); animation.SetReferenceParameter("scroll", scrollSet); target.GetVisual().StartAnimation($"Offset.{targetXY ?? sourceXY}", animation); return(animation); }
protected override void FixedUpdate() { if (_playerController.EditorMode) return; if (LockMove) return; var upHorizontal = Top.enable; var downHorizontal = Bot.enable; var leftVertical = Left.enable; var rightVertical = Right.enable; var player = _playerController.TypeItem; AudioManager.PlayerAudioType audioType; Animator.enabled = (upHorizontal || downHorizontal || leftVertical || rightVertical); if (!Animator.enabled) { audioType = AudioManager.PlayerAudioType.Idle; AudioManager.PlaySoundPlayer(AudioIdle, true, player, audioType); SlipIce(); _calcFirstAxis = null; _holdHorizontal = false; _holdVertical = false; return; } audioType = AudioManager.PlayerAudioType.Move; AudioManager.PlaySoundPlayer(AudioMove, true, player, audioType); if (upHorizontal) { CurrentDirection = Direction.Top; } else if (downHorizontal) { CurrentDirection = Direction.Bottom; } else if (leftVertical) { CurrentDirection = Direction.Left; } else if (rightVertical) { CurrentDirection = Direction.Right; } _holdHorizontal = (upHorizontal || downHorizontal); _holdVertical = (leftVertical || rightVertical); base.FixedUpdate(); }
public float along(Axis?axis) { D.assert(axis != null); switch (axis) { case Axis.horizontal: return(horizontal); case Axis.vertical: return(vertical); } throw new Exception("unknown axis"); }
private Axis? GetEqualsWay(CubeSide side, int left1, int top1, int depth1, int left2, int top2, int depth2, out bool invert) { Axis? equalsWay = null; invert = false; if (side == CubeSide.Left || side == CubeSide.Right) { if (top1 == top2) { equalsWay = Axis.Top; invert = depth1 < depth2; } else if (depth1 == depth2) { equalsWay = Axis.Depth; invert = top1 > top2; } } else if (side == CubeSide.Up || side == CubeSide.Down) { if (left1 == left2) { equalsWay = Axis.Left; invert = depth1 > depth2; } else if (depth1 == depth2) { equalsWay = Axis.Depth; invert = left1 < left2; } } else if (side == CubeSide.Front || side == CubeSide.Back) { if (left1 == left2) { equalsWay = Axis.Left; invert = top1 < top2; } else if (top1 == top2) { equalsWay = Axis.Top; invert = left1 > left2; } } invert ^= side == CubeSide.Right || side == CubeSide.Down || side == CubeSide.Back; return equalsWay; }
public static Tensor reduce_std(Tensor input_tensor, Axis?axis = null, bool keepdims = false, string name = null) { if (name == null) { name = "reduce_std"; } // else {name = name;} return(tf_with(ops.name_scope(name, "reduce_std", new[] { input_tensor }), scope => { var variance = reduce_variance(input_tensor, axis: axis, keepdims: keepdims); return gen_math_ops.sqrt(variance); })); }
/// <summary> /// Computes the product of elements across dimensions of a tensor. /// </summary> /// <param name="input_tensor"></param> /// <param name="axis"></param> /// <param name="keepdims"></param> /// <param name="name"></param> /// <returns></returns> public static Tensor reduce_prod(Tensor input_tensor, Axis?axis = null, bool keepdims = false, string name = null) { var r = _ReductionDims(input_tensor, axis); if (axis == null) { var m = gen_math_ops.prod(input_tensor, r, keepdims, name); return(_may_reduce_to_scalar(keepdims, axis, m)); } else { var m = gen_math_ops.prod(input_tensor, axis, keepdims, name); return(_may_reduce_to_scalar(keepdims, axis, m)); } }
internal Joint(XmlNode node) { Name = Utils.ParseString(node.Attributes?["name"]); string typeStr = Utils.ParseString(node.Attributes?["type"]); Type = GetJointType(typeStr, node); Origin?origin = null; Parent?parent = null; Child? child = null; Axis? axis = null; Limit? limit = null; foreach (XmlNode childNode in node.ChildNodes) { switch (childNode.Name) { case "origin": origin = new Origin(childNode); break; case "parent": parent = new Parent(childNode); break; case "child": child = new Child(childNode); break; case "axis": axis = new Axis(childNode); break; case "limit": limit = new Limit(childNode); break; } } Origin = origin ?? Origin.Identity; Parent = parent ?? throw new MalformedUrdfException(node); Child = child ?? throw new MalformedUrdfException(node); Axis = axis ?? Axis.Right; Limit = limit ?? Limit.Empty; }
private static Tensor _ReductionDims(Tensor x, Axis?axis) { if (axis != null) { // should return axis. or check before. return(ops.convert_to_tensor(axis, TF_DataType.TF_INT32)); } else { var rank = common_shapes.rank(x); // we rely on Range and Rank to do the right thing at run-time. if (rank == -1) { return(range(0, array_ops.rank(x))); } return(range(0, rank, 1)); } }
public _DragAvatar( T data, OverlayState overlayState, Axis?axis = null, Offset initialPosition = null, Offset dragStartPoint = null, Widget feedback = null, Offset feedbackOffset = null, _OnDragEnd onDragEnd = null ) { if (initialPosition == null) { initialPosition = Offset.zero; } if (dragStartPoint == null) { dragStartPoint = Offset.zero; } if (feedbackOffset == null) { feedbackOffset = Offset.zero; } D.assert(overlayState != null); this.overlayState = overlayState; this.data = data; this.axis = axis; this.dragStartPoint = dragStartPoint; this.feedback = feedback; this.feedbackOffset = feedbackOffset; this.onDragEnd = onDragEnd; this._entry = new OverlayEntry(this._build); this.overlayState.insert(this._entry); this._position = initialPosition; this.updateDrag(initialPosition); }
public static ScalarExpressionAnimation StartExpressionAnimation( [NotNull] this ScrollViewer scroller, [NotNull] UIElement target, Axis sourceXY, float parameter, Axis?targetXY = null, bool invertSourceAxis = false) { // Get the property set and setup the scroller offset sign CompositionPropertySet scrollSet = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scroller); string sign = invertSourceAxis ? "-" : "+"; // Prepare the second property set to insert the additional parameter CompositionPropertySet properties = scroller.GetVisual().Compositor.CreatePropertySet(); properties.InsertScalar(nameof(parameter), parameter); // Create and start the animation ExpressionAnimation animation = scrollSet.Compositor.CreateExpressionAnimation($"{nameof(properties)}.{nameof(parameter)} {sign} scroll.Translation.{sourceXY}"); animation.SetReferenceParameter("scroll", scrollSet); animation.SetReferenceParameter(nameof(properties), properties); target.GetVisual().StartAnimation($"Offset.{targetXY ?? sourceXY}", animation); return(new ScalarExpressionAnimation(animation, properties, nameof(parameter))); }
public _GlowController( TickerProvider vsync, Color color, Axis?axis ) { D.assert(vsync != null); D.assert(color != null); D.assert(axis != null); _color = color; _axis = axis.Value; _glowController = new AnimationController(vsync: vsync); _glowController.addStatusListener(_changePhase); Animation <float> decelerator = new CurvedAnimation( parent: _glowController, curve: Curves.decelerate ); decelerator.addListener(notifyListeners); _glowOpacity = decelerator.drive(_glowOpacityTween); _glowSize = decelerator.drive(_glowSizeTween); _displacementTicker = vsync.createTicker(_tickDisplacement); }
private void Select() { var ray = Scene.MainCamera.Unproject(Scene.Control.ScreenMousePosition); var modelSpaceRay = Ray.Transform(ray, Transform.InvertedModelMatrix); var axis = GetHitAxis(modelSpaceRay); if (axis == null) { Unhighlight(); _selectedAxis = null; return; } if (_selectedAxis == axis) { return; } Unhighlight(); _selectedAxis = axis; Highlight(); }
public TransformInfo( int?index = null, float?position = null, float?width = null, float?height = null, int?activeIndex = null, int?fromIndex = null, bool?forward = null, bool?done = null, float?viewportFraction = null, Axis?scrollDirection = null ) { this.index = index; this.position = position; this.width = width; this.height = height; this.activeIndex = activeIndex; this.fromIndex = fromIndex; this.forward = forward; this.done = done; this.viewportFraction = viewportFraction; this.scrollDirection = scrollDirection; }
/// <summary> /// Initializes a new instance of the <see cref="ResizeFilter"/> class. /// </summary> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="method">The resize method.</param> /// <param name="anchorLocation">The anchor location, for when cropping is used.</param> public ResizeFilter(int width, int height, ResizeMethod method, AnchorLocation anchorLocation, Axis? constrainAxis = null) { this.TargetSize = new Size(width, height); this.ResizeMethod = method; this.AnchorLocation = anchorLocation; this.Resolution = Resolution.Screen; this.CompositingQuality = CompositingQuality.HighQuality; this.InterpoliationMode = InterpolationMode.HighQualityBicubic; this.BackgroundColour = Color.White; this.ConstrainAxis = constrainAxis; }
public Window(string World, bool Nether , Dictionary<string, Scheme> Schemes) : base(640, 480, GraphicsMode.Default, DefaultTitle) { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmHelp)); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); GL.Enable(EnableCap.Lighting); GL.Enable(EnableCap.CullFace); GL.Enable(EnableCap.ColorMaterial); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Blend); // support transparencey GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); //GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); MinecraftLevel mcl; MinecraftLevel mclt; if (Nether) { mcl = new MinecraftLevel(World + Path.DirectorySeparatorChar + "DIM-1", false); mclt = new MinecraftLevel(World + Path.DirectorySeparatorChar + "DIM-1", true); } else { mcl = new MinecraftLevel(World, false); mclt = new MinecraftLevel(World, true); } int s = 128; DateTime starttime = DateTime.Now; string leveldat = World + Path.DirectorySeparatorChar + "level.dat"; // we still dont change this, level.dat is still used this._Renderer = new MinecraftRenderer(mcl); this._RendererTrans = new MinecraftRenderer(mclt); Scheme schm; Schemes.TryGetValue("Default", out schm); this._Renderer.CurrentScheme = schm; this._RendererTrans.CurrentScheme = schm; Vector<double> acpos = new Vector<double>(); if (File.Exists(leveldat) && !SMPInterface.IsSMP) { try { NBTCompound data = ((NBT.Read(File.OpenRead(leveldat)).Data as NBTCompound?).Value.Data["Data"].Data as NBTCompound?).Value; NBTNamedTag<INBTData> player = null; double hellscale = 8.0; bool tryget = data.Data.TryGetValue("Player", out player); bool nether = !(((player.Data as NBTCompound?).Value.Data["Dimension"].Data as NBTInt?).Value.Data == 0); if (tryget & Nether == nether) { NBTList pos = (((player.Data as NBTCompound?).Value.Data["Pos"]).Data as NBTList?).Value; acpos = new Vector<double>( (pos.Data[0] as NBTDouble?).Value.Data, (pos.Data[1] as NBTDouble?).Value.Data, (pos.Data[2] as NBTDouble?).Value.Data); } else if (tryget && !Nether) // the correct positions are not in the correct places { // Not the nether, but player location is in the nether // Lets make the view 16 times further away, this is the chunk they will come up on. NBTList pos = (((player.Data as NBTCompound?).Value.Data["Pos"]).Data as NBTList?).Value; acpos = new Vector<double>( (pos.Data[0] as NBTDouble?).Value.Data * hellscale, (pos.Data[1] as NBTDouble?).Value.Data, (pos.Data[2] as NBTDouble?).Value.Data * hellscale); } else if (tryget && Nether) // Lets see where we will end up on the nether from up top { NBTList pos = (((player.Data as NBTCompound?).Value.Data["Pos"]).Data as NBTList?).Value; acpos = new Vector<double>( (pos.Data[0] as NBTDouble?).Value.Data / hellscale, (pos.Data[1] as NBTDouble?).Value.Data, (pos.Data[2] as NBTDouble?).Value.Data / hellscale); } else { acpos = new Vector<double>( ((data.Data["SpawnX"]).Data as NBTInt?).Value.Data, ((data.Data["SpawnY"]).Data as NBTInt?).Value.Data, ((data.Data["SpawnZ"]).Data as NBTInt?).Value.Data); } } catch { } } else if (SMPInterface.IsSMP) { MineViewer.SMPPackets.PlayerSpawnPos.UpdateSpawnPos = new Action<Vector<int>>(delegate(Vector<int> pos) { Point<int> c; Point<int> o; MinecraftRenderer.ChunkOffset(new Point<int>((int)pos.Z, (int)pos.X), out c, out o); this._Renderer.GetChunk(c); this._RendererTrans.GetChunk(c); this._CamPos = new Vector<double>(s + 10.1 + c.X * MinecraftRenderer.ChunkSize, s + 10.1 + c.Y * MinecraftRenderer.ChunkSize, s + 10.1); }); } Point<int> chunk; Point<int> offset; MinecraftRenderer.ChunkOffset(new Point<int>((int)acpos.Z, (int)acpos.X), out chunk, out offset); if (!SMPInterface.IsSMP) { this._Renderer.GetChunk(chunk); this._RendererTrans.GetChunk(chunk); } this._CamPos = new Vector<double>(s + 10.1 + chunk.X * MinecraftRenderer.ChunkSize, s + 10.1 + chunk.Y * MinecraftRenderer.ChunkSize, s + 10.1); this._LookZAngle = 4.0; this._LookXAngle = -0.6; DateTime endtime = DateTime.Now; TimeSpan loadtime = endtime - starttime; this._LastHit = null; _Bookmarks = new Bookmarks(World + Path.DirectorySeparatorChar, delegate(Vector<double> vec, Vector<double> ang) { this._CamPos = vec; //this._LookXAngle = ang.X; //this._LookZAngle = ang.Z; Point<int> dchunk; Point<int> doffset; MinecraftRenderer.ChunkOffset(new Point<int>((int)vec.X, (int)vec.Y), out dchunk, out doffset); this._Renderer.GetChunk(dchunk); this._RendererTrans.GetChunk(dchunk); }); this.KeyPress += delegate(object sender, OpenTK.KeyPressEventArgs e) { char key = e.KeyChar.ToString().ToLower()[0]; if (key == 'b') { this._Bookmarks.ShowForm(this._CamPos, new Vector<double>(this._LookXAngle, 0.0, this._LookZAngle)); } if (key == ',') { this._SliceLevel = this._SlicePolarity == Polarity.Negative ? this._SliceLevel - 1 : this._SliceLevel + 1; } if (key == '.') { this._SliceLevel = this._SlicePolarity == Polarity.Negative ? this._SliceLevel + 1 : this._SliceLevel - 1; } if (key == 'h') { frmHelp frm = new frmHelp(); frm.Show(); } if (key == 'k') { frmKey k = new frmKey(this._Renderer.CurrentScheme); k.Show(); } if (key == 't') { frmSchemes schemeform = new frmSchemes(delegate(string item) { if (item.Length < 1) return; this._Renderer.CurrentScheme = this._Schemes[item]; this._RendererTrans.CurrentScheme = this._Schemes[item]; }); int index = 0; foreach(string k in this._Schemes.Keys) { ListViewItem item = new ListViewItem(k); schemeform.Schemes.Items.Add(item); Scheme o; this._Schemes.TryGetValue(k, out o); if (this._Renderer.CurrentScheme == o) schemeform.Schemes.Items[index].Selected = true; index++; } schemeform.Show(); } }; this.Keyboard.KeyDown += delegate(object sender, KeyboardKeyEventArgs e) { if (e.Key == Key.Escape) { this.Close(); } if (e.Key == Key.R) { this._SliceAxis = null; } }; this.Mouse.ButtonDown += delegate(object sender, MouseButtonEventArgs bea) { if (bea.Button == MouseButton.Left) { if (this._LastHit != null) { Border<MinecraftRenderer.HitBorder> hit = this._LastHit.Value; MinecraftRenderer.Chunk c; bool loaded = this._Renderer.Chunks.TryGetValue(hit.Value.Chunk.Value, out c); if (loaded) { if (this.Keyboard[Key.Q]) { this._Renderer.UnloadChunk(hit.Value.Chunk.Value); this._RendererTrans.UnloadChunk(hit.Value.Chunk.Value); } else if (this.Keyboard[Key.I]) { // TODO!!!!!!!!!!!!!!!!!! Point<int> pos = hit.Value.Chunk.Value; long regionX = (long)Math.Floor((decimal)pos.X / 32); long regionZ = (long)Math.Floor((decimal)pos.Y / 32); string file = Path.DirectorySeparatorChar + "region" + Path.DirectorySeparatorChar + "r." + Convert.ToString(regionX) + "." + Convert.ToString(regionZ) + ".mcr"; string msg = String.Format("Chunk: X {0} Y {1}\nFile: {2}", pos.X, pos.Y, file); msg += String.Format("\nX {0} Y {1} Z {2}", hit.Position.Y, hit.Position.Z, hit.Position.X); MessageBox.Show(msg); } else { this._SliceAxis = hit.Direction; this._SliceLevel = hit.Position[hit.Direction] + (hit.Value.Polarity == Polarity.Negative ? 1 : 0); this._SlicePolarity = hit.Value.Polarity; } } else { if (this.Keyboard[Key.E]) { bool a; Point<int> pos = hit.Value.Chunk.Value; if (this._Renderer.ChunksSelected.TryGetValue(pos, out a)) this._Renderer.ChunksSelected.Remove(pos); else this._Renderer.ChunksSelected.Add(pos, true); } else { if (this._Renderer.ChunksSelected.Count > 0) { foreach (KeyValuePair<Point<int>, bool> kv in this._Renderer.ChunksSelected) { this._Renderer.GetChunk(kv.Key); this._RendererTrans.GetChunk(kv.Key); } this._Renderer.ChunksSelected.Clear(); } else { this._Renderer.GetChunk(hit.Value.Chunk.Value); this._RendererTrans.GetChunk(hit.Value.Chunk.Value); } } } } } else { if (this._Renderer.ChunksSelected.Count > 0 && this.Keyboard[Key.E]) this._Renderer.ChunksSelected.Clear(); } }; this._Schemes = Schemes; this._Renderer.CurrentScheme = this._Schemes["Default"]; this._AverageFPS = 60.0; }