public void Draw() { if (ImGui.CollapsingHeader("Transform", ImGuiTreeNodeFlags.DefaultOpen)) { ImGui.LabelText("Children", _transform.ChildCount.ToString()); if (_transform.Parent == null) { ImGui.LabelText("Parent", "none"); } else { if (NezImGui.LabelButton("Parent", _transform.Parent.Entity.Name)) { Core.GetGlobalManager <ImGuiManager>().StartInspectingEntity(_transform.Parent.Entity); } if (ImGui.Button("Detach From Parent")) { _transform.Parent = null; } } NezImGui.SmallVerticalSpace(); Num.Vector2 pos = _transform.LocalPosition.ToNumerics(); if (ImGui.DragFloat2("Local Position", ref pos)) { _transform.SetLocalPosition(pos.ToXNA()); } float rot = _transform.LocalRotationDegrees; if (ImGui.DragFloat("Local Rotation", ref rot, 1, -360, 360)) { _transform.SetLocalRotationDegrees(rot); } Num.Vector2 scale = _transform.LocalScale.ToNumerics(); if (ImGui.DragFloat2("Local Scale", ref scale, 0.05f)) { _transform.SetLocalScale(scale.ToXNA()); } scale = _transform.Scale.ToNumerics(); if (ImGui.DragFloat2("Scale", ref scale, 0.05f)) { _transform.SetScale(scale.ToXNA()); } } }
private void DrawWidget(Vector2 value, int index) { Num.Vector2 vec = value.ToNumerics(); if (ImGui.DragFloat2($"{index}", ref vec)) { _list[index] = vec.ToXNA(); } }
private void InspectVector2() { Num.Vector2 value = GetValue <Vector2>().ToNumerics(); if (ImGui.DragFloat2(_name, ref value)) { SetValue(value.ToXNA()); } }
// ReSharper restore NotAccessedField.Global // ReSharper restore MemberCanBePrivate.Global public VertexPositionTextureNormalBinormalTangent(Vector3 position, Vector2 textureCoordinate, Vector3 normal, Vector3 binormal, Vector3 tangent) { Position = position.ToXNA(); TextureCoordinate = textureCoordinate.ToXNA(); Normal = normal.ToXNA(); Binormal = binormal.ToXNA(); Tangent = tangent.ToXNA(); }
void OnButtonClicked() { if (_parameterType == null) { (_memberInfo as MethodInfo).Invoke(_target, new object[] { }); } else { // extract the param and properly cast it var parameters = new object[1]; try { if (_parameterType == typeof(float)) { parameters[0] = _floatParam; } else if (_parameterType == typeof(int)) { parameters[0] = _intParam; } else if (_parameterType == typeof(bool)) { parameters[0] = _boolParam; } else if (_parameterType == typeof(string)) { parameters[0] = _stringParam; } else if (_parameterType == typeof(Vector2)) { parameters[0] = _vec2Param.ToXNA(); } else if (_parameterType == typeof(Vector3)) { parameters[0] = _vec3Param.ToXNA(); } (_memberInfo as MethodInfo).Invoke(_target, parameters); } catch (Exception e) { Debug.Error(e.ToString()); } } }
public static void SetValue(this EffectParameter collection, Vector2 value) { Contract.Requires(collection != null); collection.SetValue(value.ToXNA()); }
public static void SetValue(this EffectParameter collection, Vector2 value) { collection.SetValue(value.ToXNA()); }
private void DrawLeftPane() { Origin OriginIndex(Vector2 origin) { switch (origin) { case Vector2 o when o.X == 0 && o.Y == 0: // tl return(Origin.TopLeft); case Vector2 o when o.X == 0.5f && o.Y == 0: // t return(Origin.Top); case Vector2 o when o.X == 1 && o.Y == 0: // tr return(Origin.TopRight); case Vector2 o when o.X == 0 && o.Y == 0.5f: // l return(Origin.Left); case Vector2 o when o.X == 0.5f && o.Y == 0.5f: // center return(Origin.Center); case Vector2 o when o.X == 1 && o.Y == 0.5f: // right return(Origin.Right); case Vector2 o when o.X == 0 && o.Y == 1: // bl return(Origin.BottomLeft); case Vector2 o when o.X == 0.5f && o.Y == 1: // b return(Origin.Bottom); case Vector2 o when o.X == 1 && o.Y == 1: // br return(Origin.BottomRight); default: return(Origin.Custom); } } Vector2 OriginValue(Origin origin, Vector2 currentOrigin) { switch (origin) { case Origin.TopLeft: return(new Vector2(0, 0)); case Origin.Top: return(new Vector2(0.5f, 0)); case Origin.TopRight: return(new Vector2(1, 0)); case Origin.Left: return(new Vector2(0, 0.5f)); case Origin.Center: return(new Vector2(0.5f, 0.5f)); case Origin.Right: return(new Vector2(1, 0.5f)); case Origin.BottomLeft: return(new Vector2(0, 1)); case Origin.Bottom: return(new Vector2(0.5f, 1)); case Origin.BottomRight: return(new Vector2(1, 1)); default: return(currentOrigin + new Vector2(0.01f, 0.01f)); } } if (NezImGui.CenteredButton("Set All Origins", 0.75f)) { _globalOriginEnumValue = 7; ImGui.OpenPopup("set-all-origins"); } NezImGui.MediumVerticalSpace(); if (ImGui.BeginPopup("set-all-origins")) { ImGui.Combo("###global-origin", ref _globalOriginEnumValue, _originEnumNames, _originEnumNames.Length); if (ImGui.Button("Set All Origins")) { for (int i = 0; i < _spriteAtlasData.Origins.Count; i++) { _spriteAtlasData.Origins[i] = OriginValue((Origin)_globalOriginEnumValue, _spriteAtlasData.Origins[i]); } ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } for (int i = 0; i < _spriteAtlasData.Origins.Count; i++) { ImGui.PushID(i); string name = _spriteAtlasData.Names[i]; if (ImGui.InputText("Name", ref name, 25)) { _spriteAtlasData.Names[i] = name; } Num.Vector2 origin = _spriteAtlasData.Origins[i].ToNumerics(); if (ImGui.SliderFloat2("Origin", ref origin, 0f, 1f)) { _spriteAtlasData.Origins[i] = origin.ToXNA(); } Origin originEnum = OriginIndex(_spriteAtlasData.Origins[i]); int originEnumValue = (int)originEnum; if (ImGui.Combo($"###enum_{i}", ref originEnumValue, _originEnumNames, _originEnumNames.Length)) { _spriteAtlasData.Origins[i] = OriginValue((Origin)originEnumValue, _spriteAtlasData.Origins[i]); } ImGui.Separator(); ImGui.PopID(); } }