public static Scene Lighting1() { Scene scene = new Scene(new Color(255, 255, 255)); Light sun = new LightDirectional(new Color(255, 255, 255), new Vector3(1, -1, 1), scene); LightGroup lightGroup = new LightGroup(); lightGroup.addLight(sun); SurfaceMaterial diffuseRed = new SurfaceDiffuse(new Color(255, 50, 50), lightGroup); SurfaceMaterial diffuseGreen = new SurfaceDiffuse(new Color(50, 255, 50), lightGroup); SurfaceMaterial diffuseBlue = new SurfaceDiffuse(new Color(50, 50, 255), lightGroup); SurfaceMaterial diffuseWhite = new SurfaceDiffuse(new Color(255, 255, 255), lightGroup); SurfaceMaterial specular = new SurfaceSpecular(new Color(100, 100, 100), 50, lightGroup); SurfaceMaterial red = new SurfaceMaterialSum(specular, diffuseRed); SurfaceMaterial blue = new SurfaceMaterialSum(specular, diffuseBlue); SurfaceMaterial green = new SurfaceMaterialSum(specular, diffuseGreen); SurfaceMaterial white = new SurfaceMaterialSum(specular, diffuseWhite); scene.addSurface(new Surface(new SurfacePlane(-25 * Vector3.Up, Vector3.Forward, Vector3.Right), white)); scene.addSurface(new Surface(new SurfaceSphere(new Vector3(-40, 0, 80), 10), red)); scene.addSurface(new Surface(new SurfaceSphere(new Vector3(0, 0, 80), 10), green)); scene.addSurface(new Surface(new SurfaceSphere(new Vector3(40, 0, 80), 10), blue)); return(scene); }
static public void SetActiveLightGroup(LightGroup lightGroup) { if (m_LightGroup == lightGroup) { return; } if (m_LightGroup) { foreach (var l in m_LightGroup.lights) { if (l) { l.enabled = false; } } } //;;Debug.Log ("SetActiveLightGroup " + lightGroup); m_LightGroup = lightGroup; if (m_LightGroup) { foreach (var l in m_LightGroup.lights) { if (l) { l.enabled = true; } } } }
public LightGroup ReadLimitlessLampFile(String filePath) { LimitlessLampModel limitlessLampModel = ReadLimitlessLamp(filePath); List <int> mData = new List <int>(); String[] strs = limitlessLampModel.Data.Trim().Split(','); for (int i = 0; i < strs.Length; i++) { if (int.Parse(strs[i]) != 0) { int color = int.Parse(strs[i]); mData.Add(color); } else { mData.Add(0); } } LightGroup ll = new LightGroup(); for (int i = 0; i < limitlessLampModel.Points.Count; i++) { List <Light> mLl = SetDataToPreviewLaunchpadFromXY(mData, limitlessLampModel.Columns, limitlessLampModel.Rows, (int)limitlessLampModel.Points[i].X, (int)limitlessLampModel.Points[i].Y); for (int j = 0; j < mLl.Count; j++) { mLl[j].Time = i * limitlessLampModel.Interval; } ll.AddRange(mLl); } CreateInstance().ReplaceControl(ll, CreateInstance().normalArr); return(ll); }
public LightGroup SetDataToPreviewLaunchpadFromXY(List <int> mData, int ColumnsCount, int RowsCount, int positionX, int positionY) { LightGroup lightList = new LightGroup(); //Console.WriteLine(positionX + "---"+ positionY); for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { if (x + positionX < ColumnsCount && y + positionY < RowsCount) { //有值 if (x < 4) { if (mData[x + positionX + (y + positionY) * ColumnsCount] != 0) { lightList.Add(new Light(0, 144, 8 + x + 4 * (7 - y), mData[x + positionX + (y + positionY) * ColumnsCount])); } } else { if (mData[x + positionX + (y + positionY) * ColumnsCount] != 0) { lightList.Add(new Light(0, 144, 8 + x + 4 * (6 - y) + 32, mData[x + positionX + (y + positionY) * ColumnsCount])); } } } else { //没值,暂不处理 } } } return(lightList); }
public void ContextSetup() { _id = Guid.NewGuid(); _masterModel = new MasterModel(); _project = _masterModel.CreateProject(); _group = _project.CreateGroup(x => x.Id = _id); }
public static Scene Boolean(bool outlines) { Scene scene = new Scene(new Color(255, 255, 255)); Light sun = new LightDirectional(new Color(255, 255, 255), new Vector3(0, -1, 1), scene, false); LightGroup lightGroup = new LightGroup(); lightGroup.addLight(sun); Vector3 center1 = new Vector3(-12, 0, 30); Vector3 center2 = new Vector3(-6, 0, 30); Vector3 center3 = new Vector3(9, 0, 30); Vector3 center4 = new Vector3(9, 1, 27); double radius = 5; double radius2 = 3; SurfaceGeometry surfaceIntersection = new SurfaceIntersection(new VolumeSphere(center1, radius), new VolumeSphere(center2, radius)); SurfaceGeometry surfaceDifference = new SurfaceDifference(new VolumeSphere(center3, radius), new VolumeSphere(center4, radius2)); SurfaceMaterial diffuse = new SurfaceDiffuse(new Color(255, 255, 255), lightGroup); SurfaceMaterial semiopaque = new SurfaceMaterialBlend(new SurfaceTransparent(scene), diffuse, 0.2); scene.addSurface(new Surface(surfaceIntersection, diffuse)); scene.addSurface(new Surface(surfaceDifference, diffuse)); if (outlines) { scene.addSurface(new Surface(new SurfaceSphere(center1, radius), semiopaque)); scene.addSurface(new Surface(new SurfaceSphere(center2, radius), semiopaque)); scene.addSurface(new Surface(new SurfaceSphere(center3, radius), semiopaque)); scene.addSurface(new Surface(new SurfaceSphere(center4, radius2), semiopaque)); } return(scene); }
private void dgGroups_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (dgGroups.SelectedItem is LightGroup) { LightGroup group = (LightGroup)dgGroups.SelectedItem; contentHolder.Content = group; } }
private void dgGroups_GotFocus(object sender, RoutedEventArgs e) { if (dgGroups.SelectedItem is LightGroup) { LightGroup group = (LightGroup)dgGroups.SelectedItem; contentHolder.Content = group; } }
public void ContextSetup() { _group = new MasterModel().CreateProject().CreateGroup(); _light = new Light(new ZWaveValueIdentity(1, 2, 123)); _group.AddLight(_light); _group.RemoveLight(_light); }
/// <summary> /// 读取Midi文件内容 /// </summary> /// <param name="filePath">Midi文件的内容</param> public LightGroup ReadMidiContent(List <int> mData) { LightGroup mActionBeanList = new LightGroup(); //当前记录什么位置 int nowRecordPosition = 3; List <int> listTime = new List <int>(); Light ab = new Light(); for (int i = 0; i < mData.Count; i++) { //记录时间 if (nowRecordPosition == 3) { //添加进时间数组 listTime.Add(mData[i]); //如果最高位为0,结束读取时间差 if (mData[i] < 128) { int iTimeAll = 0; for (int x = listTime.Count - 1; x >= 0; x--) { if (listTime[listTime.Count - x - 1] >= 128) { listTime[listTime.Count - x - 1] -= 128; } //Console.WriteLine((int)Math.Pow(128, x) + "---" + listTime[listTime.Count - x - 1]); iTimeAll += (int)Math.Pow(127, x) * listTime[listTime.Count - x - 1]; } ab = new Light(); ab.Time = iTimeAll; listTime.Clear(); nowRecordPosition = 0; continue; } } if (nowRecordPosition == 0) { ab.Action = mData[i]; nowRecordPosition = 1; continue; } if (nowRecordPosition == 1) { ab.Position = mData[i]; nowRecordPosition = 2; continue; } if (nowRecordPosition == 2) { ab.Color = mData[i]; nowRecordPosition = 3; mActionBeanList.Add(ab); continue; } } return(mActionBeanList); }
public void ContextSetup() { _masterModel = new MasterModel(); _group = _masterModel.CreateProject().CreateGroup(); _group.AddLight(new Light(new ZWaveValueIdentity(11, 22, 123))); _group.AddLight(new Light(new ZWaveValueIdentity(11, 44, 123))); _group.UnassignAllLights(); }
public static LightGroup LightGroupToListLight(List <Light> ll) { LightGroup lightGroup = new LightGroup(); foreach (var item in ll) { lightGroup.Add(item); } return(lightGroup); }
public static List <Light> LightGroupToListLight(LightGroup lightGroup) { List <Light> ll = new List <Light>(); foreach (var item in lightGroup) { ll.Add(item); } return(ll); }
static public void SetLightGroup(LightGroup defaultLightGroup) { var lightGroups = Object.FindObjectsOfType(typeof(LightGroup)) as LightGroup[]; var lightGroup = defaultLightGroup; if (lightGroup) { BulletTime.DisableLightGroups(lightGroups); BulletTime.SetActiveLightGroup(lightGroup); } }
public void ContextSetup() { var masterModel = new MasterModel(); var fooDaddy = masterModel.CreateProject(x => x.Name = "FooDaddy"); _group = fooDaddy.CreateGroup(x => x.Name = "Foo"); _light = new Light(new ZWaveValueIdentity(1, 2, 123)); _group.AddLight(_light); _light.Unassign(); }
public static LightGroup FileToLight(String filePath, String stepName) { Dictionary <string, List <Light> > mLights = Test(GetScriptModelDictionary(filePath, out String introduce, out String audioResources), stepName); LightGroup lights = new LightGroup(); foreach (var item in mLights) { lights.AddRange(item.Value); } return(lights); }
protected void OnStopEvent(List <int> value) { LightGroup group = new LightGroup( GetLightViewPresentersFromIndices(value), mLightState); foreach (SineControl sineCtrl in mSineControls) { sineCtrl.Stop(); } mLightState.Update(); }
public void ContextSetup() { var zWaveIdentity = new ZWaveValueIdentity(11, 23, 222); _light = new Light(zWaveIdentity); _model = new MasterModel(); _destinationGroup = _model.CreateProject().CreateGroup(); _model.AddUnassignedLight(_light); _model.AssignLightToGroup(zWaveIdentity, _destinationGroup.Id); }
private static LightGroup RandomFountain(bool containBorder, params int[] nums) { //Random类默认的无参构造函数可以根据当前系统时钟为种子,进行一系列算法得出要求范围内的伪随机数. LightGroup mLl = new LightGroup(); List <List <int> > lli = IntCollection.VerticalIntList.ToList(); List <int> list = new List <int>(); for (int i = 0; i < nums.Count(); i++) { if (nums[i] < 0) { list.Add(0); } else if (nums[i] > 9) { list.Add(9); } else { list.Add(nums[i]); } if (list.Count == 10) { break; } } for (int i = nums.Count(); i < 11; i++) { list.Add(0); } int plus = 16; int count = list.Max(); int now = 0; while (now <= count) { for (int i = 0; i < list.Count; i++) { if (list[i] >= now && now != 0) { mLl.Add(new Light((now - 1) * plus, 144, lli[i][10 - now], 5)); mLl.Add(new Light((count * 2 - now) * plus, 128, lli[i][10 - now], 64)); } } now++; } //LightBusiness.Print(mLl); RemoveIncorrectlyData(mLl); return(mLl); }
protected void OnSineFired(List <int> value) { LightGroup group = new LightGroup( GetLightViewPresentersFromIndices(value), mLightState); SineControl sineCtrl = new SineControl(); AmpSinePresenter pres = new AmpSinePresenter(sineCtrl, mLightState, group); mSineControls.Add(sineCtrl); sineCtrl.Start(); }
public void ContextSetup() { var model = new MasterModel(); _fooGroup = model.CreateProject().CreateGroup(); _barGroup = model.CreateProject().CreateGroup(); var zWaveIdentity = new ZWaveValueIdentity(1, 2, 123); _light = new Light(zWaveIdentity); _fooGroup.AddLight(_light); model.AssignLightToGroup(zWaveIdentity, _barGroup.Id); }
// Start is called before the first frame update void Start() { foreach (GameObject light in GameObject.FindGameObjectsWithTag("Light")) { AllLights.Add(light.GetComponent <LightScript>()); } //Adds Lights to appropriate LightGroup foreach (LightScript l in AllLights) { LightGroup lGroep = GetOrCreate(l.groupID); lGroep.Add(l); } Blackout(); }
static public void DisableLightGroups(LightGroup[] lightGroups) { foreach (var g in lightGroups) { foreach (var l in g.lights) { if (l) { l.enabled = false; } } if (m_LightGroup == g) { m_LightGroup = null; } } SetActiveLightGroup(m_LightGroup); }
LightGroup GetOrCreate(int groupID) { //Gets Lightgroup for (int i = 0; i < Groups.Count; i++) { if (Groups[i].groupID == groupID) { return(Groups[i]); } } //Creates a new LightGroup if no Lightgroup is found LightGroup lg = new LightGroup(); lg.groupID = groupID; Groups.Add(lg); return(lg); }
public static Scene Lighting2() { Scene scene = new Scene(new Color(255, 255, 255)); Light lightRed = new LightDirectional(new Color(255, 0, 0), new Vector3(1, -3, 0), scene, true); Light lightGreen = new LightDirectional(new Color(0, 255, 0), new Vector3(-1, -3, 0), scene, true); Light lightBlue = new LightDirectional(new Color(0, 0, 255), new Vector3(0, -3, 1), scene, true); LightGroup lightGroup = new LightGroup(); lightGroup.addLight(lightRed); lightGroup.addLight(lightGreen); lightGroup.addLight(lightBlue); SurfaceMaterial diffuseWhite = new SurfaceDiffuse(new Color(255, 255, 255), lightGroup); SurfaceMaterial specular = new SurfaceSpecular(new Color(100, 100, 100), 50, lightGroup); SurfaceMaterial material = new SurfaceMaterialSum(specular, diffuseWhite); scene.addSurface(new Surface(new SurfacePlane(-25 * Vector3.Up, Vector3.Forward, Vector3.Right), diffuseWhite)); scene.addSurface(new Surface(new SurfaceSphere(new Vector3(0, 0, 80), 10), material)); return(scene); }
public void ContextSetup() { var existingMasterModel = new MasterModel(); _parentProject = existingMasterModel.CreateProject(x => x.Name = "Existing Project"); var existingGroup = _parentProject.CreateGroup(x => x.Name = "Existing Group"); existingGroup.AddLight(new Light(new ZWaveValueIdentity(1, 1, 123))); existingGroup.AddLight(new Light(new ZWaveValueIdentity(1, 2, 123))); _remainingGroup = _parentProject.CreateGroup(); _remainingGroup.AddLight(new Light(new ZWaveValueIdentity(1, 10, 123))); var repository = new StubMasterModelRepository(); repository.UseCurrentModel(existingMasterModel); var creator = new LightGroupManager(repository); _result = creator.Delete(existingGroup.Id); _savedModel = repository.LastSaved; }
public void ContextSetup() { var masterModel = new MasterModel(); var barDaddy = masterModel.CreateProject(x => { x.Name = "BarDaddy"; }); _bar = barDaddy.CreateGroup(x => x.Name = "Bar"); var fooDaddy = masterModel.CreateProject(x => { x.Name = "FooDaddy"; }); var foo = fooDaddy.CreateGroup(x => x.Name = "Foo"); _light = new Light(new ZWaveValueIdentity(1, 2, 123)); _bar.AddLight(_light); try { foo.RemoveLight(_light); } catch (Exception e) { _thrown = e; } }
/// <summary> /// 读取Light文件 /// </summary> /// <param name="filePath">Light文件的路径</param> public LightGroup ReadLightFile(String filePath) { LightGroup mActionBeanList = new LightGroup(); //存放AB的集合 List <int> mData = new List <int>(); //文件字符集合 List <String> mAction = new List <String>(); //获取文件里所有的字节 using (FileStream f = new FileStream(filePath, FileMode.OpenOrCreate)) { int i = 0; while ((i = f.ReadByte()) != -1) { mData.Add(i); } } mActionBeanList = ReadMidiContent(mData); //格式化时间 int time = 0; for (int l = 0; l < mActionBeanList.Count; l++) { mActionBeanList[l].Position -= 28; if (mActionBeanList[l].Time == 0) { mActionBeanList[l].Time = time; } else { time += mActionBeanList[l].Time; mActionBeanList[l].Time = time; } } ReplaceControl(mActionBeanList, normalArr); return(mActionBeanList); }
public static Scene Mesh() { Scene scene = new Scene(new Color(200, 200, 255)); Mesh mesh = OBJ.ParseFile(@"..\..\monkey.obj"); LightGroup lightGroup = new LightGroup(); lightGroup.addLight(new LightDirectional(new Color(255, 255, 255), new Vector3(0.2, -0.2, 1), scene)); SurfaceGeometry geometry = new SurfaceMesh(mesh, Vector3.Forward * 10, new Vector3(0, Math.PI, 0), SurfaceMesh.NormalMode.PER_VERTEX); SurfaceMaterial diffuse = new SurfaceDiffuse(new Color(200, 212, 180), lightGroup); SurfaceMaterial specular = new SurfaceSpecular(new Color(255, 255, 255), 150, lightGroup); SurfaceMaterial material = new SurfaceMaterialSum(diffuse, specular); Surface monkey = new Surface(geometry, material); //We enclose the monkey in a bounding sphere, which speeds up the rendering over 7 times Surface boundedMonkey = new Surface(new SurfaceBoundingVolume(new SurfaceSphere(Vector3.Forward * 10, 2.5), monkey), null); scene.addSurface(boundedMonkey); return(scene); }
public AmpSinePresenter(IAmpSineView pView, ILightState pState, LightGroup pGroup) : base(pView, pState) { mLightGroup = pGroup; Initialize(pView); }
public SurfaceSpecular(Color color, double exponent, LightGroup lightGroup) { this.color = color.toVector(); this.lightGroup = lightGroup; this.exponent = exponent; }
protected void OnSineFired(List<int> value) { LightGroup group = new LightGroup( GetLightViewPresentersFromIndices(value), mLightState); SineControl sineCtrl = new SineControl(); AmpSinePresenter pres = new AmpSinePresenter(sineCtrl, mLightState, group); mSineControls.Add(sineCtrl); sineCtrl.Start(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here // Add objects and lights to the ObjectManager and LightManager // respectively. The ObjectManager accepts objects in several forms: // // -As SceneObjects, which can be dynamic (movable) or static and are // created from XNA Models or custom vertex / index buffer. // // -As XNA Models, which can only be static. // voxelManager.AddVoxelType("Models/cobblestone", 10000); voxelManager.FinishInit(Content, GraphicsDevice, sceneInterface); //Window.Title = Window.Title + " - Instanced Object Count: " + (instancesPerContainerObject * containerObjects.Length); // LightRigs contain many lights and light groups. LightRig rig = new LightRig(); // Ambient lights uniformly illuminate the scene. AmbientLight ambientlight = new AmbientLight(); ambientlight.Enabled = true; ambientlight.DiffuseColor = new Vector3(0.8f, 0.98f, 0.99f); ambientlight.Intensity = 0.5f; // Directional lights illuminate the scene from a specific direction, similar to sunlight. DirectionalLight sunlight = new DirectionalLight(); sunlight.Enabled = true; sunlight.DiffuseColor = new Vector3(1.0f, 0.97f, 0.77f); sunlight.Intensity = 2.6f; sunlight.Direction = new Vector3(-0.60f, -0.73f, -0.32f); sunlight.ShadowType = ShadowType.AllObjects; sunlight.ShadowQuality = 1.0f; sunlight.ShadowPrimaryBias = 1.0f; sunlight.ShadowSecondaryBias = 0.04f; DirectionalLight sunlightB = new DirectionalLight(); sunlightB.Enabled = true; sunlightB.DiffuseColor = new Vector3(0.0f, 0.97f, 0.77f); sunlightB.Intensity = 2.6f; sunlightB.Direction = new Vector3(0.60f, -0.73f, -0.32f); sunlightB.ShadowType = ShadowType.AllObjects; sunlightB.ShadowQuality = 1.0f; sunlightB.ShadowPrimaryBias = 1.0f; sunlightB.ShadowSecondaryBias = 0.04f; // Add the lights to a group. LightGroup group = new LightGroup(); group.Add(ambientlight); group.Add(sunlight); group.Add(sunlightB); // Add the group to the light rig and commit the changes. rig.LightGroups.Add(group); rig.CommitChanges(); // Submit the light rig to the light manager. sceneInterface.LightManager.Submit(rig); // Setup the scene settings. environment = new SceneEnvironment(); environment.VisibleDistance = 250; environment.FogEnabled = true; environment.FogColor = new Vector3(0.5f, 0.5f, 0.5f); environment.FogStartDistance = 200; environment.FogEndDistance = 250; environment.ShadowFadeStartDistance = 200; environment.ShadowFadeEndDistance = 250; environment.ShadowCasterDistance = 250; // Apply the user preferences (example - not required). sceneInterface.ApplyPreferences(preferences); }
protected void OnStopEvent(List<int> value) { LightGroup group = new LightGroup( GetLightViewPresentersFromIndices(value), mLightState); foreach (SineControl sineCtrl in mSineControls) { sineCtrl.Stop(); } mLightState.Update(); }