Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / GDK.Net / Visual Studio 2005: OOP Wrappers

Author
Message
Mudbug
18
Years of Service
User Offline
Joined: 2nd Nov 2006
Location: Rome, GA USA
Posted: 20th Nov 2006 08:40
Being a c# programmer by trade, I love working with objects. I have a made a small effort so far to abstract away the GDK.Net procedural-based commands within an object wrapper layer. It allows for code like "myObject.rotate(x,y,z)" instead of "oDB3D.RotateObject(Id, x, y, z)". There is more work to be done on the library, but it is functional so far. It should be enough for you to get the idea of what can be done with object wrappers.

Here is a snippet from a test application I am using to work with the library (you can't run this since it is only a small part of a larger project, it is provided as an example):


-MudBug

Attachments

Login to view attachments
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 20th Nov 2006 19:17
Nice one Mudbug!

I am also doing something like this myself, but because of my laziness this weekend, I didn't even finish the class diagrams.

As a C# programmer, just like you, I feel DGDK.NET is just to far from being OOP, "oDB3D.RotateObject(Id, x, y, z)" is just too ugly!

But I was going to try a little bit different aproach, writing my Wrapper as a Plugin to DGDK.NET. Paul may correct if I'm wrong, but in my opinion, writing it as plugin should be the best way.
Mudbug
18
Years of Service
User Offline
Joined: 2nd Nov 2006
Location: Rome, GA USA
Posted: 20th Nov 2006 21:07
Thanks kBessa, I hope the code is useful to you. I would love to see your plug-in when you are able to get to it.

I didn't think about using plug-ins myself, I know almost nothing about them. I will spend some time researching plug-ins soon (maybe while everyone else is eating Turkey during Thanksgiving, hehe).

I am using this code in its own assembly. I found that once I initialized the engine in the main assembly, referenced assemblies could use it too (had to think about that one a little - because both assemblies reference the same COM object).

-MudBug
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 21st Nov 2006 01:31
Now that I have the time I will study what you've done in you library.

Maybe I can get something working by weekend, then I will surely post here, but I don't think it will be THAT different from yours...

One think that I hate the most are those A,B,C Methods.
Overloading is heaven! I miss this the most, along with XML Documentation on code (then we know what the method does and what is the parameter for). These among others things are missing.

I was thinking of making multiples plugins, instead of just one. It could be more organized, and different people could work on different parts at the same time. But I haven't decided upon it yet, because there are advantages and disadvantages.

One think that you've already done and I didn't think about yet was the ID Manager, great job! I don't know if I should make my own ID Manager ou should I use yours (that is, if it isn't there any problem).

And last but not least: Thanksgiving! We don't have it in Brazil, so I'll have to wait until December 24th to eat some Turkey, oh my...
Mudbug
18
Years of Service
User Offline
Joined: 2nd Nov 2006
Location: Rome, GA USA
Posted: 21st Nov 2006 02:38
I have found a couple of minor "problems" with the IdManager class.
1. Source file name is wrong. I re-named it from DarkEntity.cs to IdManager.cs
2. Region name above the public methods should be "Public Methods"

I changed the DarkObject class so that it takes native .Net System.Drawing.Color structure:


Now you can do statements like: MyObject.Color = Color.Blue;

-MudBug
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 21st Nov 2006 02:48
I had planned on creating exported OOP classes from the toolkit that actually wrapped the DGDK.NET object/image/bitmap/sound/music and animation creation so that you dealt with actual objects rather than IDs. The thing is this, people are always going to want to code this functionality in their own way that makes them feel comfortable. Having one set of classes within the DGDKLib namespace will probably be cool, but it might not suite everyone.

Also, and this has always been the goal of the toolkit design, is to ensure that people moving over from DBP or the DGDK C++ version, have familiar ground to work on. That way, all the subclassing and object wrapping can be left to the programmer.

As said though, I will do this in the near future, but for now, the important thing is for the toolkit to become familiar territory for all .NET developers, and for the issues still outstanding on the DGDK engine code, to be fixed. After that, things will become interesting.

Paul.

Mudbug
18
Years of Service
User Offline
Joined: 2nd Nov 2006
Location: Rome, GA USA
Posted: 21st Nov 2006 03:04
It most certainly has to be on the mind of just about any c# (or other OOP language) developer. I can imagine there will eventually be many different frameworks available, each with their own strengths and weaknesses. You are right, this could be very personal. And really good framework takes time and effort to develop (Look at how long it took for .Net )

I look forward to the day we see a standard accepted framework, because without it, I can imagine the difficulties in sharing code. One would be required to specify which framework the code is designed to work with (boy, that could get ugly!)

That said, I am happy to have the opportunity to make OOP wrappers around this wonderful game engine in my favorite programming language!

-MudBug
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 21st Nov 2006 03:09
Amen to that!!

Paul.

kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 21st Nov 2006 04:29
I have to agree with Paul, it is something personal.

And MudBug, you'r right. Imagine a lot of threads like: "Look at my source, requires MudBug's Wrappers, it won't with kBessa's ones!" Baaaaaaaad! Hehehe

I was going to do some wrappers for own use, because I don't want to do just one game in DGDK.NET

Maybe we could join our efforts and make just one Library?
I think it would be nice if members of the forum joined to do it! You can count on me!

And Paul, Congrats for the DGDK.NET (again). It is GREAT! Since the day I knew about DGDK (DarkGameSDK at the time) I was hoping it would have a .NET port. Waaaaaay too cool!
Mudbug
18
Years of Service
User Offline
Joined: 2nd Nov 2006
Location: Rome, GA USA
Posted: 22nd Nov 2006 03:27
kBessa, feel free to email me to discuss options. I will be happy to share any wrappers I write. Code I posted here is really proof-of-concept code. We would have to do a good bit of planning up front before we would start on a "real" framework. We need a list of design goals, and some rules about how the API should look. What namespaces to use, etc.

In the mean time, I will update my framework as I need pieces of it for my applications. If anyone wants to see whatever is the latest code at the time, email me.

-MudBug
Dark Inferno Studios
18
Years of Service
User Offline
Joined: 7th Nov 2006
Location: United Kingdom
Posted: 25th Nov 2006 00:04
Quote: "
I have found a couple of minor "problems" with the IdManager class.
1. Source file name is wrong. I re-named it from DarkEntity.cs to IdManager.cs
2. Region name above the public methods should be "Public Methods"

I changed the DarkObject class so that it takes native .Net System.Drawing.Color structure:
+ Code Snippet
public Color Color
{
get
{
return _color;
}
set
{
_color = value;
oDB3D.ColorObject(_id, (uint)value.ToArgb());
}
}


Now you can do statements like: MyObject.Color = Color.Blue; "


This doesn't work, there's no colour change.
Mudbug
18
Years of Service
User Offline
Joined: 2nd Nov 2006
Location: Rome, GA USA
Posted: 25th Nov 2006 04:46
Here is the latest code as it is evolving, and a little test app to show color changes using the famous rotating cube.


Please keep in mind that this is early code. The namespace will certainly change (I used NomadSoft as a placeholder. There will be real name there later).

Eventually this library will be available as a plug-in. For now you can load the library project into your solution and add a reference to it, or use all of the classes directly in the main project.

-MudBug

Attachments

Login to view attachments
G Man
20
Years of Service
User Offline
Joined: 17th Nov 2004
Location:
Posted: 28th Nov 2006 05:46
In the same vein, here's the start of an abstracted 3d Model class in VB.Net.



Intel Pentium 4, 3.4GHz, 1280MB RAM, NVidia Quadro FX3000/256MB, 240GB HD, XP Pro
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 28th Nov 2006 22:26
Me and MudBug joined our efforts to make to make just one solid Wrapper, which we called DarkEngine (as seen in MudBug's last post).

As a decision, we will not be releasing any source code for now, but it someone wants to join us on the making of this wrapper, please, send me or MudBug an email. We'll be glad to have any help.

What we're trying to do is something to the DGDK.NET users made by DGDK.NET users.

As the status of the project, it alredy evolved to be a DGDK.NET Plugin (not just a common class library anymore). We're deciding the final guidelines and coding have already began. Stay tuned!
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 28th Nov 2006 22:38
And I almost forgot!

DarkEngine is not supposed to add new functions to DGDK.NET, it is just a wrapper. Our purpose is to add true OOP Style Programming to DGDK.NET. Ex: MyObject.SetPosition(X,Y,Z)

This doesn't mean we wouldn't ever add something new to it, but it is not the purpose of DarkEngine.

But if we were to add 107 new commands related to handling something (like AI, Physics, whatever), I think it's better to release it as a different plugin so users of the DGDK.NET by itself or users of DarkEngine could make use ot it (we shouldn't obligate anyone to use our framework if he/she wants to use any plugin we release).
James Bondo
18
Years of Service
User Offline
Joined: 12th Nov 2006
Location: Denmark
Posted: 29th Nov 2006 01:52
What about:
MyObject.SetPosition.X = int
MyObject.SetPosition.Y = int
MyObject.SetPosition.Z = int

AKA, using public attributes

Proud member of The Unforgiven Warriors
http://www.tuwguild.com
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 29th Nov 2006 04:46
Hello James Bondo!

We could probably implement that, but DGDK only has PositionObject(id, X,Y,Z).

The primary objective is to implement the existing methods in an OOP friendly manner, then we could add new things.
G Man
20
Years of Service
User Offline
Joined: 17th Nov 2004
Location:
Posted: 29th Nov 2006 05:20 Edited at: 29th Nov 2006 05:21
Quote: "
What about:
MyObject.SetPosition.X = int
MyObject.SetPosition.Y = int
MyObject.SetPosition.Z = int
"


If you look at the code I posted, that works like this:



Intel Pentium 4, 3.4GHz, 1280MB RAM, NVidia Quadro FX3000/256MB, 240GB HD, XP Pro
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 29th Nov 2006 09:23
Erm.. Why not just use oDB3D.ObjectPositionX/Y/Z into local variables of the method, and ajust according to axis required when recalling SetObjectPosition.

Paul.

James Bondo
18
Years of Service
User Offline
Joined: 12th Nov 2006
Location: Denmark
Posted: 29th Nov 2006 12:31
Yeah thats what i thought.


the MyObject.Position.X property should just position MyObject with the old Y and Z coords and the new X coords.

But well, i understand if you wanna add already existing functionality first ofcourse

Im really looking forward to this.
I have been using C# for some time by self learning. And then i recieved lecture as part of my study and learned about OOP and stuff like that. Then i bought this ^^

Keep it up.

Proud member of The Unforgiven Warriors
http://www.tuwguild.com
Mudbug
18
Years of Service
User Offline
Joined: 2nd Nov 2006
Location: Rome, GA USA
Posted: 29th Nov 2006 22:27
Following the rules of immutability would prevent the properties of the object "Position" from being changed by an external agent. If we don't do this, it opens up our MyObject object to possible nasty side effects (for instance, now we have to notify MyObject that the Position class changed. This is possible, but not pretty).

A property of MyObject.Position could provide you read-only information about the objects location (MyObject.Position.X), but you should not be able to set it like "MyObject.Position.X = x;". Instead, you would have to replace the Position object with something like "MyObject.Position = new Position(X,Y,Z)".

The more likely acceptable implementations could be:
MyObject.X = x;
MyObject.SetPositionX(x);

Hope that makes sense

-MudBug
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 29th Nov 2006 23:04
Also, try not to create too many layers of thunking for such simple functions as this will impact performance on a global scale quite significantly. The DGDK.NET interface is as efficient as I can get it using the current interop layer for the toolkit, so as long as you keep the wrapper classes simple, this should be maintained.

Paul.

kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 1st Dec 2006 05:12
Even DBPro has only "Position Object" with X,Y,Z axys.

We could do something like this (code is missing a lot of things, it is just an example):

public float PositionX
{
set { oDB3D.PositionObject(value, oldY, oldZ);
}

And then do the same to Y and Z axis. It is possible! But think about the overhead we would be creating with people doing something like this, in a loop:

MyObject.PositionX = 5;
MyObject.PositionY = 5;
MyObject.PositionZ = 5;

People would be calling the same method 3 times! Multiply by 1500 objects, that's 3000 uneeded calls!

One possibility is to set the properties X, Y and Z, then calling a method like MyObject.SetPosition() (with no parameters), almost what MudBug said. (thinking about it, this seems like a good one, I wouln't have to create a lot of variables, they would be integrated in the object).

But still allow people to use it without the properties: MyObject.SetPosition(X,Y,Z).

Anyways, I'm not into the "DarkObject" design, MudBug has been doing it. Hope I have some spare time this weekend so I can continue coding.
Scab
20
Years of Service
User Offline
Joined: 11th Feb 2004
Location:
Posted: 6th Dec 2006 02:39
kBessa or Mudbug,

Will Dark Engine work in VB.NET as well or just c#?

Also, what is your progress right now?

Thanks.
Mudbug
18
Years of Service
User Offline
Joined: 2nd Nov 2006
Location: Rome, GA USA
Posted: 6th Dec 2006 07:15
Hi Scab,

Yes, just like any other class libraries written in .Net, it will work with VB.Net as well as c#.

As for progress, that's really hard to pinpoint right now as we are just getting started. I mostly have been working on wrapping the 3D Objects. kBessa is starting work on the 2D stuff. Of course there are many more areas then that. I will try to put together a road map soon that will show our progress and post it here.

-MudBug
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 10th Dec 2006 08:19
Hello Scab!

As with any other .NET Library, it will not only work with VB.NET and C# (as MudBug said), it should work in any .NET language (Managed C++, J#, Delphi.NET, Cobol.NET, and lots more).

We will be setting up a web site as soon as possible. Domain's registered, layout finished. I'll try to get it online by monday.

Me and MudBug are really occupied with our "Real life jobs", but I'm doing my best to have a Technology Preview by christmas, at least with the most important methods wrapped.
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 11th Dec 2006 19:11
kBessa

I cant wait to see your wrapper. it will be the right way to code

I have planned to make it by myself, but if you already have it then I can safe the time

--
Niels Henriksen
Working on a RPG right now
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 13th Dec 2006 22:40
Hey Niels, Thanks for the support!

I'll try to get back to coding the wrapper. It's been a week away now (my "life job" took all my hours away).

Me and MudBug were doing this ourselfs, that's why we got together, to join efforts.

I'm hopping to have a Snake demo by christmas, just to demonstrate the DarkEngine usage (a early-adopter of the pre-alpha realease of the wrapper, hehehe).

Happy coding!
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 21st Dec 2006 08:51
Oh my, it's been a week since my last post!

Good news everyone! This last 5 days I've been giving the best of me to code in my spare time. Almost everything has been wrapped. The missing classes are Vector2, Vector4, Matrix4, Multiplayer and MemBlocks.

Object, Mesh and Image may still be missing some functions. MudBug has been a lot busy (hope you to have more spare time, but don't forget about your real job, this is for fun pal)

I'll be giving the best of me to get the most of them completed by tomorrow, as me and MudBug agreed to release a preview of DarkEngine in the next days. Hooray!

I hope someone is still interested in our plugin, because although I've been coding it, I won't be able to use for the next 3 months! NO!!!

I'm having ideas for other plugins, but I won't be telling you right now.

Happy Coding!
James Bondo
18
Years of Service
User Offline
Joined: 12th Nov 2006
Location: Denmark
Posted: 21st Dec 2006 17:10 Edited at: 21st Dec 2006 17:10
Im eagerly awaiting this plugin as i like OOP very much and is getting lecture at school.

Proud member of The Unforgiven Warriors
http://www.tuwguild.com
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 21st Dec 2006 18:35
Im just sitting and waiting for it... cant we have the version now and then play a little with it and then just update it when you are finished?

--
Niels Henriksen
Working on a RPG right now
Mudbug
18
Years of Service
User Offline
Joined: 2nd Nov 2006
Location: Rome, GA USA
Posted: 21st Dec 2006 19:17
You will have the current version as soon as KBessa makes the release. I don't think there is any more coding that will be done for this preview release.

Sorry for the small delay, you will have it soon. Merry Christmas!

-MudBug
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 21st Dec 2006 20:31
It's great to hear from you people!

I'm wrapping Matrix4, MemBlock and we'll revise Image(this one was MudBug's work, I just wanna be sure most important functions are wrapped).

I think everybody can live without Multiplayer, Vector2 and Vector4 for now. I'll then revise somethings and will probably make the release by tomorrow. Hooray!
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 23rd Dec 2006 22:52
I cant wait... maybe I have to cancel xmas for my family while Im playing with the wrapper

--
Niels Henriksen
Working on a RPG right now
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 24th Dec 2006 00:01
The wrapper is release! Check it here at tthe forum. It's the first topic!
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 24th Dec 2006 00:31 Edited at: 24th Dec 2006 01:11
For those who might be missing the other post with the preview, here's the link:

http://forum.thegamecreators.com/?m=forum_view&t=96155&b=22

Login to post a reply

Server time is: 2024-11-19 10:24:11
Your offset time is: 2024-11-19 10:24:11