Sign in to follow this  
Guest bookmark

itrafficinfo examples needed

Recommended Posts

Hi all,I am trying to make a simple radar screen showing AI around the aircraft. Does anyone know of a tutorial or some reference material of any kind that could help me work with the Traffic Toolbox and itrafficinfo? Like a basic example of source code to start from.I am using VC++ 2005 for this btw, the rest of the gauges are in XML though. Haven't coded gauges in C for two years so a little rusty... ;) Cheers,Thomas

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

>Hi all,>>I am trying to make a simple radar screen showing AI around>the aircraft. Does anyone know of a tutorial or some reference>material of any kind that could help me work with the Traffic>Toolbox and itrafficinfo? Like a basic example of source code>to start from.>>I am using VC++ 2005 for this btw, the rest of the gauges are>in XML though. Haven't coded gauges in C for two years so a>little rusty... ;) >>Cheers,>Thomas>>There's a C++ tutorial in the FS2004 Panels.sdk , 'ItrafficInfo.doc' file.Just follow the steps in that example, it seems to work fine.Regards.Ernie.

Share this post


Link to post
Share on other sites

Thanks Ernie!Yes I knew about the sample code in the SDK, but making it work for me is another thing... I am obviously doing something wrong. That is why I was looking for more code examples.I use VC++ 2005 Express. Having successfully compiled other gauges with this setup, I now get the following compiling errors: V:gaugesinc..incITrafficInfo.h(9) : error C2061: syntax error : identifier 'ITrafficInfo' V:gaugesinc..incITrafficInfo.h(9) : error C2059: syntax error : ';' V:gaugesinc..incITrafficInfo.h(9) : error C2059: syntax error : ':'What could be the problem here? Thanks /Thomas

Share this post


Link to post
Share on other sites

Hi, I'm getting the same errors when I try to compile a gauge using trafficInfo functions and I was wondering if you ever found out how to correct it. Thanks,Eric

Share this post


Link to post
Share on other sites

Where are you #define'ing itrafficinfo.h file???This is the format I use for all gauges that require itrafficinfo.h file. This is in the main .cpp file for the project:#include "..incfs9gauges.h"#include #include #define ULONG_PTR DWORD#define UNICODE#include using namespace Gdiplus;#include "MyGauge.h"#include "..incgpsprop.h"#include "..incacparams.h"#include "..incitrafficinfo.h"

Share this post


Link to post
Share on other sites

Thanks Bill! I actually managed to solve the error myself since I started this topic some months ago. The header file was messed up, by me as usual. Mea culpa.My C/C++ programming skills are still very rusty, since I make everything in XML these days. So to avoid wasting everybody's time I was looking for some complete samples to get me started, e.g. printing data for the nearest 20 aircraft as strings. Unlike most people, I have some difficulties understanding the SDK...So thanks anyway, but now it's back to "C++ for morons" I guess.Cheers /ThomasProud father of the J 35J Draken for FS2004http://flightsim.bookmark.se

Share this post


Link to post
Share on other sites

I have a source example for a DLL in the pipeline where I program a radar screen for use with XML and C gauges, with ITrafficInfo and GDI+. Actually my "old" RadarGauge as DLL for XML usage.Anyone interested?

Share this post


Link to post
Share on other sites

Very interested Arne! Been working on the same thing as it turns out. Might save me a ton of coding.Thanks!Doug

Share this post


Link to post
Share on other sites

Me too! Me too! ;o) Something like that would really save the day. Thanks /Thomas

Share this post


Link to post
Share on other sites

I attached the source, the dll and a XML example. The real hindrance for uploading in the library is of course the dreaded monster named documentation.

Share this post


Link to post
Share on other sites

Amazing Arne! There will be a statue of you someday I am sure. This saves us mortals some weeks of trial-and-error coding.A zillion thanks /Thomas

Share this post


Link to post
Share on other sites

Just tried implementing this in my (still experimental) xml radar gauge. Works like a charm. One question to Arne: the blips have a dark (1,1,1?) edge, is there any way to change that color to fit another bg? I use a vector drawn circle as bg and not a bitmap btw. /Thomas

Share this post


Link to post
Share on other sites

Use a dark background, then you don't see it. Or no transparancy. It's a problem with the antialiasing and the use of RGB(0,0,0) for transparency by FS. Since the RGB(0,0,0) background is somewhat smeared out with the drawn pixels, you end with some pixels above RGB(0,0,0) and therefore darker as the normal pixels, but intransparent. So either use a dark background, or for transparent drawings remove the Antitaliasing command in the GDI-drawing.... //make all drawings antialiased// m_graphics->SetSmoothingMode(SmoothingModeAntiAlias);...I'm not sure if that helps.

Share this post


Link to post
Share on other sites

Yup, AA is IMHO badly implemented and a major nuisance in the FS graphics engine. I will carry on experimenting and report my results.Thanks /Thomas

Share this post


Link to post
Share on other sites

OK, a new switch AntiAlias="0"/"1" for the CustomDraw statement.

Share this post


Link to post
Share on other sites

Works perfectly, thanks! One question: I want to control TCAS color with the macro I use for the other CRT elements (see screenshot). Like this:%('0x5fffaa' '0x7ac688' '0x7ab678' 3 (L:SColor,enum) case)...StandardColour="@TCASColors" ... It does not work though. Why?

Share this post


Link to post
Share on other sites

The problem is twofold, first the ustomdraw doesn't seem to do any calculation in the attributes unlike other elements, and secondly all ...Colours in my Customdraw only accept integers (too lazy to treat them as string and then converting to integer).So what happens: a macro is nothing else then a textual replacement, it doesn't calculate anything, so with StandardColour="@TCASColors" you copy te Macro body to the CustomDraw attribute "StandardColour" which can't interpret it. Solution? Use "StandardColour" as element, like @TCASColorsCore(A:GPS GROUND TRUE HEADING, degrees)but then you can't use the original macro, because it uses syntax ("%(...)"), but you need syntax for elements of CostumDraw. So with redefined macros it should work:'0x5fffaa''0x7ac688' '0x7ab678' 3 (L:SColor,enum) case%(@TCASColorsCore)

Share this post


Link to post
Share on other sites

Works perfectly, thanks!The radar I am trying to build with your help has two modes btw, VERT/HOR. HORizontal mode is like the present solution, i.e. the CRT y axis shows distance to the echoes. In VERTical mode they are instead shown with vertical separation, i.e. the y axis shows relative altitude (above/below the horizon). Shouldn't be too difficult to implement I think.(?)The aircraft in question is the SAAB J35J Draken, which is a freeware release. 100% XML except for two gauges by Doug Dawson that he graciously permitted me to include in the distribution. I would be very happy if you permit me to also include your dll in the package (with proper credits of course). Thanks and best regards /Thomas

Share this post


Link to post
Share on other sites

My coding is a bit different to your purposes. I draw each aircraft "dot" (a ring with a short line) relatively to the aicraft due north and then rotate the screen by the heading (OK I rotate the coordinate system BEFORE I draw actually), and you need for a typical fighter radar something with with a forward looking radar, not all round. You can eather use a different coordinate axis, not in the center, or calculate the relative view angles and don't rotate the screen. For the vertical mode you'll need that anyway.

Share this post


Link to post
Share on other sites

Yes, I see what you mean. I analyzed your code and found the relevant parts, I think I have the hang of it now. I will make the changes I need and recompile it, see what happens. Very educating for me if nothing else. Will post the results here. Cheers /Thomas

Share this post


Link to post
Share on other sites

Hi,I had very severe program startup problems using the trafficradarxml.dllIn what folder do you have to put it, root or modules?Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this