Registriert: Di Jul 01, 2003 18:59 Beiträge: 887 Wohnort: (The Netherlands)
Programmiersprache: fpc/delphi/java/c#
Brushing up the new version of gl3ds i encounter some problems.
Basic setup is like this:
TBaseModel
and derived from that are
TGLModel
T3dsModel
TBaseMesh
and derived fromt that is
TGLMesh
TBaseModel contains an array of TBaseMesh
Now i get problems when rendering because TGLMesh is never used.
A model is created like this
var
mymodel: TBaseModel;
mymodel := TGLModel.Create();
mymodel.loadfromfile('name.3ds');
Here internally the needed class is used for loading (in this case T3dsModel) and the properties are copied to the on TGLModel based object.
So far so good.
Even mymodel.render can be called.
The problems arrise when the meshes are called. T3dsModel (and TBaseModel) has no knowledge of TGLMesh and thus create TBaseMesh objects. As an end result the mesh cannot be rendered. Not even by typecasting. As an hack the override on the render procedure can be removed in TGLMesh and things work again by using a typecast in TGLModel.render when rendering meshes.
What can i do so that when mymodel is created as an TGLModel the meshes are created as TGLMesh and not as TBaseMesh. The problem with that is that i do not want to put knowledge of TGLMesh in TBaseModel or T3dsModel.
E.g. can i pass a class of TGLMesh to an property of TBaseModel then i could use that for creating the proper object. But how do i store that as i do not want knowledge of TGLMesh in TBaseModel. Oh wait i may store that in an class of TBaseMesh. ... (typing a message sometimes make you get ideas on how to solve the problem)
Registriert: Do Sep 02, 2004 19:42 Beiträge: 4158
Programmiersprache: FreePascal, C++
Yes, I think to pass a class of TBaseMesh to the loading function would be the nicest way to solve this.
I use this technique at different places and it is a very well working solution if your class structure is well defined, so that there is no problem when calling the different methods from a instance of TGLMesh which is declared as TBaseMesh.
greetings Lord Horazont
_________________ If you find any deadlinks, please send me a notification – Wenn du tote Links findest, sende mir eine Benachrichtigung. current projects: ManiacLab; aioxmpp zombofant network • my photostream „Writing code is like writing poetry“ - source unknown
„Give a man a fish, and you feed him for a day. Teach a man to fish and you feed him for a lifetime. “ ~ A Chinese Proverb
Registriert: Di Jul 01, 2003 18:59 Beiträge: 887 Wohnort: (The Netherlands)
Programmiersprache: fpc/delphi/java/c#
yes it also works in reality. Now i can clean up some more. Also this now opens the possibility of using a TDXModel and TDXMesh or TGL20Model or TGL15Model.
For the moment i stored in a property. Your solution as to only pass it when needed is also apealing. But it can be a hassle passing it along different procedures involved in loading and parsing 3d formats.
Mitglieder in diesem Forum: 0 Mitglieder und 2 Gäste
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.