public Viewport(System.Windows.Forms.IWin32Window window, string name) { viewport = Engine.TV3DEngine.CreateViewport(window.Handle.ToInt32(), name); viewport.SetAutoResize(true); camera = viewport.GetCamera(); strivecamera = new Camera(camera); }
public IModel MousePick() { TVViewport vp = Engine.TV3DEngine.GetViewport(); int x = (int)vp.Width / 2; int y = (int)vp.Height / 2; return(MousePick(x, y)); }
public Viewport( System.Windows.Forms.IWin32Window window, string name ) { viewport = Engine.TV3DEngine.CreateViewport( window.Handle.ToInt32(), name ); viewport.SetAutoResize( true ); camera = viewport.GetCamera(); strivecamera = new Camera( camera ); }
private void Robot_Load(object sender, EventArgs e) { //Tracking //pictureBox27.Load(Application.StartupPath + "\\Resources\\image1.jpg"); /////3D lights = new TVLightEngine(); globals = new TVGlobals(); atmosphere = new TVAtmosphere(); maths = new TVMathLibrary(); materialfactory = new TVMaterialFactory(); texturefactory = new TVTextureFactory(); tv = new TVEngine(); physics = new TVPhysics(); //Setup TV tv.SetDebugMode(true, true); tv.SetDebugFile(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\debugfile.txt"); tv.SetAntialiasing(true, CONST_TV_MULTISAMPLE_TYPE.TV_MULTISAMPLE_2_SAMPLES); //Enter Your Beta Username And Password Here //tv.SetBetaKey("", ""); tv.SetAngleSystem(CONST_TV_ANGLE.TV_ANGLE_DEGREE); //tv.Init3DWindowed(this.Handle, true); tv.Init3DWindowed(this.pictureBox3D.Handle, true); tv.GetViewport().SetAutoResize(true); tv.DisplayFPS(true); tv.SetVSync(true); scene = new TVScene(); input = new TVInputEngine(); input.Initialize(true, true); camera = new TVCamera(); camera = scene.GetCamera(); camera.SetViewFrustum(45, 1000, 0.1f); camera.SetPosition(0, 5, -20); camera.SetLookAt(0, 3, 0); viewport = new TVViewport(); viewport = tv.CreateViewport(this.Handle, "viewport"); viewport.SetCamera(camera); viewport.SetBackgroundColor(Color.Blue.ToArgb()); bDoLoop = true; InitSound(); InitMaterials(); InitTextures(); InitFonts(); InitShaders(); InitEnvironment(); InitPhysics(); InitLandscape(); InitObjects(); InitLights(); InitPhysicsMaterials(); Init2DText(); this.Show(); this.Focus(); GameLoop(); tv = null; this.Close(); //// /3D groupComPortDefault.Enabled = false; groupComPortSettings.Enabled = false; groupTcpClientServerSettings.Enabled = false; groupTcpClientServerDefault.Enabled = false; groupDirectionAndMotion.Enabled = false; groupCameraRotation.Enabled = false; groupCameraRot2.Enabled = false; groupAdvencedSuppDevices.Enabled = false; groupJoystickInit.Enabled = false; labelCommunicationType.Text = null; labelConnectingStatus.Text = null; labelJoystickName.Text = null; SetMap(); Maps.SelectedItem = "TUKE"; //Full Screen Options op = new Options(); op = op.ReadOptionsFromFile(); this.combo_method.SelectedIndex = op.Scale; this.combo_streams.SelectedIndex = op.Streams; this.textBox1.Text = op.Text; //this.lbl_foreColor.BackColor = ColorTranslator.FromHtml(op.ForeColor); }
/// <summary> /// Public rendering routine /// </summary> /// <remarks>This method renders the scene into video memory</remarks> public void Render() { try { // for us, land only contains the clouds atm // Engine.terrain.Render(); // render static models Engine.TV3DScene.RenderAllMeshes(false); // render character models and object labels Engine.Screen2DText.ACTION_BeginText(); //string header = "X:"+View.Position.X+",Y:"+View.Position.Y+",Z:"+View.Position.Z+" - heading:"+View.Rotation.Y; //Engine.Screen2DText.NormalFont_DrawTextFontID( header, 0, 0, Engine.Gl.RGBA(1f, 0f, 1f, 1f), Engine.FontIndex ); Vector3D cameraPosition = Camera.Position; Vector3D cameraRotation = Camera.Rotation; //lock(_models.Values.SyncRoot) { foreach (IModel m in _models.Values) { if (m is Actor) { ((Actor)m).Render(); } if (m.Visible && m.Label != null) { //Get the vector between camera and object, put in v1 //Get the direction vector of the camera (lookat - position normalized) put in v2 //Compute the Dot product. //If Dot(V1, V2) > Cos(FOVInRadian) Then //You can see the object ! //Using FieldOfView of 90degrees, //so things offscreen infront will still be labeled. Vector3D v1 = m.Position - cameraPosition; if (Vector3D.Dot(v1, Helper.GetHeadingFromRotation(cameraRotation)) <= Math.Cos(Camera.FieldOfView * Math.PI / 180)) { // TODO: doesn't work for -ve numbers! // continue; } Vector3D labelPos = new Vector3D( m.Position.X, m.Position.Y + m.Height / 2 + 2, m.Position.Z ); DrawText(labelPos, m.Label + " (w:" + m.Width + ", h:" + m.Height + ", d:" + m.Depth + ")"); } } Engine.Screen2DText.ACTION_EndText(); if (cursorTextureID != 0) { // TODO: use locally saved values TVViewport vp = Engine.TV3DEngine.GetViewport(); float x = vp.Width / 2; float y = vp.Height / 2; Engine.Screen2DImmediate.ACTION_Begin2D(); Engine.Screen2DImmediate.DRAW_Texture(cursorTextureID, x - 8, y - 8, x + 8, y + 8, -2, -2, -2, -2, 0, 0, 1, 1); Engine.Screen2DImmediate.ACTION_End2D(); } } } catch (Exception e) { throw new RenderingException("Call to 'Render()' failed with '" + e.ToString() + "'", e); } //#if DEBUG //R3DColor black = new R3DColor(); //black.b = 255; //black.r = 255; //black.g = 255; //EEERRR setting the draw color fails to write text in 89 //Engine.Interface5D.Primitive_SetDrawColor(ref black); //ngine.Screen2D.DrawText(ref zero, "Fp/S: " + Engine.PowerMonitor.lGetFramesPerSecond().ToString() + // ", Vertices: " + Engine.PowerMonitor.lGetNumVerticesPerSinceLastFrame().ToString() + //", Verts/Sec: " + (Engine.PowerMonitor.lGetFramesPerSecond() * Engine.PowerMonitor.lGetNumVerticesPerSinceLastFrame()).ToString() ); // Engine.Interface2D.Primitive_DrawText(0,0, (Engine.PowerMonitor.lGetFramesPerSecond()).ToString()); //#endif /* * try * { * Engine.Pipeline.Renderer_Display(); * } * catch(Exception e) * { * throw new RenderingException("Call to 'Display()' failed with '" + e.ToString() + "'", e); * } */ }
public void AddViewport(System.Windows.Forms.IWin32Window hwnd) { TVViewport vp = Engine.TV3DEngine.CreateViewport(hwnd.Handle.ToInt32(), "viewport"); vp.SetAutoResize(true); }
public void Init3D2() { tv.GetViewport().SetAutoResize(true); tv.DisplayFPS(true); tv.SetVSync(true); scene = new TVScene(); input = new TVInputEngine(); input.Initialize(true, true); camera = new TVCamera(); camera = scene.GetCamera(); camera.SetViewFrustum(45, 1000, 0.1f); camera.SetPosition(0, 5, -20); camera.SetLookAt(0, 3, 0); viewport = new TVViewport(); }