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 / OOP w/ DarkGDK

Author
Message
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 26th Feb 2008 02:02 Edited at: 22nd Mar 2008 19:31
To get some practice with C++, I decided to create an OOP wrapper for DGDK. It's pretty basic now, but it'll get better as I work on it (I hope). The header files are attached to this post. Just include 'DarkOOP.h' in your project and it should work fine. I'll come up with some docs on it soon so people will actually know how to use it.

If you have problems with it, wanna know about something regarding it, or have any feedback or suggestions, PLEASE tell me.

Attachments

Login to view attachments
Niels Henriksen
19
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 26th Feb 2008 07:01
This is perfect. TGC should have GDK OOP from beginning..

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa)
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 26th Feb 2008 07:40
What exactly are the advantages of this?

Kentaree
21
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 26th Feb 2008 10:55
The benefits of being able to use OO... Some people just prefer it to procedural programming.

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 26th Feb 2008 12:55
Quote: "What exactly are the advantages of this?"


What Kentaree said. I just prefer using OOP to procedural programming, and I assumed that a couple people on here would, too, so I decided to post it here.
Niels Henriksen
19
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 26th Feb 2008 14:26
OO Programming gives you the ability to not to need to remember ID's on objects. And the code is more easy to read.

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa)
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 26th Feb 2008 16:13
Another important thing it allows you to use is polymorphism.

For example, you can create several unique classes for different types of objects, and derive them from IObject. Why is this so useful? Using pointers, you can access the IObject members of your derived classes. This is useful if you want to write code that can work with all types of objects, while still allowing you to have extra data/functions for them.

jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 26th Feb 2008 19:03 Edited at: 26th Feb 2008 19:05
I have a pretty extensive OOP wrapper for GDK also. Mine is thousands of lines long - and has frustrum culling, limb culling, lod, physics mesh "marriage" to objects (lod or not), Cam, Display, Objects, Sprites, effects, timers, clock, images, etc. ... to many to mention.

Everything is set up where there is a base object, and an array of them that's made for ya -

example:





If you want I can post it... I'll gladly use my own thread - I don't want to compete but I'm all for helping others get a leg up if they want it.

[no input classes yet though]

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 26th Feb 2008 21:21
@ jason p sage:

If ya wanna post it on this thread, that'd be fine with me! In fact, I could probably turn this into a general OOP DGDK thread, for everyone to post their wrappers. Your wrapper looks pretty awesome!

Mine is pretty basic, and I'm doing it mostly just as a learning experience. I'd love to see what others have come up with!
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 27th Feb 2008 05:59 Edited at: 27th Feb 2008 20:15
Here ya go. Note you might need to change directories in the Linker etc to get your libs right.

The lib expects sparky dll (I stuffed mine in my GDK area - so its seamless) and Dark Physics... BUT NOTE - that DarkPhysics isn't THAT heavily integrated yet... but the demo code is.

I TRY to write neat code - so its hopefully readable... though less than main stream - I wrote my own foundation classes. ALL COMMENTS Welcome - and I have "Self Tester" for these foundation classes - the idea is (even though boring to write) is that if you BLOW up code - you don't always know it until after a long debug session chasing the wrong tail... but the self tester does alot and will usually telly you when things are messed up.... as such - it serves as a good demo program to see little pieces of the system in action.

I Supplied media I'm playing with so you actually see something when it compiles for you.

Note - its not a finished system. My next main "TODO" is to take that frustrum stuff - and see what calls I can make to help use it a little more procedurally - like setting up REGIONS and when you add static objects - the code is smart enough to add it to the correct region (and or group). Kinda Manual now. Eventually I want this in a level editor - so you design performance bits in the actual level creation - like "How to Cull this Level" might not be anything like the next one

Hopefully the forum allows a 16meg upload! (It didn't.. go here: http://code.google.com/p/darkgdkoop/)

tell me what ya think!

[edit]Changed file size...doh.. 16megs! sorry - beats having no media though[/edit]

[edit]Note: Physics integrated - but only in that the system starts DarkPhysics, also the object class has a member named phyobj... which if left alone means nothing. If Assigned - then the OBJECT CLASS INSTANCE you assign it becomes the MESH POSITION/ORIENTATION Master. This is useful for having a mesh that is not to be visible control everything if you want, and the OBJECT itself (and LOD versions) will all behave as you would hope. It Defaults to being a COPY of the main object it belongs to. This allows making one object - and making it a rigid body - and it just works.



The frustrum stuff is mid development but works - the best I can tell you is to look at the test_frustrum_lod.cpp app.

Oh - and from TGC Newsletter 59 (I think...BitMapFonts) I read basically how the Sprite Text was done - for writing sentances etc... so I implemented that as well. There is a BitMap Font CPP file - but I'd use the test_bitmapfont.cpp to see how to use it...

It allows writing from left to right, right to left - fixed with - variable width fonts, um.... You'll see.

...Oh... AndrewT - BTW - The reason I wrote my wrapper was for my own use - so things worked the way I like to code. I've been coding like 25 years now - so I don't always like new-jack style and prefer instead to write my own - (like for your reasons - leanring) or for the simple fact that if I wrote it - and its broke - its my fault - and I know what to do to fix it - because I literally have BUILT everything so I KNOW what's going on. These are good reasons for you to continue your own.

The chances of getting all these developers to adopt one OOP C++ lib is nil... Many will just assume go to C# for OOP - but.... I'm a believer that C++ is direct to PC as close as you can without assembly (FreePascal another favorite of mine) and that OOP works fastest when done in Assembly (Yes it can be done - I've done it) and in C++...not to mention C++/Pascal OOP has been around longer and is much more portable. For developing games in microsoft that doesn't account for much - but for staying fluent in a language you can use anywhere... I think thinks its good you're hacking together your own library. I Firmly believe you learn more by doing it yourself. THEREFORE - Feel free to adopt this code I presaented - but equally - look at it to see what ideas it gives you!

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 27th Feb 2008 21:15 Edited at: 27th Feb 2008 21:21
Very cool! I'm downloading now...

[EDIT]

It's pretty cool! Definitely more advanced than mine.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 27th Feb 2008 21:30
Glad you like it! Lot-o-code Eh?

I'll do my best to try to answer questions and things. Honestly, I think the hardest thing is getting it to compile - Got DarkPhysics? Adjust the vs2008 Project Properties - like the Dir's for General C++ "Input" and the files for the Linker->Input area of the project confguration. Same for Sparky's GDK Collision lib.

You'll have to configure the Foundation Project and the GameClasses one.

AndrewT - did you get it to compile and run and demos? The FoundationClasses demo - is ...well.. boring... but good to learn from the code (The self tester) but the fun stuff is the GameClasses area. If you have DarkPhysics and Sparky's GDK Collision - it should be pretty interesting.

Let me know how it things go! I'm wishing you success!

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 27th Feb 2008 21:39
I'm having a bit of trouble compiling anything with DarkPhysics. I'm in 'Properties->Linker->Input'. What should I do here?
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 27th Feb 2008 22:16
You have DarkPhysics? If So - you need to put in the path + *.lib file name for it in the Project->Liner->Input Area (i think) I think you need to type it out or cut-n-paste - I DONT THINK there is a browser file dialog thingy or anything.

If you DONT have DarkPhysics - then you go into jgc_daddy.cpp - and look for the PhyStart (Start up Function) remove it via a comment. Also Comment out any and all DarkPhysics commands dbPhy?????

Note this will make the demos not quite work right - BUT should still work - ... note the camera has a physics cube collowing it like the skybox in some demos - comment this out to.

I was playing soccer where the camera was me flying around and the TANKS were soccer balls - and I'd kickem into air by ramming (flying into them...slight from underneath) and lauching the tanks way up - eventually to fall onto the trees (A Score!!) so I could watch them tumlbe about.

Does any of this help? Don't hesitate to ask - as other will benefit!

Niels Henriksen
19
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 27th Feb 2008 22:38
jason - nice work... I will look at this becuase Im in betweem C++ and .NET for my game

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa)
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 27th Feb 2008 23:05
I have DarkPhysics. So I'm supposed to put the full path to my DarkPhysics.lib file?? I tried it but it said:



jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Feb 2008 00:06 Edited at: 28th Feb 2008 13:25
Ok....I have a Solution with both Projects - FoundationClasses and Gameclasses. (Note I mention the DarkAI header below but its not required - is not used yet... haven't got that far )

(I Updated the Project Files - just a couple source code fixes - AND download only 7 megs now http://code.google.com/p/darkgdkoop/downloads/list)

I do somethings I'm not sure I should - but here it is:

FIRST:

sc_collision.h and DarkPhysics.h and DarkAI.h are all in my C:/Program Files/The Game Creators/Dark GDK/Include directory.

SECOND:

SC_Collision.lib and DarkPhysics.lib and DarkAI.lib are in my C:/Program Files/The Game Creators/Dark GDK/Lib/vs9 Directory.

----SOLUTION PROPERTIES
Has Two Projects: FoundationClasses and GameClasses
I right click the solution, and select properties to get here. In the form that comes up - I also set the "CURRENT SELECT" radio button - so whatever project I have "Highlighted" in the solution explorer is the one I'm compiling/running.

----FOUNDATION CLASSES - Project Properties (Debug one)
I started with a DarkGDK Wizard, then demoted the default main.cpp and added my own MAIN...usually those test programs... named like test_whatever.cpp. I "Add Existing" or "Remove" (without deleting) when I want to change what app I want to play with so I avoid having a ton of projects to configure

When you right-click the FoundationClasses project in the solution explorer, you get the config dialog. In the left is a little tree control.. I navigate to Configuration Properties->C/C++->Additional Include Directories and my Additional Includes is blank!

I navigate to Configuration Properties->Linker->Input and my additional Dependancies is Blank!

(Foundation Classes Don't need anything DarkGDK blah blah - its just C++ code to use as a stepping stone for task I need all the time.)


--------GameClasses - Project Properties (Debug one)
I started with a DarkGDK Wizard, then demoted the default main.cpp and added my own MAIN...usually those test programs... named like test_whatever.cpp. I "Add Existing" or "Remove" (without deleting) when I want to change what app I want to play with so I avoid having a ton of projects to configure I know I said this above - but it applies here too

When you right-click the GameClasses project in the solution explorer, you get the config dialog. In the left is a little tree control.. I navigate to Configuration Properties->C/C++->Additional Include Directories and my Additional Includes Refers to where the FoundationClasses project is! I've been Told I should have used relative paths - and I should have - this might be one issue. I have: D:/files/code/CPP/Projects/JegasLLC/FoundationClasses but thats a full path obviously. I think: ..FoundationClasses might do ya just fine!

I navigate to Configuration Properties->Linker->Input and my additional Dependancies is:
DarkPhysics.lib with NO Path information (I think the DarkGDK stuff is in the "Search for uincludes here" list in Vs2008.) I'll eventually need to add Sparky reference here when I actually have sparky code in use in a demo or game or make references to it.


Does this Help? If not - I can set up a "Remote Session" and look at your screen and see if we can't get it to work. Note - in a worst case scenario I follow these steps after:

Make a new Solution + Project named FoundationClasses using the DarkGDK wizard - compile and run. Does it Work? good! Copy all the foundationclasses *.cpp and *.h files to that directory where the main.cpp was just created. Remove main.cpp and add the test_foundationclasses.cpp to the project. Compile and run ... work? good!

Add a new Project to the solution named GameClasses using the DarkGDK Wizard again. compile it, run it ...work? Good... DarkGDK configured properly. Add the media directory I suppied to the directory where your new main.cpp was created for this new project. Now toos all the gameclasses *.cpp and *.h files to that directory also. remove the default main.cpp, and add one of the test apps I made. I recommend the Test_Bitmapfont.cpp one first. (No Physics etc - though if you don't have DarkPhysics it might not compile due to references etc)...any way - now you must set up this project properties like I said mine were above... especially the added include directory to point to foundationclasses' directory.

Now the weird part. You need to "Add Existing Files" to GameClasses. all the source code in the foundation classes needs to be added (not copied etc... added to the project.. find them in the FoundationClass' dir.)

[edit]
Before you can run test_bitmapfonts.cpp!!! I was going through this after I posted to be certain - and found something I overlooked. ONE Directory Path

Change test_bitmapfonts.cpp line 57 from:

to


(fonts directory didn't exist when it was written.) You can also just download the latest - link in top of THIS post.

Issues and Fixes Located here: http://code.google.com/p/darkgdkoop/issues/list

[/edit]

Now ...as they say in the streets... "RUN IT"

test_bitmapfonts.cpp


test_frustrumculling_basic.cpp (After replacing the stock test_frustrumculling_basic.cpp file with this (sorry I'm human):


http://www.jasonpetersage.com/darkgdkoop/darkgdkopp02frustrumculling_basic.PNG

test_frustrum_regions.cpp
(far Away View - Ignore the Supersized beach bug - its the Secret BOSS on level 4 LOL ) Note: The Billboarding "Point to cam" stuff is toggleable and you can set what axis (x,y, or z ...any combination) will point to camera - and of course distances for each of the (three maximum) LOD levels.

http://www.jasonpetersage.com/darkgdkoop/darkgdkopp03frustrum_regions.PNG

(close up - to show LOD)

http://www.jasonpetersage.com/darkgdkoop/darkgdkopp04frustrum_regions.PNG

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 28th Feb 2008 12:57
Wow!! I need to try and implement bitmap fonts in DarkOOP. Then, once I'm a lot better I'll think about the othyer stuff.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Feb 2008 13:22 Edited at: 28th Feb 2008 14:01
You know - its funny - it took almost as long to get the bitmap fonts working how I liked as it did to port Lost In Thought's Frustrum Limb Culling to DarkGDK! LOL

If you use my code as a guide - You'll notice that the JFC_AR (array class), JGC_SPRITE, and JGC_IMAGE classes all work together. In the jgc_bitmapfonts.cpp file - there is an Array for fonts, and array for "Strings of text", and the technique I borrowed from the Newsletter - was if you have a bitmap font "string" and write it and its 10 letters, then you change that string to 5 letters - it recycles that string (no new mem allocation if I recall) But when you write something longer - like 20 chars, than that becomes the amount of memory reserved.

Again - in case you missed it - I noticed some source errors - mostly directory names not jiving with the files I uploaded as well as some code that didn't stay current. All the little issues I found have been fixed. So if you go to http://code.google.com/p/darkgdkoop/downloads/list the latest file is there. (Smaller too... I accidently had some bloat - I thiink the intellisense database musta been in the first file I released) its 7 meg now.

@AndrewT - Did my long description help you compile the code I posted? Is anyone else having any problems getting things to work? Nothing is more frustrating then download code that seems DOA. I don't want anyone fighting just to get the demo programs running I posted pictures of.

[edit]Something I should tell you guys about regarding frustrum culling. I have diagnostic objects (A Sphere, a cube, and a box) attached to EVERY "Cull Thing" - and there are flags to "Show Primitives" (global toggle) and flags to toggle each primitive. The reason is when they are on - these transparent boxes can be displayed to help debug and see how the frustrum thing is working. Also Note that Limb Frustrum Culling is already implemented. So if you have a limbed object like a building from 3DWS - it will limb cull with something like:


Let me get you a pic of these boxes turned on. (I bring them up because in release you might want to hunt the code down that adds em and comment all related code to them. Eventually I'll have a compiler "directive" to toggle the feature at compile time. For a relase of a project - its a waste of resources but is an invaluable debugging aid.

[edit]Note: The empty boxes aren't empty - the LOD'd Bill Boards don't show through - but they are there. Models Do - hence the tree model shows. The BIGGER AREA thats GRAY surrounding everything... thats a region. In other words - the camera is inside the region - which is why the code bothers to render the trees in that region. Refer to other pics in my previous post. It might make the region thing make more sense when you think of it as a BIG BOX with stuff in it - and it only bothers with the little guys when the BIG BOX is in view.

also - the low frame rates isn't my code - its my video card - its beat! Without the frustrum code I get 0-2 FPS MAYBE!


Full size: http://www.jasonpetersage.com/darkgdkoop/darkgdkopp05frustrum_regions.PNG

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 28th Feb 2008 21:54
The frustum culling is cool! I've just finished adding some basic features of DarkPhysics, I'm gonna work on it some more tonight. Your OOP engine looks like it's coming along very well!
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Feb 2008 22:01
Quote: "The frustum culling is cool!"
Is it safe to say everything compiled For YOU? Huh? Huh?

Niels Henriksen
19
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 28th Feb 2008 23:44
Jason - It worked for me . I followed your description and removed ref. to Sparky.

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa)
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Feb 2008 23:57
Niels Henriksen
19
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 29th Feb 2008 00:14
I do... I just need to split it apart so I can understand it... and change it

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa)
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 29th Feb 2008 01:11
Wierd...I can compile fine, but when I run, it immediately closes with the typical "GameClasses.exe has stopped working." message. It doesn't give me any other messages, just that. Any idea what's wrong??
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 29th Feb 2008 01:57
Can you DEBUG to see what line# and in what file its choking on? I suspect one of two things - (maybe more but)

1: Screen Resolution and Depth? Currently the demo programs use a 1024x768 with 32bit depth

2: If a File Is Not found (Media) It will Crash Likely.

3: Not sure about this one BUt I THINK alpha transparency and/or the Shader I use in the SkyDome might be hosing you as I don't check if Shader 2 is on your video card or not (I think its Shader Version 2 it needs - CuCumber wrote that one LOL I dunno Shaders - no time to learn yet - Though Visigoth showed me a trick or two that should get me up to speed kinda quick once I dig in!)

So you see - it could be a number of things - and I AM WILLING to schedule a remote session where I can see your Screen remotely and see what's going on!

I DON'T want you stuck man! Code that doesn't run isn't worth the disk drive space!

you can try loading a demo app, and looking for the SKYDOME thing - and comment it out... Make sure you have in the GameClasses directory .. the Media Directory etc... and try to debug into the code to tell where it's choking.

If you step through the code - you may find that ... Say Load Image doesn't actually load the file because the files doesn't exist - which in turn prevents and array (arra of images) getting populated - which might make the code choke when it tries to access that image directly in the Array.... (I know I do that one alot LOL )

Seriously - I want to help get you going - (As can be seen by the amount of detail I've been posting!) C++ OOP Rocks!... when it runs

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 29th Feb 2008 02:07 Edited at: 29th Feb 2008 02:08
1- Well I have a 1440x900 monitor, but I'll try changing the res.

2- I'll check to see everything is loading right.

3- I have an 8800GTS, so yes, my video card supports the shaders.

I'll try messin' with the display mode, and if that doesn't work I'll check to see that the media is loading.

::EDIT::

Wait, do you think it could be Vista?? There have been a couple occasions where DBP/DGDK apps haven't run 'cause of Vista.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 29th Feb 2008 02:33
it's 8:30pm my time - got your messge 20 min I guess after you posted - anyways - I'll be up for a few more hours if you want to get that fixed up - I mean if you can't find it - I'll start a remote session if you want - I know my code better so I might find the hiccup fast.

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 29th Feb 2008 02:42
I'll see what I can do. But really, I think I can get a good idea of what your code does without running it, so that'll probably help me enough. Thanks for all the help, though.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 29th Feb 2008 03:05
Your Welcome... shoot thanx for starting this thread - hopefully more people will come in here and talk about more OOP stuff and share code snippets. you motivated me to share a ton of code... I'm very glad you started this one now!

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 29th Feb 2008 03:07
I hope so too! And I'm glad I had the privilage of talking to someone as experienced as you.
Niels Henriksen
19
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 29th Feb 2008 08:22
jason - just bring in the code

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa)
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 1st Mar 2008 21:03 Edited at: 1st Mar 2008 21:03
@AndrewT - Thank You - You're too kind.

@Neils - I am - I Will

Just Made a test application of Stock DarkGDK Terrain - (This pic has Physics Enabled) - Tanks Don't look right sliding sideways down a hill though... Eventualy I'll get into friction and materials

Anyways, if any one want this new demo application in a hurry - I'll pack it up now - but if you can wait a bit - I'm trying to add my homebrew terrain next - with Welded Poly, Tiles, and ability to load USGS data directly into your game if you want.

Stay Tuned... Anyone else making OOP libs for DarkGDK (even just for your game) aside from AndrewT and myself?

Attachments

Login to view attachments
Niels Henriksen
19
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 1st Mar 2008 22:59
@Jason - I can wait to you pack it with your terrain

I'm also trying to make OOP but have a little problem. Instead of using HideMouse and ShowMouse I want to make a property in a mouse-class like this:

Mouse.Visible = true/false

But get some errors with "static"

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa)
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 1st Mar 2008 23:12
Post your code, I can take a look at it.
Niels Henriksen
19
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 1st Mar 2008 23:55
@AndrewT - cool... but warning. I'm a noobish-noob to C++

mouse.cpp


mouse.h


Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa)
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Mar 2008 00:59 Edited at: 2nd Mar 2008 01:14
I don't think you want static for that. I could be wrong though.

Static is a shared variable (or whatever) that all the instances of a particular class can use. MANY Instances - ONE Variable. NOT One variable Name.

I would do something more like:
jgc_mouse.h



jgc_mouse.cpp



Note: I typed that freehand into this post, so its not tested but I suspect it will work.

[edit]void'd where I should have bool'd...fixed [/edit]

[random though - edit 2]By Making the pvt_Visible simply a BOOL and just "adhering to the rule" you won't change it - you can snip a little overhead via just acccessing the variable directly... if you want. Eliminates need for the the Visible_Get() function.
[/edit]

Niels Henriksen
19
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 2nd Mar 2008 01:03
But you are using Visible_Set and Visible_Get. And in the code its JGC_MOUSE::Visible_Set but I want to use JGC_MOUSE::Visible.

Maybe im just blind on .NET where Im using



Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa)
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Mar 2008 01:19
What you sound like your describing is REAL "Properties" where it acts like a variable - when you set it or read it - it does the stuff I did under the hood but "SEEMS" like a variable directly.

Mouse->Visible=false;

or

Mouse->Visible=true;


To tell the truth - that is more "Proper" and I do that in VB, .Net etc myself. When I was getting up to speed and looked at it in C++ - it was a royal pain in the arse so I went with the "Less Correct" just as functional.... hence the comment in the code I provided:
Quote: "//cheap "properties" LOL"


I honestly must say - I don't know how - it was enough of a nuisance where I moved on - seemed like to much work for a simple "thing" - I mean I'm really not trying to protect programmers from "hurting themselves" cuz they don't know how my calls work - and its because I'm not selling a "Tool Set" or "Programming APi"...I'm writing lean and mean code that works and hopefully works fast - that's it. Yes I organize- yes I OOP - but my rules are very lax as I think speed is a major priority - and a little "slop" to some - is just lean code for me.

Sorry I don't know how to write that the way you want. Its definately dooable in C++ though!

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 2nd Mar 2008 01:26 Edited at: 2nd Mar 2008 01:29
I don't know if anyone is actually using my OOP Wrapper, but I've updated my post with the latest version, and you can download it there.

If you have DarkPhysics, you can try out this little snippet which demonstrates rigid bodies:

jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Mar 2008 01:49
Wow AndrewT - Good Form - Different Style than me...but I think THAT's a good thing! I like it! Its lean, concise, and wow.... you're even doing operator overloading and stuff!

Good JOB!

(Guys... My Lib's kinda thick - Andrew's is sweet - its like DarkGDK ShortHand! Check it out!)

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 2nd Mar 2008 01:57 Edited at: 2nd Mar 2008 01:57
Quote: "I like it! Its lean, concise, and wow.... you're even doing operator overloading and stuff!"


Ya, I'm trying to implement as many different things as I can in order to learn more about C++. Thanks.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Mar 2008 05:06
Seriously - seeing how you're digging into the semantics heavily - perhaps you could show us a working example of using "Properties" that is actually easy to understand for everyone! That is SERIOUSLY an important OOP thing!

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 2nd Mar 2008 05:32
I think I'm a bit too noobish to do something like that right now. But I found a site that might help you:

http://ariya.blogspot.com/2005/11/property-in-c.html
Niels Henriksen
19
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 2nd Mar 2008 11:18
Oh... so C++ is not born with Properties as I know them from VB

But I found this also http://www.codeproject.com/KB/cpp/cppproperties.aspx

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa)
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Mar 2008 13:34
It's kind of a pain - and like AndrewT's link mentions in the article - there is no gain (other than for a programmer in the end game) No Performance gain etc...

And as you see - its not THAT hard but .... say for the Object Class - there is a LOT of code to write - and to add Property "emulation" for all the things you might have in your object class - I'd rather write a Blah_Set(int i) and a int Blah_Get(void) and move on. Lazy? Perhaps. Proper? Perhaps Not. I've been coding long enough where I thin I can trust my own judgment on how to do things when I have the facts. The fact is - I have enough to do already than worry about this

I agree its CLEANER in the end game - and I also - like you Neils - KNOW how it gives you more control - by totally controlling how variables/properties are accessed so you can have 100% control - and know if a value is "this" then "THAT" MUST have been set (because there is no other way to do it if your properties encapsulate/insulate it.

BTW - FreePascal, like Delphi and VB, has this built in also - so I MISS the simplicity of:


... then you write the function (for the read) and the Proc for the SET ... and you're golden

...sigh...

Niels Henriksen
19
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 2nd Mar 2008 14:42
So.... I will use Mouse.getVisible and Mouse.setVisible instead

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa)
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Mar 2008 15:10 Edited at: 2nd Mar 2008 15:11
Join the club! LOL

I was looking at AndrewT's code last night and I just thought of something for everyone to think about with "creating" stuff like GDK Objects, Images, etc with the Whole: MyObject = IObject.CreateCube(100); School of thought.

I did thuings more or les this way in my last OOP Lib in DarkGDK - and as you may know - I'm on my 3rd Iron Infantry Codebase, 2nd DarkGDK OOP lib to build it on. Why? Linked Lists are slower than Dynamic Arrays is my main reason - HOWEVER - I've been using what I've learned to mAke this one (hopefully better) and the point I'm TRYING to get to is this:

CONSIDER Making your "Object Class" in such a way it DOES NOT Create the Object... Or AT LEAST so you can create an OBJECT CLASS without creating the Object. Still have it come up with an autogenerated ID, and consider an alternative constructor where you can override the AutoNumber ID Gen.

Why? Even Want to create/delete a few times while building something? Why keep making new instances of the class? Its SLOW! Our classes for GDK are simply a Facny wrapper so intellisense works and to keep track of our GDK "ID's" (at least for me - its an organizational - and code recycling thingy)

Case an point. I'm working on those home grown mesh tools for terrain I have - and I create and destroy a MEMBLOCK Alot in one particular loop. I have a DEFINE (#define cnMemblock_ScratchID 251) And before my loop I make ONE MEMBLOCK Class... But I OVERRIDE the AutoNumber thingy:



Now the memblock DOESNT Really exist yet (I guess it could if I was sloppy in another call but...)

I Now can use this class to CREATE, CREATEFROM IMAGE etc. and I even have a delete method - (with a captial "D"elete that just does the GDK delete... it basically does this: dbDeleteMemblock(this->ID);

This way I'm recycling the class, have pure control of ID's (So I can recycle ID's also)

So - yeah - I have some stuff that lets you do the same thing - all my array classes have something - that returnas the created object... as time goes on I add things like Load etc... just for making the actually game dev faster.. but really it boils down to this:

One of the biggest changes in my design was to allow my "wrapper class" to exist WITH and WITHOUT a GDK "Thing" attached... giving me a lot of freedom ... like you have calling GDK calls directly.

Food for thought - hope this helps someone a little.

jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Mar 2008 19:14
Progress with DarkGDK OOP Mesh Classes Today! Got Two Different Mesh Classes Going Today. I made both from scratch.

JGC_JMESH - My 100% Home Brew Limbed Object Mesh Class - Has 4 Normalization Methods - Each with their own flavor, Has UV Scalling, and there are options to really get things how ya want. If you want multi object terrain with this class - you just make an array of this class... this class makes ONE OBJECT, with whatever limbs ya want... JMESH = Jason's Homebrew Mesh for Tiled Terrain or whatever.

JGC_VMESH - I made this also - but I borrowed some ideas from Visigoth's USGS terrain - namely his POLY layout and his Welded Vert Stuff. I have only one Normalization routine for this because doing the different normalization math techniques on this poly layout is a bear but - this class allows you to have tiled terrain - but of OBJECTS AND it also allows as many limbs per object you want. Think of it as similiar to JMESH - already wrapped in a "Larger Package" This class doesn't have all the UV routines.. but it does have scaling and is PERFECT for using a Terrain Shader to quickly get some great results.

Stay tuned - I'll make a completely new upload available when I get some more things ironed out - like today I found a little bug in the bitmap fonts... First time you String Write? Perfect. After? Hosed sometimes. Figured out why - all fixed. a Visible Flag hides stuff on seceond call etc. Its Fixed... also made some additions to the Init routine - now your screen is all set up in start up - one call - windowed flag, width,height,depth.

Anyways - I added a picture - sorry for double post - but forums dead today - I waited... anyways - Attached is a picture of the first mesh I described using my Jegas DarkGDK OOP lib.

Attachments

Login to view attachments
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 2nd Mar 2008 19:35
Screenie looks cool! YOur wrapper's looking awesome! I'm working on adding more of DarkPhysics right now, then I'll probably go out and buy DarkAI and implement that.

Login to post a reply

Server time is: 2024-05-20 03:27:28
Your offset time is: 2024-05-20 03:27:28