SDK Question New to DLL's

  • Thread starter Thread starter ex-orbinaut
  • Start date Start date
E

ex-orbinaut

Guest
A few threads back (Ref: STOL Shuttle Operations, started by me) a couple of you good people identified for me a particular issue about landing with docked units in Orbiter. You unanimously recommended that I venture into making a specific dll for the purpose.

The aim was to eventually get around to doing dlls, but it was not a priority, as I am quite happy larking about in SC3, for the moment. But I was convinced by the arguments, and have ventured to try it - like - right now. I downloaded a VC++ compiler recommended for Orbiter (MS VC++ Toolkit 2003 w/ Crimson Editor) and set it up. There were a few lib files missing, incidentally, but to cut a long story short I finally got it working.

Now, I am NOT a C++ programmer. I do have some programming experience in the past however, in some languages on various computers over the years (Spectrum BASIC, AMOS, Blitz (on the Amiga), and on the PC, QBASIC, C and VB6). Now, the C business was a while ago, and the human mind is fragile; ie, it forgets! Nevertheless, I have tackled the problem. I made a new mesh, with very few functions, to use as a platform to develop my first dll in C++.

The mesh is the ELO ZOOM ship, presently available for download in its SC3 test version from the Orbiter Hangar. My wish is to make a dll that does the same things as the SC3 version of ELOZOOM. I have toyed around with one of Martin Schweiger's cpp files in the sdk folder (the ShuttlePB), altered, suppressed and added some data, as corresponds, with heavy reference to the SDK guide. Then compiled it as a dll. Funny how it all comes back, after 10 years! Anyway, it worked, within it’s limited extent, and I am pretty much overjoyed. Not all the functions are there, yet, but hey! First one, yeah?

Far from thinking I have swum the Atlantic, I feel I have merely wet one foot in the garden pond, however, when I look at things like the DGIV. After this intro, then, I will say that I am starting this thread basically as my question depository during the continued development of the ELOZOOM.dll. I will occasionally revive it as I run into brick walls that I cannot get around myself, in hopes that any of you with so much more experience in the matter may very kindly point me in the right direction again. I will not be uploading this first “bobby basic” dll yet, as it is nothing special, but I probably will be posting sections of the source code here in this thread for scrutiny and analysis. I pray I can count on your assistance, and will not to bother you with trivialities that a bit of thinking on my part might solve.

Thank you all in advance...

Keith
 
For doing the animations, there is a nice rather undocumented feature in the SDK, which you can't use often enough: The class AnimState.
 
For doing the animations, there is a nice rather undocumented feature in the SDK, which you can't use often enough: The class AnimState.

Many thanks! I will have a look into it tonight.
 
The aim was to eventually get around to doing dlls, but it was not a priority, as I am quite happy larking about in SC3, for the moment. But I was convinced by the arguments, and have ventured to try it - like - right now. I downloaded a VC++ compiler recommended for Orbiter (MS VC++ Toolkit 2003 w/ Crimson Editor) and set it up. There were a few lib files missing, incidentally, but to cut a long story short I finally got it working.
You should probably move up to MSVC++ 2008. I believe the next version of Orbiter will be built against 2005, which means that you might not be able to use 2003, but 2008 will continue to work. I've already used it for several projects using the Orbiter SDK and it works fine.

Also, :welcome: to the joys and frustrations of addon programming...
 
Hello, again...

...rather undocumented feature in the SDK, which you can't use often enough: The class AnimState.

It IS undocumented, apparently. I looked for it in all the Orbiter manuals in the SDK folder, and either I am skipping over it, or it is not there. I delayed doing the simple anim that the ship has with the normal SDK commands untill I have a read up on what AnimState is all about. It could be just the thing, as there is another project that is going to have conditional animations. You know....

If Key = "C" then
If ship on ground and gear down then
Open cockpit


.....sort of thing. Where can I get some info on AnimState?

You should probably move up to MSVC++ 2008.

Thanks for the suggestion, and I will take it seriously, but before I do; do you know if it has any issues with Windows XP SP2? I was never able to use MS VC++6 on XPSP2, which is one of the reasons why I never did anything with VC++.

That aside, a brief update. I am meeting with a good measure of success so far with my dll. I have a question on the coding convention. I made 8 seperate main thrusters, with varying thrusts, but used only one gross total ISP and Max Thrust number. How I implemented the individual thruster powers was by referentially "prorating" the gross total thrust by nozzle area and distributing the percentage of power into the create-thruster command. As they are grouped, I did not see a problem with this. Here's the segment...

const double ZOOM_FUELMASS = 1774023;
const double ZOOM_ISP = 2.85e4;

......
th_main[0] = CreateThruster (_V(0,15.6,-79.1), _V(0,0,1), ZOOM_MAXMAINTH*0.116, hpr, ZOOM_ISP*0.116);
th_main[1] = CreateThruster (_V(-5.9,6.2,-80.4), _V(0,0,1), ZOOM_MAXMAINTH*0.167, hpr, ZOOM_ISP*0.167);
th_main[2] = CreateThruster (_V(5.9,6.2,-80.4), _V(0,0,1), ZOOM_MAXMAINTH*0.167, hpr, ZOOM_ISP*0.167);

...etcetera, up to [7] in the array...

It works, but is it preferable to make a separate thruster type for each used, with its own custom MAXTHRUST & ISP?

Thank you again for your help...
 
Thanks for the suggestion, and I will take it seriously, but before I do; do you know if it has any issues with Windows XP SP2? I was never able to use MS VC++6 on XPSP2, which is one of the reasons why I never did anything with VC++.
I don't know of any issues with XPSP2, no. I've used it at home on my XP machine since last summer, which I believe was before SP3 came out.
 
VS 2005 and 2008 should work fine on XP SP2. Neither will install on XP without at least SP2, but SP3 is not required.

Since there can be changes between versions of VS (some things that work in 2003 don't work in 2005, etc) it's probably best to start with the most current version to avoid having to re-learn anything later when you need to upgrade VS to be compatible with future versions of Orbiter.

BTW, according to Martin, add-ons will need to be compiled with 2005 or newer to be compatible with the next version of Orbiter, so I'd forget about VS 2003. Both 2005 and 2008 come complete with an IDE (even the free versions) so Crimson Editor isn't needed.
 
Hielor & Tommy;
Thanks for the confirmation on the VS topic. Get the latest version is advice I will follow. VS2008 it is. I did not know there was a free version; for download trial period I suppose? I will try the MS website. Good ideas, thanks!

Urwumpe;
The animations WERE difficult for a beginner, but eventually not unbeatable. However, never got animstate working (there is an example of it on the ShuttleA source). That said, I did get the semi-automatic animation working. Had to make a header file to define the class, in order to make the constructor in the cpp. But I figured it out in the end.

There is a working dll for the Zoom ship now, with the added bonus of an aerodynamic model. I will upload it to OH when I have finished tweaking and writing the manual. I will just add that I am impressed with the SDK language. Not knocking SC3, but the flexibility SDK gives you over SC3's "idealized parameters" is vastly superior and well worth the transition effort.

SetAnimState next time, as I accumulate experience, okay?

Thanks again for the comments and encouragement, and particularly thanks to the author of Orbiter MartinS for the inclusion of the excellent example source files, though the "jump" between ShuttlePB and DeltaGlider or ShuttleA is HUGE! An intermediate ship with a couple of simple animations would help starters like me get to grips. Nevertheless, it wasn't an impossible task, in the end, so maybe it is okay as it is. Makes you think a little, which can't be bad...
 
Hielor & Tommy;
Thanks for the confirmation on the VS topic. Get the latest version is advice I will follow. VS2008 it is. I did not know there was a free version; for download trial period I suppose? I will try the MS website. Good ideas, thanks!
Basically a fully-featured trial version with a trial period of like two years. My VS2005 Express (the free version) is just now complaining to me about needing to be registered, and I've had it for at least two years now.
 
Got the complete free VS2008 Express version, form the MS site, a big 740+ MB file. It includes VC++, VB2008. This one compiles Orbiter compatible dlls, yes?

Thanks again.
 
Got the complete free VS2008 Express version, form the MS site, a big 740+ MB file. It includes VC++, VB2008. This one compiles Orbiter compatible dlls, yes?

Thanks again.
Only one needed is VC++, not VB(Visual Basic).
 
Got the complete free VS2008 Express version, form the MS site, a big 740+ MB file. It includes VC++, VB2008. This one compiles Orbiter compatible dlls, yes?

Thanks again.
Yes, I have successfully compiled dlls for Orbiter using VC++ 2008. Setup should be very similar to that for VC++ 2005.
 
Okay, I have got VC++ 2008 installed on my computer at home. I have a doubt:

The orbiter.rsp file does not seem to be required anymore. Having a bit of trouble with getting cl.exe to read it, even when I re-point the directories.

I have saved the text of a page form Wiki for later reference, which deals with set up of the compiler and should answer this question, but, from the quick scan I gave it, seems to deal mainly with VC++ 2005. Any known problems or discrepancies, or can I go ahead and trust it?

And another couple. I have looked at some other members threads regarding problems with VC++ 2008. My questions, quite apart from the above one:

  • Do I REALLY need to get Windows SDK just for a windows.h file? I already have a windows.h file, but; is it a different version required for VC++ 2008, or something?
  • My computer at home is NOT connected to the internet. I read one post where it states that a "VS2008 registration" raz note starts appearing after a while. Any ideas how will I be able to register the package if I am off-line user?
Thanks in advance,

Keith

---------- Post added at 12:15 PM ---------- Previous post was at 10:54 AM ----------

A quick edit....

  • My computer at home is NOT connected to the internet. I read one post where it states that a "VS2008 registration" raz note starts appearing after a while. Any ideas how will I be able to register the package if I am off-line user?

This question is really a bit superfluous. Always managed to cross that bridge when I got to it before, with things like free anti-virus packages. And, I recall as I was loading the VS 2008 package - as I got the complete DVD ISO image version - that I already seem to have the Windows SDK, which solves the other (preceding) question.

Any help, please, with the Orbiter.rsp / cl.exe files issue, however, will be greatly appreciated.

Thank you kindly,

Keith

---------- Post added at 05:21 PM ---------- Previous post was at 12:15 PM ----------

Srub it all, now. Thanks to the Wiki article , it all works PERFECTLY; away like a brigantine on fore tops´l and spanker in a fresh breeze! :speakcool:

Apologies for a needless alarm call...

All the best.
 
Sorry. In my euphoria I forgot to contribute....

So, to give this thread its natural conclusion, I will add a few of my condensed experiences with VC++ 2008 setup which might help anyone who finds themselves at the same point.

Read the Wikiorbiter Free Compiler set up (important):

http://www.orbiterwiki.org/wiki/Free_Compiler_Setup

Plus these observations. I got the ISO DVD image version of of the whole VS 2008 Express package at:

http://www.microsoft.com/express/download/#webInstall

I made a DVD from it and by default the MS Windows SDK is installed when you install VC++. Maybe this procedure eliminates a few of the problems I have seen others having in some very long threads. You find the "platform SDK" files in Program Files\Microsoft SDKs\Windows\V6.0A, not PlatformSDK as the Wiki article says...

In the setup part (Linker\Input -> Additional Dependencies), I also needed to add;

orbiter.lib and orbiter sdk.lib

..as well as the specified kernel32.lib, gdi32.lib and user32.lib, in order to get my source code compiled. Otherwise the compiler will not know what you are talking about when you use the Orbiter SDK language.

And in the setup part (Linker\Ignore Specific Library) you also need to add to the list;

msvcrt.lib

...as well as msvcirt.lib.

If you have an older version source code but no VC++ 2008 project (like me), use create project from source code in the file menu of the VC++ editor. It is the easiest way, and you do not need any rsp files.

Also noted the compiled dll was smaller, for the exact same source code, in comparison to VC++ 2003 (72 to 55 k's, in my case).

That's about it, from my perspective. Thanks again, everyone, for the suggestion to upgrade to VC++ 2008. And have fun, fellow newbies who are testing the temperature with this dll business.

Bye for now.

Keith
 
First, my apologies. There is no intention here of "bumping" (as I see it referred) this thread. I simply would like to expand on the experience gained in the continued hope that it might benefit new users to VS2008 like me, and take the opportunity to reiterate my thanks to those who helped me recently with a small problem encountered with VS2008 (described further along).

1. All of the descriptions are applicable to Windows XP SP2 and Orbiter 2006 P1. I cannot say if it is the same for Vista or XP SP3, or other Orbiter versions. I forgot to say that before, though it is inferred in previous text.

2. If you use VS2008, make sure you take the section of the Wiki article about debugging seriously. Particularly the following issue; the final compile must be in "release" mode, not "debug" (here's where I owe the thanks; Ref thread Invisible Mesh), or the addon will work wonderfully on computers with VS2008 installed on them, but you will have certain errors on any that does not! By default, it seems, it will compile debugs for you, first. You have to set it to release (Win32) yourself. Remember I came recently from Crimson Editor, so this snippet is for the benefit of those who make the same leap to VS2008.

I am still wondering if this could have been the same issue with the add on mentioned in the original post of the Invisible Mesh thread? By the way, apologies to garyw for using his post to solve this problem; it was a similar problem, however.

3. When you do the final "Release" compile, the msvcrt.lib MIGHT be required. I have had varying results with this, strangely enough, so be prepared to play around here (by the looks of it). If a series of compile errors come up, when you compile your release version, to the effect that it does not recognize a list of OAPI keywords, the probability is that it DOES need msvcrt.lib. Chop it out of the Ignore Specific Library in the compiler properties, in Linker\Input, but leave msvcirt.lib as ignored.

4. In my case, a warning appeared during the final release compile regarding the command line (cl.exe) build procedure, stating that it would prefer /Zi incremental build. It does not affect the final product, really, but as I do not like to see warnings it can be eliminated by setting YES(INCREMENTAL/ZI) in Linker\General of Enable Incremental Linking, without any apparent ill effects.

I think this does now conclude the running account of my first dll, as it is now working reasonably well on all the computers I have tested it on (and had it tested on) so far. I was averse to leaving in information which might cause problems further on.
 
Last edited by a moderator:
3. When you do the final "Release" compile, the msvcrt.lib MIGHT be required. I have had varying results with this, strangely enough, so be prepared to play around here (by the looks of it). If a series of compile errors come up, when you compile your release version, to the effect that it does not recognize a list of OAPI keywords, the probability is that it DOES need msvcrt.lib. Chop it out of the Ignore Specific Library in the compiler properties, in Linker\Input, but leave msvcirt.lib as ignored.
See here for a description of which runtime library is required for which build configuration: http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx. I normally static link my addons with /MT (to see why, read here: http://www.orbiter-forum.com/showthread.php?t=6969), if are needing MSVCRT.lib then you are compiling with /MD. An additional note: I use VC++2005, but from discussions with those using VC++2008 it seems that the VC++2008 compiler will link against the debug versions of the runtime library even if you have /MT or /MD selected in the property pages.

On MSVCIRT.lib, one (or more) of the Orbiter SDK libraries tries to link against this but it has been deprecated in favour of MSVCPRT.lib (see here: http://msdn.microsoft.com/en-us/library/aa272081(VS.60).aspx). If you ignore it, the linker will link the functions in the SDK file to MSVCPRT.lib. :speakcool:
 
Back
Top