private void SelectLightTreeNode(LightAttributes light) { foreach (TreeNode rn in LightsTreeView.Nodes) { if (rn.Tag == light) { LightsTreeView.SelectedNode = rn; break; } var found = false; foreach (TreeNode tn in rn.Nodes) { if (tn.Tag == light) { LightsTreeView.SelectedNode = tn; found = true; break; } } if (found) { break; } } }
private void SelectLight(LightAttributes light) { if (light == null) { selectedLight = null; ModelForm.selectedLight = null; UpdateUI(); } else { selectedLight = light; ModelForm.selectedLight = light; UpdateUI(); var pos = light.Position; Bone bone = null; ModelForm.Skeleton?.BonesMap?.TryGetValue(light.BoneId, out bone); if (bone != null) { var xform = bone.AbsTransform; pos = xform.Multiply(pos); //TODO:? handle bone's rotation correctly for widget?? } ModelForm.SetWidgetTransform(pos, light.Orientation, new Vector3(light.Falloff)); } }
private void DuplicateLight() { if (selectedLight == null) { return; } selectedLight = DuplicateLightAttribute(); if (Drawable != null) { if (Drawable.LightAttributes == null) { Drawable.LightAttributes = new ResourceSimpleList64 <LightAttributes>(); } List <LightAttributes> lights = Drawable.LightAttributes.data_items?.ToList() ?? new List <LightAttributes>(); lights.Add(selectedLight); Drawable.LightAttributes.data_items = lights.ToArray(); UpdateLightParams(); LoadModel(Drawable); } else if (FragDrawable != null) { if (FragDrawable.OwnerFragment.LightAttributes == null) { FragDrawable.OwnerFragment.LightAttributes = new ResourceSimpleList64 <LightAttributes>(); } List <LightAttributes> lights = FragDrawable.OwnerFragment.LightAttributes.data_items?.ToList() ?? new List <LightAttributes>(); lights.Add(selectedLight); FragDrawable.OwnerFragment.LightAttributes.data_items = lights.ToArray(); UpdateLightParams(); LoadModel(FragDrawable); } else { var n = LightsTreeView.SelectedNode; if (n != null) { var dr = n.Tag as Drawable; if (dr == null) { dr = n.Parent.Tag as Drawable; } //try parent node tag also if (dr != null) { if (dr.LightAttributes == null) { dr.LightAttributes = new ResourceSimpleList64 <LightAttributes>(); } List <LightAttributes> lights = dr.LightAttributes.data_items?.ToList() ?? new List <LightAttributes>(); lights.Add(selectedLight); dr.LightAttributes.data_items = lights.ToArray(); UpdateLightParams(); LoadModels(DrawableDict); } } } SelectLightTreeNode(selectedLight); }
private LightAttributes DuplicateLightAttribute() { LightAttributes light = new LightAttributes(); light.Unknown_0h = selectedLight.Unknown_0h; light.Unknown_4h = selectedLight.Unknown_4h; light.Position = selectedLight.Position; light.Unknown_14h = selectedLight.Unknown_14h; light.ColorR = selectedLight.ColorR; light.ColorG = selectedLight.ColorG; light.ColorB = selectedLight.ColorB; light.Flashiness = selectedLight.Flashiness; light.Intensity = selectedLight.Intensity; light.Flags = selectedLight.Flags; light.BoneId = selectedLight.BoneId; light.Type = selectedLight.Type; light.GroupId = selectedLight.GroupId; light.TimeFlags = selectedLight.TimeFlags; light.Falloff = selectedLight.Falloff; light.FalloffExponent = selectedLight.FalloffExponent; light.CullingPlaneNormal = selectedLight.CullingPlaneNormal; light.CullingPlaneOffset = selectedLight.CullingPlaneOffset; light.ShadowBlur = selectedLight.ShadowBlur; light.Unknown_45h = selectedLight.Unknown_45h; light.Unknown_46h = selectedLight.Unknown_46h; light.VolumeIntensity = selectedLight.VolumeIntensity; light.VolumeSizeScale = selectedLight.VolumeSizeScale; light.VolumeOuterColorR = selectedLight.VolumeOuterColorR; light.VolumeOuterColorG = selectedLight.VolumeOuterColorG; light.VolumeOuterColorB = selectedLight.VolumeOuterColorB; light.LightHash = selectedLight.LightHash; light.VolumeOuterIntensity = selectedLight.VolumeOuterIntensity; light.CoronaSize = selectedLight.CoronaSize; light.VolumeOuterExponent = selectedLight.VolumeOuterExponent; light.LightFadeDistance = selectedLight.LightFadeDistance; light.ShadowFadeDistance = selectedLight.ShadowFadeDistance; light.SpecularFadeDistance = selectedLight.SpecularFadeDistance; light.VolumetricFadeDistance = selectedLight.VolumetricFadeDistance; light.ShadowNearClip = selectedLight.ShadowNearClip; light.CoronaIntensity = selectedLight.CoronaIntensity; light.CoronaZBias = selectedLight.CoronaZBias; light.Direction = selectedLight.Direction; light.Tangent = selectedLight.Tangent; light.ConeInnerAngle = selectedLight.ConeInnerAngle; light.ConeOuterAngle = selectedLight.ConeOuterAngle; light.Extent = selectedLight.Extent; light.ProjectedTextureHash = selectedLight.ProjectedTextureHash; light.Unknown_A4h = selectedLight.Unknown_A4h; return(light); }
private void SelectLight(LightAttributes light) { if (light == null) { selectedLight = null; ModelForm.selectedLight = null; UpdateUI(); } else { selectedLight = light; ModelForm.selectedLight = light; UpdateUI(); ModelForm.SetWidgetTransform(light.Position, light.Orientation, new Vector3(light.Falloff)); } }
private LightAttributes NewLightAttribute() { LightAttributes light = new LightAttributes(); light.Direction = Vector3.BackwardLH; light.Tangent = Vector3.Right; light.Intensity = 5; light.ConeInnerAngle = 5; light.ConeOuterAngle = 35; light.Extent = Vector3.One; light.Type = LightType.Spot; light.Falloff = 10; light.ColorR = 255; light.ColorG = 255; light.ColorB = 255; light.TimeFlags = 14680191; return(light); }