[C# + DirectX] Problem z wyświetleniem sceny

0

Witam serdecznie,
mam nadzieję, że ktoś tu będzie mi w stanie pomóc ponieważ już tracę nadzieję, a jest to dla mnie bardzo ważne :-O
Muszę wyświetlić scenę na ekranie za pomocą DirectX. Dostałem tutorial z gotowym kodem. Kod ten był pisany na wcześniejszej wersjii VS (ja mam wersję 2008, która przekonwertowała go sobie na własną). Nie wiem czy ten kod jest zły, czy konwersja coś psuje, czy problem jest w bibliotekach dll.
W każdym razie wygląda to tak

http://img368.imageshack.us/img368/1075/55343903wv1.jpg

A to log z programu assembly Binding Log Viewer

  • Assembly Binder Log Entry (2008-04-20 @ 2120) ***

The operation failed.
Bind result: hr = 0x80070002. Nie można odnaleźć określonego pliku.

Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable C:\Documents and Settings\Endrju\Pulpit\Kopia DirectX_pdf\Zajecia_nr_4_TeksturowanieOswietlanie\CD_Wykladowca\App4\bin\Debug\ATutorial3.vshost.exe
--- A detailed error log follows.

Pre-bind state information

LOG: User = GRZYWKA\Endrju
LOG: DisplayName = mscorlib.resources, Version=2.0.0.0, Culture=pl, PublicKeyToken=b77a5c561934e089
(Fully-specified)
LOG: Appbase = file:///C:/Documents and Settings/Endrju/Pulpit/Kopia DirectX_pdf/Zajecia_nr_4_TeksturowanieOswietlanie/CD_Wykladowca/App4/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).

LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Documents and Settings\Endrju\Pulpit\Kopia DirectX_pdf\Zajecia_nr_4_TeksturowanieOswietlanie\CD_Wykladowca\App4\bin\Debug\ATutorial3.vshost.exe.Config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: mscorlib.resources, Version=2.0.0.0, Culture=pl, PublicKeyToken=b77a5c561934e089
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Documents and Settings/Endrju/Pulpit/CD_Wykladowca/App4/bin/Debug/pl/mscorlib.resources.DLL.
LOG: Attempting download of new URL file:///C:/Documents and Settings/Endrju/Pulpit/CD_Wykladowca/App4/bin/Debug/pl/mscorlib.resources/mscorlib.resources.DLL.
LOG: Attempting download of new URL file:///C:/Documents and Settings/Endrju/Pulpit/CD_Wykladowca/App4/bin/Debug/pl/pl/mscorlib.resources.DLL.
LOG: Attempting download of new URL file:///C:/Documents and Settings/Endrju/Pulpit/CD_Wykladowca/App4/bin/Debug/pl/pl/mscorlib.resources/mscorlib.resources.DLL.
LOG: Attempting download of new URL file:///C:/Documents and Settings/Endrju/Pulpit/CD_Wykladowca/App4/bin/Debug/pl/mscorlib.resources.EXE.
LOG: Attempting download of new URL file:///C:/Documents and Settings/Endrju/Pulpit/CD_Wykladowca/App4/bin/Debug/pl/mscorlib.resources/mscorlib.resources.EXE.
LOG: Attempting download of new URL file:///C:/Documents and Settings/Endrju/Pulpit/CD_Wykladowca/App4/bin/Debug/pl/pl/mscorlib.resources.EXE.
LOG: Attempting download of new URL file:///C:/Documents and Settings/Endrju/Pulpit/CD_Wykladowca/App4/bin/Debug/pl/pl/mscorlib.resources/mscorlib.resources.EXE.
LOG: All probing URLs attempted and failed.

Mogę wysłać komuś gotową aplikację do sprawdzenia czy się uruchamia. RATUNKU!

0

A czy plik scene_tr_.3ds jest w katalogu Debug?

0

No tak tak ;-)

0

Podaj cialo konstruktora AScene.

PS. Ciekawy try tam ponizej :P

0

Wklejam "główny" kod, mogę jeszcze podać kod samej klasy AScene.

using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using Direct3D=Microsoft.DirectX.Direct3D;

namespace ATutorial
{
    public class MainClass : Form
    {
		public ARenderer Renderer;
        PresentParameters presentParams = new PresentParameters();
		AScene	Scene = null;
		public ATimer	Timer = new ATimer();

        public MainClass()
        {
			this.ClientSize = new System.Drawing.Size(800,600);
			this.Text = "a tutorial"; 
        }

		bool InitializeGraphics()
		{
			try 
			{
				Renderer = new ARenderer( true, 800, 600, 32, Filtering.TriLinear );
				Renderer.Enumerate();
				Renderer.Initialize( this );
			}

			catch (DirectXException e )
			{
				MessageBox.Show( e.Message );
				return false;
			}
 
            return true;
        }

		bool LoadEverything()
		{
			Scene = new AScene( Renderer, "scene_tr_.3ds" );
			Scene.Set();
			Scene.SetActiveCamera( Scene.CamerasList[ 0 ] as ACamera );

			
			try
			{
			}

			catch ( Exception e )
			{
				MessageBox.Show( e.Message );
				return false;
			}

			return true;
		}

        private void Render()
        {
			Device device = Renderer.Device;

            if (device == null) 
                return;

			device.TestCooperativeLevel();

			device.Clear(ClearFlags.Target | ClearFlags.ZBuffer,
				System.Drawing.Color.Black, 1.0f, 0);
			device.BeginScene();

			Renderer.SetDefaultRenderStates();
			
			float f = Timer.GetTime() * 30.0f;
			Scene.SetFrame( f );
			Scene.Update();
			Scene.Render();

			device.EndScene();
			device.Present(); 
		}

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            // this.Render();
        }
        protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
        {
			if ( (int)(byte)e.KeyChar == (int)System.Windows.Forms.Keys.Escape )
				this.Dispose();

			else if ( (int)(byte)e.KeyChar == (int)System.Windows.Forms.Keys.W )
			{
				Renderer.ChangeWindowedMode();
				Renderer.Reset();
			}
		}

        static void Main() 
        {
            using (MainClass frm = new MainClass())
            {
                if (!frm.InitializeGraphics())
                {
                    MessageBox.Show("Could not initialize Direct3D.");
                    return;
                }
                frm.Show();
				
				if ( false == frm.LoadEverything() )
					return;

				frm.Timer.Reset();

				while(frm.Created)
				{
					try
					{
						frm.Render();
						Application.DoEvents();
					}
					catch( DirectXException e )
					{
						DeviceLostException lostException = e as DeviceLostException;
						DeviceNotResetException resetException = e as DeviceNotResetException;

						if ( ( ( null != lostException ) || ( null != resetException ) ) && ( null != frm.Renderer ) )
						{
							try
							{
								frm.Renderer.Reset();
							}
							catch ( DirectXException )
							{ 

							}
						}
					}
				}
			}
        }
    }
}




/*
 * 
 * 
 * 			dev.Lights[ 0 ].Enabled = true;
			dev.Lights[ 0 ].Diffuse = System.Drawing.Color.Red;// FromArgb( 0, 255, 255 );
			dev.Lights[ 0 ].Type = LightType.Directional;
			dev.Lights[ 0 ].Direction = new Vector3( 0.0f, 0.0f, 1.0f );
 * 
 * 
 * 
 * 			Mesh NewMesh = mesh.Clone( mesh.Options.Value, mesh.VertexFormat | VertexFormats.Normal, dev );
			NewMesh.ComputeNormals();
			mesh.Dispose();
			mesh = NewMesh;
			*/

Rzeczywiście try ciekawy ;-) To nie ja pisalem, ja tylko próbuję to uruchomić.

0

Podaj cialo tego konstruktora, bo tam leci wyjatek. Bedzie latwiej zobaczyc gdzie szuka tego pliku.

0

O to chodziło? :|

		public AScene( ARenderer renderer, string name )
		{
			Renderer = renderer;

			if ( null == ( Scene = Clax.SceneLoader.CreateScene( name ) ) )
				throw new Exception( "Can't Load Scene: " + name );

			for ( uint i = 0; i < Scene.GetNumberOfMeshes(); i++ )
			{
				Clax.Mesh claxMesh = Scene.GetMeshByID( i );
				
				if ( null == claxMesh )
					throw new Exception( "clax mesh is null" );

				if ( Clax.MeshFlag.Dummy != claxMesh.GetFlags() )		//we dont need dummies for anything atm
					Meshes.Add( new AMesh( Renderer, this, claxMesh ) );
			}

			for ( uint i = 0; i < Scene.GetNumberOfCameras(); i++ )
				Cameras.Add( new ACamera( Renderer, this, Scene.GetCameraByID( i ) ) );

			for ( uint i = 0; i < Scene.GetNumberOfLights(); i++ )
				Lights.Add( new ALight( Renderer, this, Scene.GetLightByID( i ), (int)i ) );

			AllFrames = Scene.GetFrames();
			Clax.Vector ambient = Scene.GetAmbientColor();

			if ( ( 0.0f != ambient.x ) || ( 0.0f != ambient.y ) || ( 0.0f != ambient.z ) )
			{
				AmbientColor.X = ambient.x;
				AmbientColor.Y = ambient.y;
				AmbientColor.Z = ambient.z;
			}
		}
0

Tak, o to. To chyba jest w osobnej bibliotece skoro debugger wylapuje wyjatek dopiero w miejscu wskazanym w pierwszym poscie?

Jedynym sensownym miejscem do rzucenia tego wyjatku wydaje mi sie:

if ( null == ( Scene = Clax.SceneLoader.CreateScene( name ) ) )

Co to ten Clax? Na google nie wyglada, zeby cos bylo na temat biblioteki o tej nazwie (jest dla c++ cos, ale nie .net)

0
johny_bravo napisał(a)

Tak, o to. To chyba jest w osobnej bibliotece skoro debugger wylapuje wyjatek dopiero w miejscu wskazanym w pierwszym poscie?

Jedynym sensownym miejscem do rzucenia tego wyjatku wydaje mi sie:

if ( null == ( Scene = Clax.SceneLoader.CreateScene( name ) ) )

Co to ten Clax? Na google nie wyglada, zeby cos bylo na temat biblioteki o tej nazwie (jest dla c++ cos, ale nie .net)

Biblioteka nazywa się ManagedClax.dll. http://www.geocities.com/SiliconValley/Bay/6525/info.html - ju chyba jest coś o tym.
Najgorsze jest to, że dostałem to wszystko od promotora i lepiej, żeby działało tak jak tu. Ale jeżeli to niemożliwe to może jest jakiś lepszy sposób, żeby wyświetlić kawałek grafiki 3D?

0

Tyle, ze tam jest biblioteka dla c, wiec to nie bardzo jest to wprost. Sciagnij Reflectora i podejrzyj kod ManagedClax.dll, albo wrzuc ta dllke gdzies, albo przeslij na maila to zobaczymy gdzie powinien sie znajdowac plik.

Co do drugiego pytania - nie ma sensu szukac innego kodu, bo ten 'nie dziala' na razie tylko dlatego, ze nie moze znalezc pliku scene_tr_.3ds - stad pytanie gdzie go szuka, by wiedziec gdzie go umiescic.

0

<url>www.astercity.net/~kolunake/ManagedClax.dll</url>
Wrzucilem biblioteke na serwer. Dzięki za czynne zainteresowanie. Myślałem, że problem tkwi gdzie indziej ale może rzeczywiście to chodzi o znalezienie pliku ze sceną.

0

Ok, chwilowo nie mam czasu tego rozgryzac, bo jestem w pracy.

Sprobuj w tzw. miedzyczasie podac pelna sciezke do pliku, np. c:\scene_tr_.3ds i umiescic tam plik oczywiscie.

0
johny_bravo napisał(a)

Ok, chwilowo nie mam czasu tego rozgryzac, bo jestem w pracy.

Sprobuj w tzw. miedzyczasie podac pelna sciezke do pliku, np. c:\scene_tr_.3ds i umiescic tam plik oczywiscie.

No niestety ale już próbowałem, bez zmian :-/

// PS, Fringe - od kolorowania składni C# w serwisie jest <code class="csharp"></code> - Cold</i>

0

I jak, udało się coś stwierdzić na podstawie tej biblioteki?

0

Problem jest taki, że musisz ustawić tryb visuala na x86 bo pewnie pracujesz w trybie 65 bitowym :)

1

Odnawiasz temat po 2 latach :]
I nie da się tego (trybu x86) ustawić w wersji express.

1 użytkowników online, w tym zalogowanych: 0, gości: 1