All pastes #28627 Raw Edit

Anonymous

public text v1 · immutable
#28627 ·published 2005-11-14 03:51 UTC
rendered paste body
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
//using System.Collections;


//lets pull in that 6.5 engine
using MTV3D65;

namespace MyFirstCFramework
{



	public class Form1 : System.Windows.Forms.Form
	{

		//Refrence The Engine Dll.
		MTV3D65.TVEngine tveng;
		MTV3D65.TVScene tvscene;
		MTV3D65.TVInputEngine tvinput;
		MTV3D65.TVLandscape tvlandscape;
		MTV3D65.TVGlobals tvglobals;
		MTV3D65.TVTextureFactory txfactory;
		MTV3D65.TVCamera tvcamera;
		MTV3D65.TVScreen2DText tvscreen2dtxt;
		MTV3D65.TVScreen2DImmediate tvsceenimd;
		MTV3D65.TVLightEngine tvlightengine;
		MTV3D65.TVMaterialFactory tvmatfactory;
		MTV3D65.TVAtmosphere tvatmos;
		MTV3D65.TVPhysics tvphys;
		MTV3D65.TVShader tvshader;
		MTV3D65.TVMathLibrary tvmath;

//MTV3D65.TVMesh tvmesh;

//END OF REFRENCE DLL ENGINE!

		//END OF 

		bool engineon = true;

		//CAMRA - 1 
		MTV3D65.TV_3DVECTOR campos;
		MTV3D65.TVCamera tvcamra;
		float camraangle;
		float lookat;
		float twist;
		//variables for settings
	    int vxzspeed=2;
		int vyspeed=10;
		int temp;
		string vheightmap;
		//array list to store meshes
		public ArrayList tvmeshtemp = new ArrayList(); 
		public ArrayList tvmeshlayout = new ArrayList(); 
		//this because .Count dont work ?
		int listcount = 0;

		//wirefraem
		bool wireframe = false;
		private System.Windows.Forms.PictureBox fpwindow;
		private System.Windows.Forms.GroupBox Settings;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.GroupBox groupBox3;
		private System.Windows.Forms.GroupBox groupBox4;
		private System.Windows.Forms.Button cmdsave;
		private System.Windows.Forms.TextBox txtxpos;
		private System.Windows.Forms.ComboBox oblib;
		private System.Windows.Forms.ComboBox textlib;
		private System.Windows.Forms.TextBox txtheightmap;
		private System.Windows.Forms.ComboBox cob;
		private System.Windows.Forms.Button cmddel;
		private System.Windows.Forms.CheckBox checkBox1;
		private System.Windows.Forms.ComboBox comboxzspeed;
		private System.Windows.Forms.ComboBox comboyspeed;
		private System.Windows.Forms.TextBox txtzpos;


		private System.ComponentModel.Container components = null;

		public Form1()
		{// Required for Windows Form Designer support
			InitializeComponent();
		}//<-----------------------------------------


		// Clean up any resources being used. .net Grabage
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				// when you click X then this exucutes.
				//CLEAR ALL !
				engineon = false; //turn engine off
				tveng = null;
				tvscene = null;
				tvinput = null;
				tvlandscape = null;
				tvglobals = null;
				txfactory = null;
				tvcamera = null;
				tvscreen2dtxt = null;
				tvsceenimd = null;
				tvlightengine = null;
				tvmatfactory = null;
				tvatmos = null;
				tvphys = null;
				tvshader = null;
				tvmath = null;

				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		//END OF .net Garbage Clean UP
		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.fpwindow = new System.Windows.Forms.PictureBox();
			this.Settings = new System.Windows.Forms.GroupBox();
			this.comboyspeed = new System.Windows.Forms.ComboBox();
			this.comboxzspeed = new System.Windows.Forms.ComboBox();
			this.txtzpos = new System.Windows.Forms.TextBox();
			this.txtxpos = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.cmdsave = new System.Windows.Forms.Button();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.oblib = new System.Windows.Forms.ComboBox();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.textlib = new System.Windows.Forms.ComboBox();
			this.groupBox3 = new System.Windows.Forms.GroupBox();
			this.txtheightmap = new System.Windows.Forms.TextBox();
			this.groupBox4 = new System.Windows.Forms.GroupBox();
			this.cmddel = new System.Windows.Forms.Button();
			this.cob = new System.Windows.Forms.ComboBox();
			this.checkBox1 = new System.Windows.Forms.CheckBox();
			this.Settings.SuspendLayout();
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			this.groupBox3.SuspendLayout();
			this.groupBox4.SuspendLayout();
			this.SuspendLayout();
			// 
			// fpwindow
			// 
			this.fpwindow.Location = new System.Drawing.Point(8, 168);
			this.fpwindow.Name = "fpwindow";
			this.fpwindow.Size = new System.Drawing.Size(688, 536);
			this.fpwindow.TabIndex = 0;
			this.fpwindow.TabStop = false;
			// 
			// Settings
			// 
			this.Settings.Controls.Add(this.comboyspeed);
			this.Settings.Controls.Add(this.comboxzspeed);
			this.Settings.Controls.Add(this.txtzpos);
			this.Settings.Controls.Add(this.txtxpos);
			this.Settings.Controls.Add(this.label4);
			this.Settings.Controls.Add(this.label3);
			this.Settings.Controls.Add(this.label2);
			this.Settings.Controls.Add(this.label1);
			this.Settings.Location = new System.Drawing.Point(8, 8);
			this.Settings.Name = "Settings";
			this.Settings.Size = new System.Drawing.Size(152, 128);
			this.Settings.TabIndex = 1;
			this.Settings.TabStop = false;
			this.Settings.Text = "Settings";
			// 
			// comboyspeed
			// 
			this.comboyspeed.Items.AddRange(new object[] {
															 "1",
															 "10",
															 "20",
															 "30",
															 "40",
															 "50",
															 "60",
															 "70",
															 "80",
															 "90",
															 "100"});
			this.comboyspeed.Location = new System.Drawing.Point(72, 40);
			this.comboyspeed.Name = "comboyspeed";
			this.comboyspeed.Size = new System.Drawing.Size(72, 21);
			this.comboyspeed.TabIndex = 9;
			// 
			// comboxzspeed
			// 
			this.comboxzspeed.Items.AddRange(new object[] {
															  "1",
															  "2",
															  "4",
															  "6",
															  "8",
															  "10",
															  "12",
															  "14",
															  "16",
															  "18",
															  "20",
															  "22",
															  "24",
															  "26",
															  "28",
															  "30",
															  "32",
															  "34",
															  "36",
															  "38",
															  "40"});
			this.comboxzspeed.Location = new System.Drawing.Point(72, 16);
			this.comboxzspeed.Name = "comboxzspeed";
			this.comboxzspeed.Size = new System.Drawing.Size(72, 21);
			this.comboxzspeed.TabIndex = 8;
			// 
			// txtzpos
			// 
			this.txtzpos.Location = new System.Drawing.Point(72, 88);
			this.txtzpos.Name = "txtzpos";
			this.txtzpos.Size = new System.Drawing.Size(72, 20);
			this.txtzpos.TabIndex = 7;
			this.txtzpos.Text = "";
			// 
			// txtxpos
			// 
			this.txtxpos.Location = new System.Drawing.Point(72, 64);
			this.txtxpos.Name = "txtxpos";
			this.txtxpos.Size = new System.Drawing.Size(72, 20);
			this.txtxpos.TabIndex = 6;
			this.txtxpos.Text = "";
			// 
			// label4
			// 
			this.label4.AutoSize = true;
			this.label4.Location = new System.Drawing.Point(32, 88);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(32, 16);
			this.label4.TabIndex = 5;
			this.label4.Text = "z-pos";
			// 
			// label3
			// 
			this.label3.AutoSize = true;
			this.label3.Location = new System.Drawing.Point(32, 64);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(32, 16);
			this.label3.TabIndex = 4;
			this.label3.Text = "x-pos";
			// 
			// label2
			// 
			this.label2.AutoSize = true;
			this.label2.Location = new System.Drawing.Point(16, 40);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(46, 16);
			this.label2.TabIndex = 1;
			this.label2.Text = "y Speed";
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(8, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(54, 16);
			this.label1.TabIndex = 1;
			this.label1.Text = "x/z Speed";
			// 
			// cmdsave
			// 
			this.cmdsave.Location = new System.Drawing.Point(8, 136);
			this.cmdsave.Name = "cmdsave";
			this.cmdsave.Size = new System.Drawing.Size(328, 24);
			this.cmdsave.TabIndex = 2;
			this.cmdsave.Text = "Save All Changes";
			this.cmdsave.Click += new System.EventHandler(this.cmdsave_Click);
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.oblib);
			this.groupBox1.Location = new System.Drawing.Point(168, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(168, 40);
			this.groupBox1.TabIndex = 3;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Object Library";
			// 
			// oblib
			// 
			this.oblib.Location = new System.Drawing.Point(8, 16);
			this.oblib.Name = "oblib";
			this.oblib.Size = new System.Drawing.Size(152, 21);
			this.oblib.TabIndex = 0;
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.textlib);
			this.groupBox2.Location = new System.Drawing.Point(168, 48);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(168, 40);
			this.groupBox2.TabIndex = 4;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "Texture Library";
			// 
			// textlib
			// 
			this.textlib.Location = new System.Drawing.Point(8, 16);
			this.textlib.Name = "textlib";
			this.textlib.Size = new System.Drawing.Size(152, 21);
			this.textlib.TabIndex = 0;
			// 
			// groupBox3
			// 
			this.groupBox3.Controls.Add(this.txtheightmap);
			this.groupBox3.Location = new System.Drawing.Point(168, 88);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new System.Drawing.Size(168, 48);
			this.groupBox3.TabIndex = 5;
			this.groupBox3.TabStop = false;
			this.groupBox3.Text = "Height Map";
			// 
			// txtheightmap
			// 
			this.txtheightmap.Location = new System.Drawing.Point(8, 16);
			this.txtheightmap.Name = "txtheightmap";
			this.txtheightmap.Size = new System.Drawing.Size(152, 20);
			this.txtheightmap.TabIndex = 0;
			this.txtheightmap.Text = "";
			// 
			// groupBox4
			// 
			this.groupBox4.Controls.Add(this.cmddel);
			this.groupBox4.Controls.Add(this.cob);
			this.groupBox4.Location = new System.Drawing.Point(344, 8);
			this.groupBox4.Name = "groupBox4";
			this.groupBox4.Size = new System.Drawing.Size(152, 72);
			this.groupBox4.TabIndex = 6;
			this.groupBox4.TabStop = false;
			this.groupBox4.Text = "Objects in map";
			// 
			// cmddel
			// 
			this.cmddel.Location = new System.Drawing.Point(8, 40);
			this.cmddel.Name = "cmddel";
			this.cmddel.Size = new System.Drawing.Size(136, 24);
			this.cmddel.TabIndex = 1;
			this.cmddel.Text = "Delete Selected Object";
			// 
			// cob
			// 
			this.cob.Location = new System.Drawing.Point(8, 16);
			this.cob.Name = "cob";
			this.cob.Size = new System.Drawing.Size(136, 21);
			this.cob.TabIndex = 0;
			// 
			// checkBox1
			// 
			this.checkBox1.Location = new System.Drawing.Point(0, 0);
			this.checkBox1.Name = "checkBox1";
			this.checkBox1.TabIndex = 0;
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(704, 710);
			this.Controls.Add(this.checkBox1);
			this.Controls.Add(this.groupBox4);
			this.Controls.Add(this.groupBox3);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.cmdsave);
			this.Controls.Add(this.Settings);
			this.Controls.Add(this.fpwindow);
			this.Name = "Form1";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Form1";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.Settings.ResumeLayout(false);
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.groupBox3.ResumeLayout(false);
			this.groupBox4.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
			this.txtheightmap.Text=Convert.ToString(System.Environment.CurrentDirectory);
			this.txtheightmap.Text+="\\heightmap\\";
			//WE NEED TO CREATE OBJECTS?
			tveng = new TVEngine();
			tvscene = new MTV3D65.TVScene();
			tvinput = new MTV3D65.TVInputEngine();
			tvlandscape = new MTV3D65.TVLandscape();
			tvglobals = new MTV3D65.TVGlobals();
			txfactory = new MTV3D65.TVTextureFactory();
			tvcamera = new MTV3D65.TVCamera();
			tvscreen2dtxt = new MTV3D65.TVScreen2DText();
			tvsceenimd = new MTV3D65.TVScreen2DImmediate();
			tvlightengine = new MTV3D65.TVLightEngine();
			tvmatfactory = new MTV3D65.TVMaterialFactory();
			tvatmos = new MTV3D65.TVAtmosphere();
			tvphys = new MTV3D65.TVPhysics();
			tvshader = new MTV3D65.TVShader();
			tvmath = new MTV3D65.TVMathLibrary();
			
			//turn the engine on
			engineon = true;

			//camra
			campos = new MTV3D65.TV_3DVECTOR();
			tvcamra = new MTV3D65.TVCamera();



			//CREATE CUSTOM CLASSES
			

			//???????????????????


			//set licence for beta
			tveng.SetBetaKey("shawng", "A3E70B7F-8540A9A8-896DE01A-E15EB44B");

			//Screen INITALIZE
			tveng.Init3DWindowed(this.fpwindow.Handle, true);
			tveng.DisplayFPS(true);

			//Debug	
			tveng.SetDebugMode(true,false);
			tveng.SetDebugFile(System.Windows.Forms.Application.StartupPath.ToString() + "\\DEBUGFILE.txt");
		
			tvscene.SetViewFrustum(90, 100000);
			

			//DRAW MAP ?
			DRAW();



			///show the form
			this.Show();
			this.Focus();

			GAMELOOP();
		}


//STAT GAME LOOP CODE
		private void GAMELOOP()
				{
				// this is main game code shell
				
				//Enable Keybord and mouse input
			tvinput.Initialize(true,true);
				

				//main code loop	
				while(engineon == true) 
				{
					tveng.Clear(false);

				 //Check inputs!
					CheckInput();

					PosCamra();
				    //Render

					//ATMOS RANDEr / DISABLES CLOUDS FOR RENDERING FOG.. A MUST!
					tvatmos.Fog_Enable(false);
					tvatmos.Atmosphere_Render();
					tvatmos.Fog_Enable(true);


					tvlandscape.Render();

					//generic render
					tvscene.RenderAllMeshes(false);
					tveng.RenderToScreen();

					//need this or you wont ever see shit
					System.Windows.Forms.Application.DoEvents(); 

					}

			//EXITED LOOP
			GAMEEXIT();

	}


		//END OF GAME LOOP CODE



		//Start of Check Input CODE
		private void CheckInput()
		{

			//check for user input
			if(tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_ESCAPE))
			{
				engineon = false; //exit
			}

			//CAMRA CODE

	
			if(tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_UP))
			{

		
				campos.x += (float)(System.Math.Cos(camraangle) * (float)tveng.AccurateTimeElapsed() * vxzspeed);
				campos.z += (float)(System.Math.Sin(camraangle) * (float)tveng.AccurateTimeElapsed() * vxzspeed);
				this.txtxpos.Text=Convert.ToString(campos.x);
				this.txtzpos.Text=Convert.ToString(campos.z);
				if(campos.y<tvlandscape.GetHeight(campos.x, campos.z)+500)
				{
					campos.y =tvlandscape.GetHeight(campos.x, campos.z) + 500;
				}
			}
			
			if (tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_DOWN))
			{
		
				campos.x -= (float)(System.Math.Cos(camraangle) * (float)tveng.AccurateTimeElapsed() * 2);
				campos.z -= (float)(System.Math.Sin(camraangle) * (float)tveng.AccurateTimeElapsed() * 2);
				txtxpos.Text=Convert.ToString(campos.x);
				txtzpos.Text=Convert.ToString(campos.z);
			}

			if (tvinput.IsKeyPressed(CONST_TV_KEY.TV_KEY_LEFT))
			{
				camraangle += (float)tveng.AccurateTimeElapsed() * 0.006f;
			}

			if (tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_RIGHT))
			{
				camraangle -= (float)tveng.AccurateTimeElapsed() * 0.006f;
			}

			//WORKING HERE AT MOMENT
			if (tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_NUMPAD8))
			{
				lookat -= (float)tveng.AccurateTimeElapsed() * 0.001f;
			}

			if (tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_NUMPAD2))
			{
				lookat += (float)tveng.AccurateTimeElapsed() * 0.001f;
			}


			if (tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_NUMPAD6))
			{
				twist -= (float)tveng.AccurateTimeElapsed() * 0.001f;
			}

			if (tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_NUMPAD4))
			{
				twist += (float)tveng.AccurateTimeElapsed() * 0.001f;
			}

			if (tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_NUMPAD0))
			{
				campos.y += vyspeed;
			}

			if (tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_NUMPADENTER))
			{
				campos.y -= vyspeed;
			}

			if (tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_NUMPADSTAR)) 

			{
				campos.y = 300;
				lookat = 0f;
				twist = 0f;
			}

			//END OF CAMRA CODE


			//start mesh placement test

			if (tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_H))
			{
				MTV3D65.TVMesh m = ((TVMesh)tvmeshtemp[0]).Duplicate();
				m.SetPosition(campos.x, tvlandscape.GetHeight(campos.x, campos.z) - 50, campos.z);
				m.SetTexture(tvglobals.GetTex("land"));
				//m.SetScale(5, 5, 5);
				m.Enable(true);		
				tvmeshlayout.Add(m);
				listcount++; //keep track of howmany
			}

			if (tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_C))
			{	
				for (int i=0; i < listcount; i++)
				{
					((TVMesh)tvmeshlayout[i]).Destroy();
				}
				tvmeshlayout.Clear();
				listcount = 1;
			}


		//eND OF MESH PLACEMENT

		//Toggle WireFrame
		if (tvinput.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_W))
		{

			switch (wireframe) 
			{
				case true:
					tvscene.SetRenderMode(CONST_TV_RENDERMODE.TV_LINE);
					wireframe = false;
					break;
				default:
					tvscene.SetRenderMode(CONST_TV_RENDERMODE.TV_SOLID);
					wireframe = true;
					break;
			}


		}



		}


		//END OF CHECK INPUT CODE


		//START GAME EXIT CODE
		private void GAMEEXIT()
		{
			engineon = false; //turn engine off
			tveng = null;
			tvscene = null;
			tvinput = null;
			tvlandscape = null;
			tvglobals = null;
			txfactory = null;
			tvcamera = null;
			tvscreen2dtxt = null;
			tvsceenimd = null;
			tvlightengine = null;
			tvmatfactory = null;
			tvatmos = null;
			tvphys = null;
			tvshader = null;
			tvmath = null;
			tvcamra = null;

		this.Close();
		}
		//END GAME EXIT CODE


		private void DRAW()
		{
			//this draws to the screen!

			//ok so when i first put this i got this weired 
			//"Unrecognized escape sequence" that is because in C#
			//you need to put @ in front of the data string to tell it to ignore it
			//else it will try to enter a newline or something line C++

			txfactory.LoadTexture(@"data\overlay.jpg", "land");
			txfactory.LoadTexture(@"data\brush.jpg", "brush1");
			txfactory.LoadAlphaTexture(@"data\whitemass.jpg","white");
			txfactory.LoadAlphaTexture(@"data\alphabrush.jpg","alphabrush1");


			//this is the land detial setting
			int levelofdetail;
			levelofdetail = 50;

			tvlandscape.GenerateTerrain(vheightmap, MTV3D65.CONST_TV_LANDSCAPE_PRECISION.TV_PRECISION_BEST, 2, 2, 0, 0, 0, true);

			tvlandscape.SetSplattingEnable(true);
			
			//tvlandscape.OptimizeSplatting(true,false);


			
			tvlandscape.SetAffineLevel(MTV3D65.CONST_TV_LANDSCAPE_AFFINE.TV_AFFINE_HIGH);


			tvlandscape.AddSplattingTexture((tvglobals.GetTex("land")), 0, levelofdetail, levelofdetail);
			tvlandscape.ExpandSplattingTexture((tvglobals.GetTex("white")), (tvglobals.GetTex("land")));

			tvlandscape.AddSplattingTexture((tvglobals.GetTex("brush1")), 0, levelofdetail, levelofdetail);
			tvlandscape.ExpandSplattingTexture((tvglobals.GetTex("alphabrush1")), (tvglobals.GetTex("brush1")));

			tvlandscape.SetTextureScale(500, 500);

			tvlandscape.SetScale(500, 150, 500);

			atmos(); //DRAW ATMOS

			InitMesh(); //SetUP MESH!


		}//END OFDRAW CODE
		


		//BEGAIN ATMOS
		private void atmos()
		{


			txfactory.LoadTexture(@"data\aclound.dds", "clouds", 0, 0, MTV3D65.CONST_TV_COLORKEY.TV_COLORKEY_BLACK, true);
    
            tvatmos.SkySphere_Enable(true);
            tvatmos.SkySphere_SetColor(80, 84, 6, 17);
            tvatmos.Clouds_Create(1, 100000, 100000);

            tvatmos.Clouds_SetLayerParameters(0, 33000, tvglobals.GetTex("clouds"));
            tvatmos.Clouds_SetLayerColor(0, 1, 1, 1, 1);
            tvatmos.Clouds_SetLayerAnimation(0, true, 0.004f, 0.004f);
            tvatmos.Clouds_SetLayerBlendMode(0, MTV3D65.CONST_TV_BLENDINGMODE.TV_BLEND_ALPHA);

  
            tvatmos.Clouds_Enable(true);

            tvatmos.Fog_Enable(true);
            tvatmos.Fog_SetColor(0.5f, 0.5f, 0.6f);
            tvatmos.Fog_SetParameters(50000, 55000, 0.005f);
            tvatmos.Fog_SetType(MTV3D65.CONST_TV_FOG.TV_FOG_LINEAR, MTV3D65.CONST_TV_FOGTYPE.TV_FOGTYPE_VERTEX);

		}
		//END ATMOS


		//CAMRA CODE
		private void PosCamra()
		{	
		
		//if camra is set to chase terrain
		//campos.y = tvlandscape.GetHeight(campos.x,campos.z) + 1000;
		
		tvcamra.SetCamera(campos.x, campos.y, campos.z, campos.x + (float)System.Math.Cos((double)camraangle), campos.y, campos.z + (float)System.Math.Sin((double)camraangle));

			//check what is ahead of us.. should we ajust camra ?


			//if(tvlandscape.GetHeight(campos.x ,campos.z) >=  tvlandscape.GetHeight(campos.x+500,campos.z+500))
		//	{//here comes a drop 
			
			//CAMRA LIMIT NEEDED! OR YOU END UP LOOK AT GROUND OR WORSE UPSIDEDOWN
			//if (lookat + (float)tveng.AccurateTimeElapsed() * 0.001f > 30f)
		//	{
		//	lookat += (float)tveng.AccurateTimeElapsed() * 0.001f;
		//	}//LOTS OF BUGS HERE!

		//	}

		//	else if (tvlandscape.GetHeight(campos.x ,campos.z) <=  tvlandscape.GetHeight(campos.x-500,campos.z-500))
		//	{//here a hill
				
				//CAMRA LIMIT NEEDED! OR YOU END UP LOOK AT GROUND OR WORSE UPSIDEDOWN
		//		if (lookat - (float)tveng.AccurateTimeElapsed() * 0.001f < 30f)
			//	{
			//		lookat -= (float)tveng.AccurateTimeElapsed() * 0.001f;
			//	}//LOTS OF BUGS HERE!

		//	}
		//	else
		//	{
			tvcamra.RotateX(lookat, true);
		//	}

		//twist is not effected	
		tvcamra.RotateY(twist, true);


		}//END OF POS CAMRA CODE




		//THIS IS THE MESH MANAGER
		public void InitMesh()
		{

		//LOAD ALL MESH TEMPLATES
	
		MTV3D65.TVMesh m = tvscene.CreateMeshBuilder();
		m.LoadTVM(@"data/build/building.tvm");
		m.SetCullMode(CONST_TV_CULLING.TV_DOUBLESIDED);
        m.Enable(false);		
		tvmeshtemp.Add(m);
		}

		private void cmdsave_Click(object sender, System.EventArgs e)
		{
		vxzspeed=Convert.ToInt32(this.comboxzspeed.SelectedItem);
	    vyspeed=Convert.ToInt32(this.comboyspeed.SelectedItem);
		//campos.x = System.Convert.ToSingle(this.txtxpos.Text);
		//temp=System.Convert.ToInt32(this.txtxpos.Text);
		//campos.x=(float)temp;
	    //temp=0;
		temp=int.Parse(this.txtzpos.Text);
		campos.z=(float)temp;
		campos.y=tvlandscape.GetHeight(campos.x,campos.z)+500;
		vheightmap=Convert.ToString(txtheightmap);
		}

	
	}

}