![]() |
OpenGL 3ds laden geht nicht ?!?
hey leute,
ich probiere schon stunden aber irgendwie sehe ich nur weiß :-( also ich habe eine 3ds mit blender erstellt (standart-würfel) und cube.3ds genannt. so und dann halt die normalen routinen geschrieben die halt dafür nötig sind:
Delphi-Quellcode:
hab ich irgendwas vergessen oder ..?.. wie?
unit skybox1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,dglOpenGL, AppEvnts, GLBmp, StdCtrls, ExtCtrls,gl3ds; type TForm1 = class(TForm) ApplicationEvents1: TApplicationEvents; Timer1: TTimer; procedure FormCreate(Sender: TObject); procedure ApplicationEvents1Idle(Sender: TObject; var Done: Boolean); procedure FormResize(Sender: TObject); procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure FormDestroy(Sender: TObject); procedure Timer1Timer(Sender: TObject); private { Private-Deklarationen } public FDC : HDC; FRC : HGLRC; List : Cardinal; yrot ,xrot : TGLFloat; x,y:real; OMpos : TPoint; mesh: TAll3dsMesh; procedure GLInit; procedure LoadSkyBox; procedure GenerateSkyBox(pWidth, pHeight, pLength : TGLFloat); procedure DrawScene; end; var Form1: TForm1; SkyBoxTexture : Array[0..5] of TGLBmp; timefactor : double = 1; fps : integer = 20; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var Dummy : HPalette; begin InitOpenGL; // Get a handle from our Window FDC := GetDC(Handle); // Generate our rendering context with a color depth of 32Bpp FRC := CreateRenderingContext(FDC, [opDoubleBuffered], 32, 24, 0, 0, 0, 0); // Save our old mouse position OMPos := Mouse.CursorPos; ActivateRenderingContext(FDC, FRC); GLInit; LoadSkyBox; mesh:= TAll3dsMesh.Create(nil); //erstellen mesh.LoadFromFile('cube.3ds'); // objekt laden Cursor := crCross; end; procedure TForm1.FormDestroy(Sender: TObject); begin DeActivateRenderingContext; wglDeleteContext(FRC); ReleaseDC(Handle, FDC); Mesh.free;//freigabe end; procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin //courser berchnen und und undd.... end; procedure TForm1.FormResize(Sender: TObject); begin if HandleAllocated then begin glViewport(0, 0, ClientWidth, ClientHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity; gluPerspective(45, ClientWidth/ClientHeight, 0.1, 1000); end; end; procedure TForm1.GLInit; begin // Enable texture mapping glEnable(GL_TEXTURE_2D); end; procedure TForm1.Timer1Timer(Sender: TObject); begin if fps=0 then begin fps := 1; end; timefactor := 20/fps; fps := 0; end; procedure TForm1.LoadSkyBox; //bilder für skybox laden end; procedure TForm1.GenerateSkyBox(pWidth, pHeight, pLength : TGLFloat); ///erstellt eine Skybox end; procedure TForm1.ApplicationEvents1Idle(Sender: TObject; var Done: Boolean); begin DrawScene; SetCursorPos(Width div 2 + left, height div 2 + top); fps := fps+1; end; procedure TForm1.DrawScene; begin glMatrixMode(GL_MODELVIEW); glLoadIdentity; // As the Skybox will fill the entire screen, we will only have to clear // the depth buffer and not the color buffer glClear(GL_DEPTH_BUFFER_BIT); //glRotatef(xrot, 1, 0, 0); //glRotatef(yrot, 0, 1, 0); glTranslated(0,0,-xrot); mesh.Render; // rendern // Call the Displaylist of our Skybox glCallList(List); SwapBuffers(FDC); end; end. bitte helft mir :( ich weiß sonst nicht mehr was ich machen soll? ich danke im vorraus MfG chefx |
Re: OpenGL 3ds laden geht nicht ?!?
Eine ähnliche Frage habe ich auch schonmal auf delphigl.com gestellt ;)
Bei mir hat es dann nachher so funktioniert (bin mir aber nicht mehr sicher, ob wirklich alle Schritte nötig waren; der mit mesh[0].visible ist es aber ganz bestimmt):
Delphi-Quellcode:
Leider unterstützt dieser Loader, so weit ich weiß, keine richtigen Animationen (zumindest nicht von Anim8or, sowohl mit Bones als auch mit morphing). Gäbe es da vielleicht auch einen speziellen oder einfach einen umfangreicheren? Leider bin ich noch nicht so weit, dass ich selber einen schreiben könnte...
//Loading
model1.AddModel(); model1.Models[0].LoadFromFile(extractfilepath(paramstr(0))+'3ds\model.3ds'); model1.Models[0].TexturePath:=extractfilepath(paramstr(0))+'tex\'; model1.UpdateTextures; model1.Models[0].Mesh[0].Visible := true; //model1.Models[0].Mesh[1].Visible := true; //bei mehreren Meshes model1.Models[0].InitSkin; //Rendering Model1.AdvanceAnimation; Model1.Render; |
Re: OpenGL 3ds laden geht nicht ?!?
|
Re: OpenGL 3ds laden geht nicht ?!?
Ich auch, aber nicht die uralte Version ;)
![]() Einfach wie gewohnt entweder in den Lib-Ordner packen oder in den Projekt-Ordner, in die uses einbinden und
Delphi-Quellcode:
Model1: TGLRender; //bzw. bei dir mesh
|
Re: OpenGL 3ds laden geht nicht ?!?
ok danke nochmal für alles hab jetzt alles hinbekommen^^ :-D
MfG Chefx |
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:00 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz