public override void PosDrawPhase(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, SceneControl.RenderHelper render, Cameras.ICamera cam, IList<Light.ILight> lights) { SimpleTree tree = (obj.Modelo as TreeModel).Tree; tree.DrawLeaves(obj.WorldMatrix, cam.View, cam.Projection, false); render.ResyncStates(); render.SetSamplerStates(ginfo.SamplerState); }
/// <summary> /// Takes the picture from the given camera /// </summary> /// <param name="camera"></param> /// <param name="cameras"></param> public void TakePicture(Camera camera, Cameras cameras) { int jpegCompressionRate = 20; string saveToPath = GetImageSavePath(camera); cameras.Get(camera.CameraName) .SavePicture(new PictureSize(camera.PictureWidth , camera.PictureHeight) , saveToPath , jpegCompressionRate); }
/// <summary> /// Updates !!! /// </summary> /// <param name="gt">The gt.</param> /// <param name="camera">The camera.</param> protected override void Update(Microsoft.Xna.Framework.GameTime gt, Cameras.ICamera camera) { Emiter.Position = follower.PhysicObject.Position; Emiter.Velocity = follower.PhysicObject.Velocity; Emiter.Forward = follower.PhysicObject.FaceVector; Listener.Position = camera.Position; Listener.Up = camera.Up; SoundEngineInstance.Apply3D(Listener, Emiter); }
protected void btnModify_Click(object sender, EventArgs e) { Cameras c = new Cameras(); c.Assertno = txtAssertNo.Text; c.Caremano = txtCameraNo.Text; c.Customeraddress = txtCustomerAddress.Text; c.Customername = txtCustomerName.Text; c.Handleno = txtHandleNo.Text; c.Info = txtInfo.Text; c.Installdate = txtInstalldate.Text.Trim() == "" ? DateTime.Now : Convert.ToDateTime(txtInstalldate.Text.Trim()); c.Installplace = txtInstallPlace.Text; c.Junctionboxno = txtJunctionBoxNo.Text; c.Latitude = txtLatitude.Text.Trim() == "" ? 0 : Convert.ToDouble(txtLatitude.Text.Trim()); c.Linkman = txtLinkman.Text; c.Linkman_phone = txtLinkmanPhone.Text; c.Longitude = txtLongitude.Text.Trim() == "" ? 0 : Convert.ToDouble(txtLongitude.Text.Trim()); c.Singleplace = txtSinglePlace.Text; c.Storagetime = txtStorageTime.Text; c.Baudrate = ddlBaudrate.SelectedValue; c.Caremakind = ddlCameraKind.SelectedValue; c.Carematype = ddlCameraType.SelectedValue; c.Codeaddr = ddlCodeAddr.SelectedValue; c.Codestream = ddlCodeStream.SelectedValue; c.Controlprotocol = ddlControlProtocol.SelectedValue; c.Customertype = ddlCustomerType.SelectedValue; c.Devicelevel = ddlDeviceLevel.SelectedValue; c.Devicemanu = ddlDeviceManu.SelectedValue; c.Devicepropertyright = ddlDevicePropertyRight.SelectedValue; c.Devicestate = ddlDeviceState.SelectedValue; c.Dvsport = ddlDvsPort.SelectedValue; c.Installmode = ddlInstallMode.SelectedValue; c.Paymenttype = ddlPaymentType.SelectedValue; c.Powertype = ddlPowerType.SelectedValue; c.Powervoltage = ddlPowerVoltage.SelectedValue; c.Storagetype = ddlStorageType.SelectedValue; c.Switchinmode = ddlSwitchinMode.SelectedValue; c.Switchinplace = ddlSwitchinPlace.SelectedValue; c.Dvsid = hdfDvsID.Value; c.Suburb = hdfSuburbID.Value; if (hdfCameraID.Value == "0" || hdfCameraID.Value == "") //新增 { CameraManager cm = new CameraManager(); cm.NewCamera(c, Session["userid"].ToString()); hdfCameraID.Value = c.Id.ToString(); btnModify.Text = "确定修改"; } else { c.Id = DataGlobal.ConvertToInt(hdfCameraID.Value); CameraManager cm = new CameraManager(); cm.ModifyCamera(c, Session["userid"].ToString()); } }
/// <summary> /// Draw /// </summary> /// <param name="gt">gametime</param> /// <param name="obj">the obj</param> /// <param name="render">The render.</param> /// <param name="cam">The cam.</param> /// <param name="lights"></param> protected override void Draw(GameTime gt, IObject obj, RenderHelper render, Cameras.ICamera cam, IList<Light.ILight> lights) { base.Draw(gt, obj, render, cam, lights); effect.View = cam.View; effect.Projection = cam.Projection; for (int i = 0; i < obj.Modelo.MeshNumber; i++) { BatchInformation[] bi = obj.Modelo.GetBatchInformation(i); for (int j = 0; j < bi.Count(); j++) { effect.Texture = obj.Modelo.getTexture(Modelo.TextureType.DIFFUSE,i,j); effect.World = bi[j].ModelLocalTransformation * obj.WorldMatrix; render.RenderBatch(bi[j],effect); } } }
public static List<Cameras> GetCameras() { var cameras = _Cameras; var index = 0; var cameraInfo = new List<Cameras>(); foreach (var currentCamera in cameras) { var camera = new Cameras { Id = currentCamera.Key, Name = new FilterInfoCollection(FilterCategory.VideoInputDevice)[index].Name, CameraStatus = currentCamera.Value.IsRunning }; cameraInfo.Add(camera); index++; } return cameraInfo; }
/* * public static void initVLC() * { * if (Environment.Is64BitOperatingSystem) * { * // Set libvlc.dll and libvlccore.dll directory path * VlcContext.LibVlcDllsPath = @"VLC\"; * * // Set the vlc plugins directory path * VlcContext.LibVlcPluginsPath = @"VLC\plugins"; * } * else * { * // Set libvlc.dll and libvlccore.dll directory path * VlcContext.LibVlcDllsPath = @"VLC\"; * * // Set the vlc plugins directory path * VlcContext.LibVlcPluginsPath = @"VLC\plugins"; * } * * // Ignore the VLC configuration file * VlcContext.StartupOptions.IgnoreConfig = true; #if DEBUG * // Enable file based logging * VlcContext.StartupOptions.LogOptions.LogInFile = true; * * // Shows the VLC log console (in addition to the applications window) * VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true; #else * VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = false; * VlcContext.StartupOptions.LogOptions.LogInFile = false; #endif * // Set the log level for the VLC instance * VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Debug; * VlcContext.StartupOptions.AddOption("--ffmpeg-hw"); * // Disable showing the movie file name as an overlay * VlcContext.StartupOptions.AddOption("--no-video-title-show"); * VlcContext.StartupOptions.AddOption("--rtsp-tcp"); * VlcContext.StartupOptions.AddOption("--rtsp-mcast"); * // VlcContext.StartupOptions.AddOption("--rtsp-host=192.168.10.35"); * // VlcContext.StartupOptions.AddOption("--sap-addr=192.168.10.35"); * VlcContext.StartupOptions.AddOption("--rtsp-port=8554"); * VlcContext.StartupOptions.AddOption("--rtp-client-port=8554"); * VlcContext.StartupOptions.AddOption("--sout-rtp-rtcp-mux"); * VlcContext.StartupOptions.AddOption("--rtsp-wmserver"); * * * VlcContext.StartupOptions.AddOption("--file-caching=18000"); * VlcContext.StartupOptions.AddOption("--sout-rtp-caching=18000"); * VlcContext.StartupOptions.AddOption("--sout-rtp-port=8554"); * VlcContext.StartupOptions.AddOption("--sout-rtp-proto=tcp"); * VlcContext.StartupOptions.AddOption("--network-caching=1000"); * * VlcContext.StartupOptions.AddOption("--vout-filter=wall"); * VlcContext.StartupOptions.AddOption("--wall-cols=2"); * VlcContext.StartupOptions.AddOption("--wall-rows=2"); * * // Pauses the playback of a movie on the last frame * VlcContext.StartupOptions.AddOption("--play-and-pause"); * VlcContext.CloseAll(); * // Initialize the VlcContext * VlcContext.Initialize(); * } */ private void Application_Startup(object sender, StartupEventArgs e) { bool login = true; Rows = new List <CsvRow>(); RowsSend = new List <CsvRow>(); Fonts = ExCss.ReadFile(@"Asset\Fonts\font-awesome.min.css"); Timethread = new Thread(CheckTimeFunctionThread); Timethread.IsBackground = true; listSerialPort = new List <SerialPort>(); QueueCMD = new Queue <string>(); m_bInitSDK = CHCNetSDK.NET_DVR_Init(); if (m_bInitSDK == false) { MessageBox.Show("NET_DVR_Init error!"); return; } if (!File.Exists(_FILE_CSV_COMMAND)) { File.Create(_FILE_CSV_COMMAND); } if (!File.Exists(_FILE_Send_COMMAND)) { File.Create(_FILE_Send_COMMAND); } // initVLC(); DefineCommand = CommandDefine.Read(_FILE_DEFINE_COMMAND); setting = Config.Read(_FILE_Config); if (!Directory.Exists("Data")) { DirectoryInfo di = Directory.CreateDirectory("Data"); di.Attributes = FileAttributes.Directory | FileAttributes.Hidden; } if (!Directory.Exists(setting.Folder)) { Directory.CreateDirectory(setting.Folder); } curDate = DateTime.Now; Timethread.Start(); curFolder = System.IO.Path.Combine(setting.Folder, this.curDate.ToString("dd-MM-yyyy")); if (!Directory.Exists(curFolder)) { Directory.CreateDirectory(curFolder); } DataUser = Users.read(@"Data\User.mtc"); if (DataUser == null) { DataUser = new Users(); User root = new User("root", 1); root.Pass = "******".toMD5(); root.type = 0; root.FullName = "Root"; DataUser.Add(root); Users.write(_FILE_User_Data, DataUser); } DataCamera = Cameras.Read(_FILE_Camera_Data); DataPreset = Presets.Read(_FILE_PRESET_DATA); DataAlarm = Alarms.Read(_FILE_Alarm_Data); this.checkFile = new Thread(checkFileFunctionThread); checkFile.IsBackground = true; this.checkFile.Start(); #if DEBUG if (DataCamera.Count == 0) { Camera camera = new Camera("192.168.10.199"); camera.name = "Camera Demo"; camera.channel = 1; camera.port = 8000; camera.admin = "admin"; camera.pass = "******"; camera.icon = "fa-video-camera"; DataCamera.Add(camera); } if (DataUser.Datas.Count < 2) { User root = new User("admin", 2); root.Pass = "******".toMD5(); root.type = 1; root.FullName = "Admin"; DataUser.Add(root); User root2 = new User("htdm", 3); root2.Pass = "******".toMD5(); root2.type = 2; root2.FullName = "Camera"; DataUser.Add(root2); Users.write(_FILE_User_Data, DataUser); } #endif var listCom = getListCOM(); if (listCom.Length > 0) { foreach (string i in listCom) { try { SerialPort serialPort = new SerialPort(); serialPort = new SerialPort(); serialPort.openCOM(i, BAUDRATE, DATABITS, StopBits.One); serialPort.DataReceived += serialPort_DataReceived; serialPort.sendCommand("#0$"); listSerialPort.Add(serialPort); } catch (Exception) { } } } Map = Map.Read(_FILE_Map_Data); for (int i = 0; i != e.Args.Length; i += 2) { if (e.Args[i] == "-u") { string hash = e.Args[i + 1]; User u = App.DataUser.Login(hash); if (u != null) { login = false; App.User = u; } } else if (e.Args[i] == "-mode") { Mode = (Camera_Final.Mode) int.Parse(e.Args[i + 1]); } } if (login) { this.MainWindow = new Login(); } else { this.MainWindow = new MainWindow(); } this.MainWindow.Show(); }
public void Drawn(Microsoft.Xna.Framework.GameTime gt, IObject obj, Cameras.ICamera cam, IList<ILight> lights, RenderHelper render) { shader.Draw(gt, obj, render, cam,lights); }
/* public static void initVLC() { if (Environment.Is64BitOperatingSystem) { // Set libvlc.dll and libvlccore.dll directory path VlcContext.LibVlcDllsPath = @"VLC\"; // Set the vlc plugins directory path VlcContext.LibVlcPluginsPath = @"VLC\plugins"; } else { // Set libvlc.dll and libvlccore.dll directory path VlcContext.LibVlcDllsPath = @"VLC\"; // Set the vlc plugins directory path VlcContext.LibVlcPluginsPath = @"VLC\plugins"; } // Ignore the VLC configuration file VlcContext.StartupOptions.IgnoreConfig = true; #if DEBUG // Enable file based logging VlcContext.StartupOptions.LogOptions.LogInFile = true; // Shows the VLC log console (in addition to the applications window) VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true; #else VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = false; VlcContext.StartupOptions.LogOptions.LogInFile = false; #endif // Set the log level for the VLC instance VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Debug; VlcContext.StartupOptions.AddOption("--ffmpeg-hw"); // Disable showing the movie file name as an overlay VlcContext.StartupOptions.AddOption("--no-video-title-show"); VlcContext.StartupOptions.AddOption("--rtsp-tcp"); VlcContext.StartupOptions.AddOption("--rtsp-mcast"); // VlcContext.StartupOptions.AddOption("--rtsp-host=192.168.10.35"); // VlcContext.StartupOptions.AddOption("--sap-addr=192.168.10.35"); VlcContext.StartupOptions.AddOption("--rtsp-port=8554"); VlcContext.StartupOptions.AddOption("--rtp-client-port=8554"); VlcContext.StartupOptions.AddOption("--sout-rtp-rtcp-mux"); VlcContext.StartupOptions.AddOption("--rtsp-wmserver"); VlcContext.StartupOptions.AddOption("--file-caching=18000"); VlcContext.StartupOptions.AddOption("--sout-rtp-caching=18000"); VlcContext.StartupOptions.AddOption("--sout-rtp-port=8554"); VlcContext.StartupOptions.AddOption("--sout-rtp-proto=tcp"); VlcContext.StartupOptions.AddOption("--network-caching=1000"); VlcContext.StartupOptions.AddOption("--vout-filter=wall"); VlcContext.StartupOptions.AddOption("--wall-cols=2"); VlcContext.StartupOptions.AddOption("--wall-rows=2"); // Pauses the playback of a movie on the last frame VlcContext.StartupOptions.AddOption("--play-and-pause"); VlcContext.CloseAll(); // Initialize the VlcContext VlcContext.Initialize(); } */ private void Application_Startup(object sender, StartupEventArgs e) { bool login = true; Rows = new List<CsvRow>(); RowsSend = new List<CsvRow>(); Fonts = ExCss.ReadFile(@"Asset\Fonts\font-awesome.min.css"); Timethread = new Thread(CheckTimeFunctionThread); Timethread.IsBackground = true; listSerialPort = new List<SerialPort>(); QueueCMD = new Queue<string>(); m_bInitSDK = CHCNetSDK.NET_DVR_Init(); if (m_bInitSDK == false) { MessageBox.Show("NET_DVR_Init error!"); return; } if (!File.Exists(_FILE_CSV_COMMAND)) { File.Create(_FILE_CSV_COMMAND); } if (!File.Exists(_FILE_Send_COMMAND)) { File.Create(_FILE_Send_COMMAND); } // initVLC(); DefineCommand = CommandDefine.Read(_FILE_DEFINE_COMMAND); setting = Config.Read(_FILE_Config); if (!Directory.Exists("Data")) { DirectoryInfo di = Directory.CreateDirectory("Data"); di.Attributes = FileAttributes.Directory | FileAttributes.Hidden; } if (!Directory.Exists(setting.Folder)) { Directory.CreateDirectory(setting.Folder); } curDate = DateTime.Now; Timethread.Start(); curFolder = System.IO.Path.Combine(setting.Folder, this.curDate.ToString("dd-MM-yyyy")); if (!Directory.Exists(curFolder)) { Directory.CreateDirectory(curFolder); } DataUser = Users.read(@"Data\User.mtc"); if (DataUser == null) { DataUser = new Users(); User root = new User("root", 1); root.Pass = "******".toMD5(); root.type = 0; root.FullName = "Root"; DataUser.Add(root); Users.write(_FILE_User_Data, DataUser); } DataCamera = Cameras.Read(_FILE_Camera_Data); DataPreset = Presets.Read(_FILE_PRESET_DATA); DataAlarm = Alarms.Read(_FILE_Alarm_Data); this.checkFile = new Thread(checkFileFunctionThread); checkFile.IsBackground = true; this.checkFile.Start(); #if DEBUG if (DataCamera.Count == 0) { Camera camera = new Camera("192.168.10.199"); camera.name = "Camera Demo"; camera.channel = 1; camera.port = 8000; camera.admin = "admin"; camera.pass = "******"; camera.icon = "fa-video-camera"; DataCamera.Add(camera); } if (DataUser.Datas.Count < 2) { User root = new User("admin", 2); root.Pass = "******".toMD5(); root.type = 1; root.FullName = "Admin"; DataUser.Add(root); User root2 = new User("htdm",3); root2.Pass = "******".toMD5(); root2.type = 2; root2.FullName = "Camera"; DataUser.Add(root2); Users.write(_FILE_User_Data, DataUser); } #endif var listCom = getListCOM(); if (listCom.Length > 0) { foreach (string i in listCom) { try { SerialPort serialPort = new SerialPort(); serialPort = new SerialPort(); serialPort.openCOM(i, BAUDRATE, DATABITS, StopBits.One); serialPort.DataReceived += serialPort_DataReceived; serialPort.sendCommand("#0$"); listSerialPort.Add(serialPort); } catch (Exception) { } } } Map = Map.Read(_FILE_Map_Data); for (int i = 0; i != e.Args.Length; i += 2) { if (e.Args[i] == "-u") { string hash = e.Args[i + 1]; User u = App.DataUser.Login(hash); if (u != null) { login = false; App.User = u; } } else if (e.Args[i] == "-mode") { Mode = (Camera_Final.Mode)int.Parse(e.Args[i + 1]); } } if (login) { this.MainWindow = new Login(); } else { this.MainWindow = new MainWindow(); } this.MainWindow.Show(); }
public static void RemoveCamera(Camera2D camera) { Cameras.Remove(camera); }
/// <summary> /// Updates . /// </summary> /// <param name="gt">The gt.</param> /// <param name="camera">The camera.</param> protected override void Update(Microsoft.Xna.Framework.GameTime gt, Cameras.ICamera camera) { Listener.Position = camera.Position; Listener.Up = camera.Up; SoundEngineInstance.Apply3D(Listener, Emiter); }
public override void Reset() { Cameras.Clear(); CurrentCamera = 0; }
protected override void DebugDrawn(SceneControl.RenderHelper render, GameTime gt, Cameras.ICamera cam) { throw new System.NotImplementedException(); }
public virtual int Add(Cameras.Camera value) { return List.Add(value); }
protected internal override void Render(Scenes.Scene scene, Cameras.Camera camera, int viewportWidth, int viewportHeight) { sprites.Clear(); scene.TraverseVisible(c => { var sprite = c as Sprite; if (sprite != null) sprites.Add(sprite); }); if (sprites.Count == 0) return; // setup gl GL.UseProgram( program ); GL.EnableVertexAttribArray( attributes.position ); GL.EnableVertexAttribArray( attributes.uv ); GL.Disable( EnableCap.CullFace); GL.Enable( EnableCap.Blend); GL.BindBuffer( BufferTarget.ArrayBuffer, vertexBuffer ); GL.VertexAttribPointer( attributes.position, 2, VertexAttribPointerType.Float, false, 2 * 8, 0 ); GL.VertexAttribPointer( attributes.uv, 2, VertexAttribPointerType.Float, false, 2 * 8, 8 ); GL.BindBuffer(BufferTarget.ElementArrayBuffer, elementBuffer ); GL.UniformMatrix4(uniforms.projectionMatrix, 16, false, camera.projectionMatrix.elements); GL.ActiveTexture(TextureUnit.Texture0); GL.Uniform1( uniforms.map, 0 ); var oldFogType = 0; var sceneFogType = 0; var fog = scene.Fog; if (fog != null) { GL.Uniform3(uniforms.fogColor, scene.Fog.Color.R, scene.Fog.Color.G, scene.Fog.Color.B); var linear = fog as FogLinear; var exp2 = fog as FogExp2; if (linear != null) { GL.Uniform1( uniforms.fogNear, linear.Near); GL.Uniform1( uniforms.fogFar, linear.Far); GL.Uniform1( uniforms.fogType, 1 ); oldFogType = 1; sceneFogType = 1; } else if ( exp2 != null) { GL.Uniform1( uniforms.fogDensity, exp2.Density); GL.Uniform1( uniforms.fogType, 2 ); oldFogType = 2; sceneFogType = 2; } } else { GL.Uniform1( uniforms.fogType, 0 ); oldFogType = 0; sceneFogType = 0; } // update positions and sort foreach( var sprite in sprites) { var material = sprite.Material; sprite.modelViewMatrix.MultiplyMatrices( camera.matrixWorldInverse, sprite.matrixWorld ); sprite.Zdepth = -sprite.modelViewMatrix.elements[ 14 ]; } sprites.Sort( PainterSortStable ); // render all sprites foreach( var sprite in sprites) { var material = sprite.Material as SpriteMaterial; GL.Uniform1( uniforms.alphaTest, material.ShouldAlphaTest); GL.UniformMatrix4( (int)uniforms.modelViewMatrix, 16, false, sprite.modelViewMatrix.elements ); var fogType = 0; if ( scene.Fog != null && material.UseFog) fogType = sceneFogType; if ( oldFogType != fogType ) { GL.Uniform1( uniforms.fogType, fogType ); oldFogType = fogType; } if ( material.DiffuseMap != null ) { GL.Uniform2(uniforms.uvOffset, material.DiffuseMap.Offset.x, material.DiffuseMap.Offset.y); GL.Uniform2(uniforms.uvScale, material.DiffuseMap.Repeat.x, material.DiffuseMap.Repeat.y); } else { GL.Uniform2( uniforms.uvOffset, 0, 0 ); GL.Uniform2( uniforms.uvScale, 1, 1 ); } GL.Uniform1( uniforms.opacity, material.Opacity ); GL.Uniform3(uniforms.color, material.Diffuse.R, material.Diffuse.G, material.Diffuse.B); GL.Uniform1( uniforms.rotation, material.Rotation); GL.Uniform2( uniforms.scale, sprite.Scale.x, sprite.Scale.y); renderer.SetBlending( material.Blending, material.BlendEquation, material.BlendSource, material.BlendDestination); renderer.DepthTest = material.ShouldDepthTest; renderer.DepthWrite = material.ShouldDepthWrite; if ( material.DiffuseMap != null && material.DiffuseMap.Resolution.Width > 0) renderer.SetTexture( material.DiffuseMap, 0 ); else renderer.SetTexture(texture, 0 ); GL.DrawElements( BeginMode.TriangleFan, 6, DrawElementsType.UnsignedShort, 0 ); } // restore gl GL.Enable( EnableCap.CullFace); }
/// <summary> /// Normal Draw Function. /// </summary> /// <param name="gt">The gt.</param> /// <param name="obj">The obj.</param> /// <param name="cam">The cam.</param> /// <param name="lights">The lights.</param> /// <param name="render">The render.</param> public void Drawn(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList<Light.ILight> lights, SceneControl.RenderHelper render) { PhysxFluidObject PhysxFluidObject = obj.PhysicObject as PhysxFluidObject; InstancedBilboardModel InstancedBilboardModel = obj.Modelo as InstancedBilboardModel; if (!PhysxFluidObject.Fluid.ParticleWriteData.NumberOfParticles.HasValue) return; Phyx.Vector3[] pos = PhysxFluidObject.Fluid.ParticleWriteData.PositionBuffer.GetData<Phyx.Vector3>(); BilboardInstance[] inst = new Modelo.BilboardInstance[PhysxFluidObject.Fluid.ParticleWriteData.NumberOfParticles.Value]; for (int i = 0; i < PhysxFluidObject.Fluid.ParticleWriteData.NumberOfParticles; i++) { inst[i] = BilboardInstance[i]; inst[i].Position = pos[i].AsXNA(); } InstancedBilboardModel.SetBilboardInstances(inst); shader.iDraw(gt, obj, render, cam, lights); }
public HttpVideoServer(int port, Cameras cameras) : this(new [] { "http://home.romcyber.com:" + port + "/" }) { this.cameras = cameras; }
public override void draw() { if (_flickerTimer != 0) { _flicker = !_flicker; if (_flicker) { return; } } FlxCamera camera = FlxG.camera; //._activeCamera; if (Cameras == null) { Cameras = FlxG.cameras; } if (!Cameras.Contains(camera)) { return; } if (!onScreen(camera)) { return; } _tagPoint.X = X - (camera.Scroll.X * ScrollFactor.X) - Offset.X; _tagPoint.Y = Y - (camera.Scroll.Y * ScrollFactor.Y) - Offset.Y; _tagPoint.X += (_tagPoint.X > 0) ? 0.0000001f : -0.0000001f; _tagPoint.Y += (_tagPoint.Y > 0) ? 0.0000001f : -0.0000001f; // scaling if (Scale.X != 1f || Scale.Y != 1f) { //_textField.getFont().setScale(Scale.X, Scale.Y); calcFrame(); } // position //_textField.setPosition(_tagPoint.X, _tagPoint.Y); // rotation if (Angle != 0) { /* * _matrix = FlxG.Batch.getTransformMatrix().cpy(); * * Matrix4 rotationMatrix = FlxG.batch.getTransformMatrix(); * rotationMatrix.translate(_textField.getX() + (width / 2), _textField.getY() + (height / 2), 0); * rotationMatrix.rotate(0, 0, 1, angle); * rotationMatrix.translate(-(_textField.getX() + (width / 2)), -(_textField.getY() + (height / 2)), 0); * * FlxG.batch.setTransformMatrix(rotationMatrix); */ } /* * // blending * if(blend != null && currentBlend != blend) * { * int[] blendFunc = BlendMode.getOpenGLBlendMode(blend); * FlxG.batch.setBlendFunction(blendFunc[0], blendFunc[1]); * } * else if(FlxG.batchShader == null || ignoreBatchShader) * { * // OpenGL ES 2.0 shader render * renderShader(); * // OpenGL ES 2.0 blend mode render * renderBlend(); * } */ // distance field if (_distanceFieldEnabled) { drawDistanceField(); } int tintColor; /* * // Render shadow behind the text * if(_shadow != 0) * { * // tinting * tintColor = FlxU.multiplyColors(_shadow, camera.getColor()); * _textField.setColors(((tintColor >> 16) & 0xFF) * 0.00392f, ((tintColor >> 8) & 0xFF) * 0.00392f, (tintColor & 0xFF) * 0.00392f, ((_shadow >> 24) & 0xFF) * _alpha * 0.00392f); * _textField.translate(_shadowX, _shadowY); * _textField.draw(FlxG.batch); * _textField.translate(-_shadowX, -_shadowY); * } * * // tinting * tintColor = FlxU.multiplyColors(_color, camera.getColor()); * _textField.setColors(((tintColor >> 16) & 0xFF) * 0.00392f, ((tintColor >> 8) & 0xFF) * 0.00392f, (tintColor & 0xFF) * 0.00392f, _alpha); * * _textField.draw(FlxG.batch); * * // turn off distance field * if(_distanceFieldEnabled) * FlxG.batch.setShader(null); * * // rotation * if(Angle != 0) * FlxG.batch.setTransformMatrix(_matrix); * * _VISIBLECOUNT++; * * if(FlxG.visualDebug && !ignoreDrawDebug) * drawDebug(camera); */ Point point = bounds.Center; Vector2 pos = new Vector2(point.X, point.Y); if (_alignment == "RIGHT") { pos.X += Width - textWidth; } if (_alignment == "CENTER") { pos.X += ((Width - textWidth) / 2); } pos.Y += ((Height - textHeight) / 2); // Render shadow behind the text if (_shadow != Color.Transparent) { FlxS.SpriteBatch.DrawString(LoadedFont, text, new Vector2(pos.X + _shadowX, pos.Y + _shadowY), _shadow, 0, origin, _size / _default_size, SpriteEffects.None, 0); } FlxS.SpriteBatch.DrawString(LoadedFont, text, pos, Color, 0, origin, _size / _default_size, SpriteEffects.None, 0); }
/// <summary> /// Update Inputs, Plugins & Cameras /// </summary> /// <param name="gameTime"></param> public static void Update(GameTime gameTime) { InputManager.Update(gameTime); Plugins.Update(gameTime); Cameras.Update(gameTime); }
protected override void DebugDrawn(SceneControl.RenderHelper render, GameTime gt, Cameras.ICamera cam) { if (BasicEffect == null) { BasicEffect = new BasicEffect(render.device); BasicEffect.VertexColorEnabled = true; BasicEffect.TextureEnabled = false; } //if (_fetchedResults == false) { DebugRenderable RenderBuffer = Scene.GetDebugRenderable(); if (RenderBuffer == null || (RenderBuffer.TriangleCount == 0 && RenderBuffer.LineCount == 0)) return; Color c = Color.Red; if (RenderBuffer.TriangleCount > 0) { VertexPositionColor1 = new VertexPositionColor[RenderBuffer.TriangleCount * 3]; for (int i = 0, j = 0; i < RenderBuffer.TriangleCount; i += 3, j++) { VertexPositionColor1[i].Color = c; VertexPositionColor1[i].Position = RenderBuffer.GetDebugTriangles()[j].Point0.AsXNA(); VertexPositionColor1[i + 1].Color = c; VertexPositionColor1[i + 1].Position = RenderBuffer.GetDebugTriangles()[j].Point1.AsXNA(); VertexPositionColor1[i + 2].Color = c; VertexPositionColor1[i + 2].Position = RenderBuffer.GetDebugTriangles()[j].Point2.AsXNA(); } } if (RenderBuffer.LineCount > 0) { VertexPositionColor2 = new VertexPositionColor[RenderBuffer.LineCount * 2]; for (int i = 0, j = 0; i < RenderBuffer.LineCount; i += 2, j++) { VertexPositionColor2[i].Color = c; VertexPositionColor2[i].Position = RenderBuffer.GetDebugLines()[j].Point0.AsXNA(); VertexPositionColor2[i + 1].Color = c; VertexPositionColor2[i + 1].Position = RenderBuffer.GetDebugLines()[j].Point1.AsXNA(); } } } BasicEffect.View = cam.View; BasicEffect.Projection = cam.Projection; BasicEffect.World = Matrix.Identity; if(VertexPositionColor2 != null) render.RenderUserPrimitive<VertexPositionColor>(BasicEffect, PrimitiveType.LineList, VertexPositionColor2, 0, VertexPositionColor2.Length / 2); if (VertexPositionColor1 != null) render.RenderUserPrimitive<VertexPositionColor>(BasicEffect, PrimitiveType.TriangleList, VertexPositionColor1, 0, VertexPositionColor1.Length / 3); }
/// <summary> /// Normal Drawn Function. /// </summary> /// <param name="gt">The gt.</param> /// <param name="obj">The obj.</param> /// <param name="cam">The cam.</param> /// <param name="lights">The lights.</param> /// <param name="render">The render.</param> public void Drawn(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList<Light.ILight> lights, SceneControl.RenderHelper render) { if (isupdated == false) { QuadTerrain.UpdateTerrain(cam.Position, cam.BoundingFrustum, LOD); } WorldMatrix.SetValue(obj.PhysicObject.WorldMatrix); ViewMatrix.SetValue(cam.View); ProjectionMatrix.SetValue(cam.Projection); TerrainShader.CurrentTechnique = TerrainShader.Techniques["Technique2"]; TerrainShader.CurrentTechnique.Passes[0].Apply(); QuadTerrain.DrawTerrain(TerrainShader, render.device); render.ResyncStates(); isupdated = false; render.SetSamplerStates(ginfo.SamplerState,6); }
public virtual void Remove(Cameras.Camera value) { List.Remove(value); }
protected override void DebugDrawn(SceneControl.RenderHelper render, GameTime gt, Cameras.ICamera cam) { }
/// <summary> /// Initializes the cameras from the database. /// </summary> private void InitializeCameras() { availableCameras = new CameraQuery().GetAllCamera(); camBuilder = Cameras.DeclareDevice().Named(availableCameras[1].CameraName).WithDevicePath(availableCameras[1].Path) .AndDevice().Named(availableCameras[0].CameraName).WithDevicePath(availableCameras[0].Path); cameras = camBuilder.Memorize(); }
protected internal override void Render(Scenes.Scene scene, Cameras.Camera camera, int viewportWidth, int viewportHeight) { throw new NotImplementedException(); }
/// <summary> /// Normal Drawn Function. /// </summary> /// <param name="gt">The gt.</param> /// <param name="obj">The obj.</param> /// <param name="cam">The cam.</param> /// <param name="lights">The lights.</param> /// <param name="render">The render.</param> public void Drawn(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList<Light.ILight> lights, SceneControl.RenderHelper render) { shader.iDraw(gt, obj, render, cam,lights); }
/// <summary> /// Draws the specified gt. /// </summary> /// <param name="gt">The gt.</param> /// <param name="obj">The obj.</param> /// <param name="render">The render.</param> /// <param name="cam">The cam.</param> /// <param name="lights">The lights.</param> protected override void Draw(GameTime gt, SceneControl.IObject obj, SceneControl.RenderHelper render, Cameras.ICamera cam, System.Collections.Generic.IList<Light.ILight> lights) { }
/// <summary> /// This is the main function of the class, it'll create a triangulated polygon /// from and SceneObject. /// </summary> /// <param name="sourceObject">The object to convert.</param> /// <param name="guarenteedView">A camera that can see the whole object.</param> /// <returns>A polygon created from 'sourceObject'.</returns> public Polygon CreatePolygon(OpenGL gl, SceneObject sourceObject, Cameras.Camera guarenteedView) { // Save the current camera data. gl.MatrixMode(OpenGL.PROJECTION); gl.PushMatrix(); // Look through the camera that can see the object. guarenteedView.Project(gl); // Start triangulation. Begin(gl); // Draw the object. sourceObject.Draw(gl); // End triangulation. End(gl); Polygon newPoly = Triangle; newPoly.Name = sourceObject.Name + " (Triangulated Poly)"; return newPoly; }
public override void Draw(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, RenderHelper render, Cameras.ICamera cam) { effect.Texture = obj.Modelo.getTexture(Modelo.TextureType.DIFFUSE); effect.View = cam.View; effect.Projection = cam.Projection; for (int i = 0; i < obj.Modelo.MeshNumber; i++) { BatchInformation[] bi = obj.Modelo.GetBatchInformation(i); for (int j = 0; j < bi.Count(); j++) { effect.World = bi[j].ModelLocalTransformation; effect.CurrentTechnique.Passes[0].Apply(); render.RenderBatch(ref bi[j]); } } }
/// <summary> /// Normal Drawn Function. /// </summary> /// <param name="gt">The gt.</param> /// <param name="obj">The obj.</param> /// <param name="cam">The cam.</param> /// <param name="lights">The lights.</param> /// <param name="render">The render.</param> public void Drawn(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList<Light.ILight> lights, SceneControl.RenderHelper render) { WorldMatrix.SetValue(obj.PhysicObject.WorldMatrix); ViewMatrix.SetValue(cam.View); ProjectionMatrix.SetValue(cam.Projection); TerrainShader.CurrentTechnique = TerrainShader.Techniques["Technique1"]; TerrainShader.CurrentTechnique.Passes[0].Apply(); QuadTerrain.DrawTerrain(TerrainShader, render.device); render.ResyncStates(); }
public void PreDrawnPhase(Microsoft.Xna.Framework.GameTime gt, IWorld mundo, IObject obj, Cameras.ICamera cam, IList<ILight> lights, RenderHelper render) { }
// Use this for initialization void Start() { GameObject cam = GameObject.FindWithTag("MainCamera"); camScript = cam.GetComponent <Cameras>(); }
/// <summary> /// Pre drawn Function. /// Called before all the objects are draw /// </summary> /// <param name="gt">The gt.</param> /// <param name="mundo">The mundo.</param> /// <param name="obj">The obj.</param> /// <param name="cam">The cam.</param> /// <param name="lights">The lights.</param> /// <param name="render">The render.</param> public void PreDrawnPhase(Microsoft.Xna.Framework.GameTime gt, SceneControl.IWorld mundo, SceneControl.IObject obj, Cameras.ICamera cam, IList<Light.ILight> lights, SceneControl.RenderHelper render) { shader.PreDrawPhase(gt, mundo, obj, render, cam); }
/// <summary> /// Normal Draw Function. /// </summary> /// <param name="gt">The gt.</param> /// <param name="obj">The obj.</param> /// <param name="cam">The cam.</param> /// <param name="lights">The lights.</param> /// <param name="render">The render.</param> public void Drawn(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList<Light.ILight> lights, SceneControl.RenderHelper render) { if (rasterizerState!= null && rasterizerState != render.PeekRasterizerState()) { rasterStateFlag = true; render.PushRasterizerState(rasterizerState); } shader.iDraw(gt, obj, render, cam, lights); if (rasterStateFlag) { render.PopRasterizerState(); rasterStateFlag = false; } }
/// <summary> /// Pos drawn Function. /// Called after all objects are Draw /// </summary> /// <param name="gt">The gt.</param> /// <param name="obj">The obj.</param> /// <param name="cam">The cam.</param> /// <param name="lights">The lights.</param> /// <param name="render">The render.</param> public void PosDrawnPhase(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList<Light.ILight> lights, SceneControl.RenderHelper render) { }
/// <summary> /// Normal Draw Function. /// </summary> /// <param name="gt">The gt.</param> /// <param name="obj">The obj.</param> /// <param name="cam">The cam.</param> /// <param name="lights">The lights.</param> /// <param name="render">The render.</param> public void Drawn(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList<Light.ILight> lights, SceneControl.RenderHelper render) { PhysxClothObject PhysxClothObject = obj.PhysicObject as PhysxClothObject; ClothModel ClothModel = obj.Modelo as ClothModel; StillDesign.PhysX.MathPrimitives.Vector3[] pos = PhysxClothObject.Cloth.GetMeshData().PositionsStream.GetData<StillDesign.PhysX.MathPrimitives.Vector3>(); StillDesign.PhysX.MathPrimitives.Vector3[] norm = PhysxClothObject.Cloth.GetMeshData().NormalsStream.GetData<StillDesign.PhysX.MathPrimitives.Vector3>(); for (int i = 0; i < ClothModel.BatchInformation.NumVertices; i++) { ClothModel.vertexPositionNormalTexture[i].Position = pos[i].AsXNA(); ClothModel.vertexPositionNormalTexture[i].Normal = norm[i].AsXNA(); } ClothModel.BatchInformation.VertexBuffer.SetData<VertexPositionNormalTexture>(ClothModel.vertexPositionNormalTexture); if (rasterizerState != null && rasterizerState != render.PeekRasterizerState()) { rasterStateFlag = true; render.PushRasterizerState(rasterizerState); } shader.iDraw(gt, obj, render, cam, lights); if (rasterStateFlag) { render.PopRasterizerState(); rasterStateFlag = false; } }
void InitializeModules() { repo = new Repository(); if (modules.Count > 0) { modules.Clear(); } drawing = new Drawing(); drawing.Enabled = false; // manual updating (so it only happens when XNA wants to draw) drawing.Subscribe(repo.Delegater); timing = new Timing(); timing.Subscribe(repo.Delegater); cameras = new Cameras(); cameras.Subscribe(repo.Delegater); modules.Add(drawing); modules.Add(timing); modules.Add(cameras); }
internal void OnLoad() { Mouse = window.Mouse; Keyboard = window.Keyboard; #if ANDROID Graphics = new OpenGLESApi(); #elif !USE_DX Graphics = new OpenGLApi(); #else Graphics = new Direct3D9Api(this); #endif Graphics.MakeApiInfo(); ErrorHandler.AdditionalInfo = Graphics.ApiInfo; #if ANDROID Drawer2D = new CanvasDrawer2D(Graphics); #else Drawer2D = new GdiPlusDrawer2D(Graphics); #endif Entities = new EntityList(this); AcceptedUrls.Load(); DeniedUrls.Load(); ETags.Load(); LastModified.Load(); if (Options.GetBool(OptionsKey.SurvivalMode, false)) { Mode = new SurvivalGameMode(); } else { Mode = new CreativeGameMode(); } Components.Add(Mode); Input = new InputHandler(this); defaultIb = Graphics.MakeDefaultIb(); ParticleManager = new ParticleManager(); Components.Add(ParticleManager); TabList = new TabList(); Components.Add(TabList); LoadOptions(); LoadGuiOptions(); Chat = new Chat(); Components.Add(Chat); WorldEvents.OnNewMap += OnNewMapCore; WorldEvents.OnNewMapLoaded += OnNewMapLoadedCore; Events.TextureChanged += TextureChangedCore; BlockInfo.Init(); ModelCache = new ModelCache(this); ModelCache.InitCache(); AsyncDownloader = new AsyncDownloader(Drawer2D); Components.Add(AsyncDownloader); Lighting = new BasicLighting(); Components.Add(Lighting); Drawer2D.UseBitmappedChat = ClassicMode || !Options.GetBool(OptionsKey.UseChatFont, false); Drawer2D.BlackTextShadows = Options.GetBool(OptionsKey.BlackText, false); Graphics.Mipmaps = Options.GetBool(OptionsKey.Mipmaps, false); TerrainAtlas1D = new TerrainAtlas1D(this); TerrainAtlas = new TerrainAtlas2D(this); Animations = new Animations(); Components.Add(Animations); Inventory = new Inventory(); Components.Add(Inventory); BlockInfo.SetDefaultPerms(); World = new World(this); LocalPlayer = new LocalPlayer(this); Components.Add(LocalPlayer); Entities.List[EntityList.SelfID] = LocalPlayer; Width = window.Width; Height = window.Height; MapRenderer = new MapRenderer(this); string renType = Options.Get(OptionsKey.RenderType) ?? "normal"; if (!SetRenderType(renType)) { SetRenderType("normal"); } if (IPAddress == null) { Server = new Singleplayer.SinglePlayerServer(this); } else { Server = new Network.NetworkProcessor(this); } Graphics.LostContextFunction = Server.Tick; Cameras.Add(new FirstPersonCamera(this)); Cameras.Add(new ThirdPersonCamera(this, false)); Cameras.Add(new ThirdPersonCamera(this, true)); Camera = Cameras[0]; UpdateProjection(); Gui = new GuiInterface(this); Components.Add(Gui); CommandList = new CommandList(); Components.Add(CommandList); SelectionManager = new SelectionManager(); Components.Add(SelectionManager); WeatherRenderer = new WeatherRenderer(); Components.Add(WeatherRenderer); HeldBlockRenderer = new HeldBlockRenderer(); Components.Add(HeldBlockRenderer); Graphics.DepthTest = true; Graphics.DepthTestFunc(CompareFunc.LessEqual); //Graphics.DepthWrite = true; Graphics.AlphaBlendFunc(BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha); Graphics.AlphaTestFunc(CompareFunc.Greater, 0.5f); Culling = new FrustumCulling(); Picking = new PickedPosRenderer(); Components.Add(Picking); AudioPlayer = new AudioPlayer(); Components.Add(AudioPlayer); AxisLinesRenderer = new AxisLinesRenderer(); Components.Add(AxisLinesRenderer); SkyboxRenderer = new SkyboxRenderer(); Components.Add(SkyboxRenderer); plugins = new PluginLoader(this); List <string> nonLoaded = plugins.LoadAll(); for (int i = 0; i < Components.Count; i++) { Components[i].Init(this); } ExtractInitialTexturePack(); for (int i = 0; i < Components.Count; i++) { Components[i].Ready(this); } InitScheduledTasks(); if (nonLoaded != null) { for (int i = 0; i < nonLoaded.Count; i++) { plugins.MakeWarning(this, nonLoaded[i]); } } window.LoadIcon(); string connectString = "Connecting to " + IPAddress + ":" + Port + ".."; if (Graphics.WarnIfNecessary(Chat)) { MapBordersRenderer.UseLegacyMode(true); EnvRenderer.UseLegacyMode(true); } Gui.SetNewScreen(new LoadingMapScreen(this, connectString, "")); Server.Connect(IPAddress, Port); }