8 Replies - 1335 Views - Last Post: 26 August 2010 - 07:10 AM Rate Topic: -----

#1 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,303
  • Joined: 22-October 08

A Little C# help

Posted 26 August 2010 - 02:08 AM

Hello
Here is my source code
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

// Add MTV3D65 to using clause:
using MTV3D65;

namespace Template
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class frmMain : System.Windows.Forms.Form
	{
		// Declare the TV Objects.
		public TVEngine TV;
		public TVScene Scene;
        public TVMesh Mesh;
        public TVLightEngine Light;
		public TVInputEngine Input;
		public TVGlobals Globals;
		public bool bDoLoop;

		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmMain()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#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()
		{
			// 
			// frmMain
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(632, 453);
			this.Name = "frmMain";
			this.Text = "Thompson Gaming Studios : Dev Pipline";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.frmMain_Closing);
			this.Load += new System.EventHandler(this.frmMain_Load);

		}
		#endregion

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

		private void frmMain_Load(object sender, System.EventArgs e)
		{
			// Create the TV Interface first:
			TV = new TVEngine();

			// Set the debug file/options.
			// Do this before the 3D init so it can log any errors found during init.
			TV.SetDebugMode(true, true);
			TV.SetDebugFile(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\debugfile.txt");
			
			// After setting the beta-key/license its time to init the engine:
			TV.Init3DWindowed(this.Handle, true);

			// Something good to do is to enable the auto-resize feature:
			// Get the default viewport and set autoresize to true for it:
			TV.GetViewport().SetAutoResize(true);

			// Lets display the FPS:
			TV.DisplayFPS(true);

			// Set the prefered angle system:
			TV.SetAngleSystem(MTV3D65.CONST_TV_ANGLE.TV_ANGLE_DEGREE);

			// Now after we are done initializing the TVEngine component lets continue:
			// Create any other components after TV init.

			Scene = new TVScene();

			Globals = new TVGlobals();

			// Input has an additional init method to call.
			Input = new TVInputEngine();
			// Lets init both keyboard and mouse:
			Input.Initialize(true, true);

			// Now we have setup the most basic of components.
			// Something to think about, if the component has a diffrent construct method
			// then the Object = new TV<NAME>, use that one instead.

			// For example:
			// TVMesh Mesh;
			// Mesh = Scene.CreateMeshBuilder("MyMesh"); <- Instead of Mesh = TVMesh();
			// Same goes for RenderSurface, Viewport etc.

            Mesh = Scene.CreateMeshBuilder("My Mesh");
            Light = Light.CreateLight(ref TV_LIGHT);
            
			bDoLoop = true;
			this.Show();
			this.Focus();

			// Lets setup the Loop:
			while(bDoLoop)
			{
				// Check if the application has focus, if yes thats when we process the loop.
				if(this.Focused)
				{				
					// The actual render loop:
					TV.Clear(false);
						// Render everything
						Scene.RenderAll(true);
					TV.RenderToScreen();

					// Lets check if the user presses ESC key, if yes we will quit the app.
					if(Input.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_ESCAPE)) { bDoLoop = false; };
				} else { 
					// So we arent calling DoEvents to many times if we arent using full CPU power.
					System.Threading.Thread.Sleep(100); 
				}
				
				Application.DoEvents();			
			}

			// Additional Info:
			/*
			Normally you dont have to keep track of the TV component and free it on closing.
			.NET will free the Managed Interface on close and thus automatically all the internal
			objects will be free'd. Such as Mesh's, Textures etc.

			Though it might be good to know you do have the ability to destroy and nil objects
			for re-creation or cleanup during runtime if you want that.

			TV = null;

			Will free all of the internal objects automatically.
			There are several other Destroy methods such as:

			TV<NAME>.Destroy , DestroyAll exists for some objects aswell if it is a Factory of some sort.

			Some other good destroy methods are:
			TVScene.DestroyAllMeshs.
			TVTextureFactory.DeleteAllTextures.

			And others...			
			*/

			TV = null;

			// End the application.
			this.Close();
		}

		private void frmMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			// If we close the application lets stop the loop.
			bDoLoop = false;
		}
	}
}




Now in this part

Mesh = Scene.CreateMeshBuilder("My Mesh");
Light = Light.CreateLight(ref TV_LIGHT);



it says when debugging
"Error 1 'MTV3D65.TV_LIGHT' is a 'type' but is used like a 'variable' C:\Program Files\TV3D SDK 6.5\templates\csharp\frmMain.cs 133 43 Template
"

What does that mean

Is This A Good Question/Topic? 0
  • +

Replies To: A Little C# help

#2 AmitTheInfinity  Icon User is offline

  • C Surfing ∞
  • member icon

Reputation: 119
  • View blog
  • Posts: 1,565
  • Joined: 25-January 07

Re: A Little C# help

Posted 26 August 2010 - 02:29 AM

--EDIT--
C# forum question... Not my piece of cake.

This post has been edited by AmitTheInfinity: 26 August 2010 - 02:36 AM

Was This Post Helpful? 0
  • +
  • -

#3 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: A Little C# help

Posted 26 August 2010 - 02:33 AM

And you posted this in C/C++ forum why? Moved to C#.
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5388
  • View blog
  • Posts: 27,385
  • Joined: 10-May 07

Re: A Little C# help

Posted 26 August 2010 - 02:50 AM

** Updated title to make the description more accurate **
Was This Post Helpful? 0
  • +
  • -

#5 Imdsm  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 103
  • View blog
  • Posts: 362
  • Joined: 21-March 09

Re: A Little C# help

Posted 26 August 2010 - 03:27 AM

"Error 1 'MTV3D65.TV_LIGHT' is a 'type' but is used like a 'variable' C:\Program Files\TV3D SDK 6.5\templates\csharp\frmMain.cs 133 43 Template"

This simply means that you're trying to pass a type (TV_LIGHT) as a variable.

For example, you can have this, which will work fine:

public string Name = "John";

public void main()
{
    SomeFunction(ref Name);
}


but what you're trying to do is pass the string, instead of the variable, such as:

public string Name = "John";

public void main()
{
    SomeFunction(ref string);
}


Now you haven't actually showed us where TV_LIGHT is defined, but you should really be doing something like TV_LIGHT tvLight and then passing tvLight etc.

Edit: thinking about it, I think you're trying to create the light with this line:
Light = Light.CreateLight(ref TV_LIGHT);

but you're passing a type to CreateLight, what we need to see is the method CreateLight.. :)

This post has been edited by Imdsm: 26 August 2010 - 03:28 AM

Was This Post Helpful? 2
  • +
  • -

#6 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,303
  • Joined: 22-October 08

Re: A Little C# help

Posted 26 August 2010 - 04:16 AM

Ok, well this is from Realvision 3dTV sdk, so ill have to find it and get back to you, im a total newbie and decided to dive in the deep end for a challenge

Thanks Aaron1178
Was This Post Helpful? 0
  • +
  • -

#7 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,303
  • Joined: 22-October 08

Re: A Little C# help

Posted 26 August 2010 - 04:21 AM

Also a quick question!
While i was reading some tutorials i found this code
using System;

class Hello
{
public void Main()
{
system.console.write("Hello world");
}
}


Thats off the top of my head.
But what is wrong with it if anything is wrong and im using Microsoft Visual C# 2010 Express and when i debug "F5" it opens with Hello World and then shuts before i can do any thing

Thanks Aaron1178
Was This Post Helpful? 0
  • +
  • -

#8 BigR1983  Icon User is offline

  • D.I.C Head

Reputation: 57
  • View blog
  • Posts: 221
  • Joined: 12-April 10

Re: A Little C# help

Posted 26 August 2010 - 04:29 AM

it shuts down because after it writes the line, the program is finished and is cleaned up.

if you want to see what is displays, put

Console.ReadLine(); 



that will force the window to stay open until you hit a key.

I think that you can also change the compile settings in VS to not close the console window until you close it, but I am not sure on that part.
Was This Post Helpful? 1
  • +
  • -

#9 Robin19  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 272
  • View blog
  • Posts: 552
  • Joined: 07-July 10

Re: A Little C# help

Posted 26 August 2010 - 07:10 AM

The tutorials are sometimes written assuming you run them through the command line interface. If it is run there, it will display "Hello World", end the program, and return to a prompt. The display will still have your output above the prompt. You can also put a breakpoint at the bracket ending Main, but BigR's suggestion is what I always use.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1