• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

MSFS I stumble in nvgMoveTo and nvgLineTo in Nanovg

Messages
162
Country
italy
Have mercy on me, explain to me why in this code:
Code:
void Gunsight::OuterCircle(void) {
    nvgBeginPath(ctx);
    nvgEllipse(ctx, 0, 0, size.w, size.h);
    nvgStrokeColor(ctx, nvgRGBAf(255, 255, 255, alpha));
    nvgStrokeWidth(ctx, thickness);
    nvgStroke(ctx);
    nvgClosePath(ctx);
   
}
//////////////////////////////
void Gunsight::Pipper(void) {
    // pipper
    nvgBeginPath(ctx);
    nvgEllipse(ctx, -10, -10, 10, 10);
    nvgStrokeColor(ctx, nvgRGBAf(255, 255, 255, alpha));
    nvgStrokeWidth(ctx, thickness);
    nvgStroke(ctx);
    nvgClosePath(ctx);
}
///////////////////////////////
void Gunsight::Crosses(void) {
    nvgBeginPath(ctx);
    nvgMoveTo(ctx, center.x, center.y - size.h/2.0);
    nvgLineTo(ctx, center.x, center.y - size.h/4.0);
    nvgMoveTo(ctx, center.x - size.w/2.0, center.y);
    nvgLineTo(ctx, center.x - size.w/4.0, center.y);
    nvgStrokeColor(ctx, nvgRGBAf(255, 255, 255, alpha));
    nvgStrokeWidth(ctx, thickness);
    nvgStroke(ctx);
    nvgClosePath(ctx);
}

both OuterCircle() and Pipper() work nicely instead Crosses() refuses to draw 2 simple lines even if called in sequence:

Code:
nvgBeginFrame(myGunsight->ctx, p_draw_data->winWidth, p_draw_data->winHeight, pxRatio);
{
// go to center 
nvgTranslate(myGunsight->ctx, myGunsight->center.x, myGunsight->center.y);
// Outer circle   
myGunsight->OuterCircle();   
// pipper
myGunsight->Pipper();
// fails
myGunsight->Crosses();
}
nvgEndFrame(myGunsight->ctx);
 
Messages
87
Country
russia
In your Crosses method you use center.x and center.y like you working in absolute coordinates, but after calling nvgTranslate in first time yours zeros are already in the center of canvas.
Try this.
C++:
void Gunsight::Crosses(void) {
    nvgBeginPath(ctx);
    nvgMoveTo(ctx, 0, -size.h/4.0);
    nvgLineTo(ctx, 0, size.h/4.0);
    nvgMoveTo(ctx, -size.w/4.0, 0);
    nvgLineTo(ctx, size.w/4.0, 0);
    nvgStrokeColor(ctx, nvgRGBAf(255, 255, 255, alpha));
    nvgStrokeWidth(ctx, thickness);
    nvgStroke(ctx);
    nvgClosePath(ctx);
}
 
Last edited:
Messages
162
Country
italy
Thanks a lot, really appreciated.
btw: shame on me, i would realize it before watching how circle coordinates are set :-(
Yet another issue, look at the attached picture, how to make gunsight glass transparent ?
I'm not a modeller, could not make it transparent, any clues ?
tia
/Mario
 

Attachments

  • FlightSimulator 2021-01-11 09-41-44-53.jpg
    FlightSimulator 2021-01-11 09-41-44-53.jpg
    224.2 KB · Views: 222
Messages
87
Country
russia
I think it is possible to draw WASM gauge output on to glass surface texture. I'm less than beginner in 3D design and blender user. Just quick try with glass material settings inside Blender (Huge thanks to Blender2MSFS team) and that is my ugly results.
test_material_glass2.png
Unfortunately this is only flat texture, not HUD as it must behavior when you move point of view. Maybe MSFS Porthole or Parallax materials are more suitable. Oh, there are so much settings for all this materials.
 
Top