April 13, 200521 yr >Making a triangle move up/down on a line is easy. Rotating a>needle however .. I got no idea where to start.>>If only there was an option in VB.Net to rotate something by>some given degrees ... that would solve a lot.This is where trig comes in real handy. To make a line rotate to a specific position, you basically need to do the following.1. Set up the max and min data range (from MSFS) as a percentage (basically 0-1 in small decimal steps).2. Determine the max and min angle of your instrument needle. For instance, I believe the N2 needle is roughly 0-300 degrees. This is usually done by trial and error, and may need to be repeated.3. Multiply the percent times the angle range of the arc For example.... needleAngle = -1 * (dataPercentage * maxArcAngle) You have to multiply by -1 since the trig circle goes counterclockwise, and most instruments rotate clockwise.4. Determine the X and Y values for the line. line (x1,y1,x2,y2) Let's assume that the arc starts at 0,0 to get x2, and y2, use the following equations: X2 = R * cos(needleAngle) Y2 = R * sin(needleAngle) Where R is the length of the indicator line (typically the radius of the arc) These are derived from the fundamental trig identities: cos(theta) = Rx / R sin(theta) = Ry / R As you can see in the following photo, the yellow lines represent the values you are calculating with the above equations. http://www.t-b-x.com/prather/777project/ne...t/exampleN2.JPG That's basically it. It's easier than it sounds, and can be done in 4-5 lines of code (once the data is retrieved from FSUIPC)Hopefully this helps,Robert
April 13, 200521 yr The code I got now is doing it with a matrix.But I used to do it like you did .. only problem I had back then was that I couldn't get a background to keep showing. Now it does work.
April 13, 200521 yr Ok, I got Visual C++ 6.0 running and I am checking the tutorials. Now the biggest concern is getting this exe to link up with FS via fsuipc.Do I need the fsuipc SDK (C++) for that ? I guess so ..
April 13, 200521 yr I guess that was a rhetorical question...Of course you'll need the SDK :) The examples included alone are very usefull!
April 13, 200521 yr You can do it without OpenGL though. If you look at my FSEicas application in the library, that was written with no OpenGL so that it could run on an old 486 laptop that can't handle OpenGL. The needles in that are drawn with trig functions. Basically the same as Robert's example, except that because the gauges have a digitial readout in the center, I had to calculate both the inner and outer ends of the needle, so that it appears as a 'bug' that crawls round the outside of the dial circle.Richard
April 13, 200521 yr OWkeeej ...That's done. I got the C++/C fsuipc stuff integrated. And on startup of the program I get the "hello world" example popup stating which FS version, which fsuipc version and the current time in FS.What's the next step ?Reading speed value from FS and making the needle rotate acordingly. That's the next goal.I'll have to check if I can master this C++ language *slik*
April 13, 200521 yr :(C++ is not that difficult. If you have any previous programming/scripting experience, you can learn it rather fast :) (I do not consider VB as a programming language, nor a scripting language, it stands on it's own)Anyways, you can pretty much take a tutorial and adjust 1 var to take the data directly from FS instead of programming it's behavior - so to speak -If you get it to work, let us (me!) knowI'm currently also experimenting to get the space shuttle MEDS working :) Printed the 1400 page guide a few hours ago. Problem is that S3 doesn't have a FSUIPC, so currently, it's all scripted respons
April 13, 200521 yr :(This don work.Here's what I get:__________________C:MyFilesProggiesVisualC++OpenGLLesson01Lesson1.cpp(414) : error C2664: 'FSUIPC_Read' : cannot convert parameter 3 from 'float' to 'void *' There is no context in which this conversion is possibleError executing cl.exe.__________________I am trying hard to find a sample code that gives more examples than just reading the clock from FS. No luck so far :(
April 13, 200521 yr Well, exactly what it says...Could you give the code where the error occures?You apperantly try to do some calculation on a float (eg 1.234) that should result in a void...
April 13, 200521 yr I added an "&" in front of the variable and now it's OK.I am however now trying to figure out how I can create a subroutine, add the fsuipc stuff in there and make it possible to call it from a timer.:sI got the impression that this C++ is kinda like Java ?
April 13, 200521 yr You're still thinking in VB... forget the timer, and subroutineswhat you want is a void , not a subroutine.pretty easy:void FSdinges (var, var) {//code}why do you want a timer?
April 13, 200521 yr >The code I got now is doing it with a matrix.>But I used to do it like you did .. only problem I had back>then was that I couldn't get a background to keep showing. >Now it does work.If you are using a 1 dimensional line, for instance with the "line" API call, you *shouldn't* have any problems with the background. IF the background becomes obscured, it is possible that you need to manually invoke the "refresh" command on the object.Robert
April 13, 200521 yr I want a timer for reading data from FS and to update the position of the gauge needels.I am starting to think that it would be more easy cheating a bit and looking into the open source code of some freeware projects around ... :(Something bugs me .. I had the code such that I had a needle (rectangle) which was being rotated around the Z axis, thus going 360
Create an account or sign in to comment