ERLEDIGT
NEIN
NEIN
ANTWORTEN
1
1
ZUGRIFFE
725
725
EMPFEHLEN
-
Hi Leute.
Ich hab mal wieder ein kleines Problem. Ich bin habe gerade eine nette schöne Aufgabe bekommen. Ich muss nun Beziehungen zwischen Objekten grafisch als Matrix darstellen.
Das soll ungefähr so aussehene wie die Matrix auf wissen.de oder www.sj.com nur aber halt unter C#.Net. Ich hab mich nun n bischen mit DirectX auseinander gesetzt und mir ein paar Tutorials durchgelesen.
Ich bin mir grad nicht sicher ob ich das unbedingt in DirectX machen muss. Könnt Ihr mir da etwas einfacheres empfehlen? Wenn nicht wäre auch nicht so schlimm, aber dann stehe ich vor dem Problem, dass ich zwar ein schönes Dreieck (wie im Tutorial) zeichnen kann, die Fläche sich allerdings über das gesamte Formular erstreckt.
Mein Problem ist es nun diese Fläche zu begrentzen, damit ich dann noch normale Objekte einbauen kann. Weiß da einer weiter (Hier hab ich die Tutorials her: http://www.miszalok.de/C_00/Index_all_Courses.htm)
Kann man das dann irgendwie auf eine PicturBox oder etwas anderes anwenden und nicht auf das ganze Formular
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
using System; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; public class Form1 : Form { static void Main() { Application.Run( new Form1() ); } static Device device = null; static float fAngle; PresentParameters presentParams; static CustomVertex.PositionColored[] v = new CustomVertex.PositionColored[3]; Timer myTimer = new Timer(); public Form1() { Text = "D3DTriangleAnimation"; //fill coordinates and colors into an array "v" v[0].X=-1f; v[0].Y=-1f; v[0].Z=0f; v[1].X= 1f; v[1].Y=-1f; v[1].Z=0f; v[2].X= 0f; v[2].Y= 1f; v[2].Z=0f; v[0].Color = System.Drawing.Color.DarkGoldenrod.ToArgb(); v[1].Color = System.Drawing.Color.MediumOrchid.ToArgb(); v[2].Color = System.Drawing.Color.Cornsilk.ToArgb(); myTimer.Tick += new EventHandler( OnTimer ); myTimer.Interval = 1; ClientSize = new Size( 400, 300 ); //Calls OnResize( ... ) } protected override void OnResize( System.EventArgs e ) //Whenever the window changes we have to initialize Direct3D from scratch { myTimer.Stop();// stop the timer during initialization try { //get information from the operating system about its current graphics properties presentParams = new PresentParameters(); presentParams.Windowed = true; //no full screen display presentParams.SwapEffect = SwapEffect.Discard; //no swap buffer if ( device != null ) device.Dispose(); //free the old canvas if any device = new Device( 0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams ); device.Transform.View = Matrix.LookAtLH( new Vector3( 0f, 0f,-4f ), new Vector3( 0f, 0f, 0f ), new Vector3( 0f, 1f, 0f ) ); device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI/4, 1f, 0f, 10f ); device.RenderState.CullMode = Cull.None; device.RenderState.Lighting = false; device.VertexFormat = CustomVertex.PositionColored.Format; myTimer.Start();//start the timer again } catch (DirectXException) { MessageBox.Show( "Could not initialize Direct3D." ); return; } } protected static void OnTimer( Object myObject, EventArgs myEventArgs ) { if (device == null) return; device.Clear( ClearFlags.Target, Color.Blue, 1f, 0 ); fAngle += 0.1f; device.Transform.World = Matrix.RotationY( fAngle ); device.BeginScene(); device.DrawUserPrimitives( PrimitiveType.TriangleList, 1, v ); device.EndScene(); device.Present(); // show the canvas } }
Das Problem ist glaube dieser Befehl "device = new Device( 0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams );" wenn man sich ein neues Device erstellt. Weiß jemand, wie man das dann nicht auf das Formular sondern auf die PctureBox oder ein anderes Object anwedet, das dafür geeignet ist
Freue mich über jede Hilfe!!
MfG
XersesFuer die einen ist es Windows,
fuer die anderen die größte Bug-Sammlung der Welt.
-
Ich bin mal wieder erfreut was für eine Hilfe hier geboten wird. Ist echt geil im stich gelassen zu werden, obwohl einige Leute das doch bestimmt wissen könnten.
Ich hab nun auf jeden Fall weiter gemacht und habs endlich geschaft mir ein Formular mit einer PictureBox und einem Button zu erstellen. Klickt man auf den Button wird ein Dreieck rotiert. Klick man wiederum auf den Button soll die Rotation gestoppt werden. Das funtkioniert auf meinem Rechner wunderbar, aber wenn ich ein Setup Projekt erstelle und es auf einem anderen Rechner installiere auf dem nur Framework 1.1 und DirectX9.0c installiert sind, reagiert mein Programm nach dem Starten der Rotation nicht mehr. Kann mir jemand sagen woran das liegt
Der einzige unterschied zwischen den Rechner ist, das ich auf meinem DirectX SDK installiert habe und auf dem anderen nur das normale DirectX9.0c. Muss ich beim kompilieren noch extra was einstellen oder was beachten Ich kenne mich mit Visual Studio 03.NET noch nicht so gut aus. Wäre cool, wenn ihr mir da weiter helfen könntet.
Hoffe doch diesmal mehr antworten zu bekommen.
Mit freundlichen Grüßen
Xerses
Anhang Fehlermeldung:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.IO.FileLoadException: Unverifiable assembly 'Microsoft.DirectX' failed policy check. File name: "Microsoft.DirectX" at DirectX_Tutorial_2.Formular.picViewport_Paint(Object sender, PaintEventArgs e) at System.Windows.Forms.Control.OnPaint(PaintEventArgs e) at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) ************** Loaded Assemblies ************** mscorlib Assembly Version: 1.0.5000.0 Win32 Version: 1.1.4322.573 CodeBase: [url="file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll"]file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll[/url] ---------------------------------------- System Assembly Version: 1.0.5000.0 Win32 Version: 1.1.4322.573 CodeBase: [url="file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll"]file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll[/url] ---------------------------------------- System.Drawing Assembly Version: 1.0.5000.0 Win32 Version: 1.1.4322.573 CodeBase: [url="file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll"]file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll[/url] ---------------------------------------- DirectX_Tutorial_2 Assembly Version: 1.0.2078.17667 Win32 Version: 1.0.2078.17667 CodeBase: [url="file:///T:/Gruber/DirectX_Dreieck/DirectX_Tutorial_2.exe"]file:///T:/Gruber/DirectX_Dreieck/DirectX_Tutorial_2.exe[/url] ---------------------------------------- System.Windows.Forms Assembly Version: 1.0.5000.0 Win32 Version: 1.1.4322.573 CodeBase: [url="file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll"]file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll[/url] ----------------------------------------
Geändert von xerses (09.09.05 um 10:53 Uhr)
Fuer die einen ist es Windows,
fuer die anderen die größte Bug-Sammlung der Welt.
Ähnliche Themen
-
Directx 8 und 9
Von Anfänger92 im Forum C/C++Antworten: 0Letzter Beitrag: 13.05.07, 12:38 -
C# und DirectX
Von time-master im Forum LiteraturAntworten: 0Letzter Beitrag: 26.03.06, 00:16 -
[DirectX // Win 32] DirectX im Fenster?
Von Nizomi im Forum C/C++Antworten: 8Letzter Beitrag: 31.08.05, 23:26 -
DirectX
Von the edge im Forum C/C++Antworten: 1Letzter Beitrag: 10.04.05, 18:23 -
DirectX
Von DerAndere im Forum Microsoft WindowsAntworten: 10Letzter Beitrag: 08.11.04, 21:54





Zitieren
Login





