• 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.

P3D v4 Dynamic Lights Inside VC

Messages
43
Country
us-texas
I'm writing a PDK dynamic light like the custom lights example, works fine outside the aircraft. When I try to AddLight to a point inside the cockpit the code controlling the light is correct in the debugger and seems to be fine; the light never appears within the confines of the VC. Is there something I'm missing?
 
So found that there is a limitation with a dynamic light within a certain distance. Within 1 meter the light object isn't visible. Outside of that distance, it is visible. This seems to be related to a clipping limitation.
 
Thanks for the update on your findings. I find very little is more annoying than an "I've fixed it" with no details.
 
Thank you for the reply, I'll keep working on this, but the aircraft it was supposed to be implemented with will have to have the traditional cockpit lighting for now. Hopefully, the mystery can be solved and I can share what I have found here and on the P3D Developers Forum.
 
I have never had issues with interior lighting for P3D at any distance. Can you share the effect for testing.
 
Last edited:
In P3D v4 I created a dynamic light from the example given in the PDK, my impression was there wasn't an effect needed. The light would appear anywhere I positioned it as long as the camera was not within 1 meter of its location. Here's the draw call:

void DrawLight(IObjectRendererV400* pRenderer, ObjectWorldTransform& objTrans, ObjectWorldTransform& cameraTrans)
{
// get body relative offset of camera and light box
ObjectLocalTransform objToCameraTrans;
pRenderer->CalculateBodyRelativeOffset(objTrans, cameraTrans, objToCameraTrans);

// calculate heading offset
int headingOffset = int(abs(objToCameraTrans.PBH.Heading)) % 360;
if (headingOffset > 180)
{
headingOffset -= 180;
}

// Add White color in based on heading offset
unsigned int color = WHITE_COLOR | (headingOffset << 16);

// draw a group to hold the light
pRenderer->BeginLightGroup(objTrans);

// add a light to the group
// X Y Z are positioning coordinates
pRenderer->AddLight(0.0, 0.656, 0.8, LIGHT_TYPE, color, LIGHT_WIDTH, 4000.0f, false);

// End the light group. Because it's attached to a sim object, sort this group
// to prevent drawing behind other transparent objects like clouds
pRenderer->EndLightGroup(true);
}

//bool m_bDrawGroundLightGrid;
bool m_bDrawCockpitLightGrid;
int m_uOneSecondTick;

// default light type and width
const float LIGHT_WIDTH = 1.0f;
const unsigned int LIGHT_TYPE = 1;
 
Back
Top