Cameras and texture plugins

JB3DG
Posts: 454
Joined: Mon Jan 09, 2012 6:44 pm

Cameras and texture plugins

Postby JB3DG » Mon Feb 08, 2016 11:11 am

Can someone shed some light on connecting a camera with a texture plugin for processing to put into a gauge? It seems rather undocumented. For what it is worth, I cannot seem get a texture plugin to be rendered into a texture slot in a XML gauge either.
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun

Clifton Crane
Lockheed Martin
Posts: 998
Joined: Tue Sep 25, 2012 2:34 pm

Re: Cameras and texture plugins

Postby Clifton Crane » Mon Feb 08, 2016 8:20 pm

Hello,

For XML based gauges, you would want to use the Texture object which is described in the "Creating XML Gauges" section of the Learning Center.

Here is a small example:

XML Gauge:

Code: Select all

<Gauge Name="MyRTTGauge" Version="1.0">
    <Image Name="background.bmp" />
    <Element>
        <Position X="0" Y="0" />
        <Texture Name="MyRTTCamera" Width="256" Height="256" />
    </Element>
</Gauge>


Camera Definition:

Code: Select all

[CameraDefinition.001]
Title = "MyRTTCamera"
Guid = {DA3F1490-F2C4-4D80-8D31-D8FE1A5C9DA8}
Origin = Center
ShowPanel = No
SnapPbhAdjust = Swivel
SnapPbhReturn = FALSE
PanPbhAdjust = Swivel
PanPbhReturn = FALSE
Track = None
ShowAxis = FALSE
AllowZoom = TRUE
InitialZoom = 0.30
ShowWeather = Yes
InitialXyz = 0.0, 0.0, 0.0
InitialPbh = 0, 0, 0
XyzAdjust = TRUE
Category=Aircraft
RenderToTexture=TRUE
MomentumEffect=TRUE
ClipMode=Minimum
CycleHidden=Yes
ShowLabels = 0
UseGlobalTerrainView=1
TextureSizeX=512
TextureSizeY=512
HideUserAircraft=0


Notice the Name property in the Texture object should match your camera definition's Title. Also, the following camera definitions should be set for RTT based camera definitions:

RenderToTexture=TRUE

The following camera definition entries are optional for RTT but can be used to further configure it:

UseGlobalTerrainView=1
TextureSizeX=512
TextureSizeY=512

Hope this helps!
Clifton Crane
Prepar3D® Software Engineer Sr.

JB3DG
Posts: 454
Joined: Mon Jan 09, 2012 6:44 pm

Re: Cameras and texture plugins

Postby JB3DG » Tue Feb 09, 2016 6:05 am

Not quite. I should clarify....I would like to get the camera to render into a ITextureRenderPlugin texture, and then reprocess it (like what happens with the radar) and put the reprocessed output into the XML texture.
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun

User avatar
Beau Hollis
Lockheed Martin
Posts: 1890
Joined: Wed Oct 06, 2010 3:25 pm

Re: Cameras and texture plugins

Postby Beau Hollis » Tue Feb 09, 2016 3:53 pm

There are two ways you could handle this.
1) skip texture plugin and use an Effect Plugin instead. In this case the RTT view creates a named texture associated with the view already, so you don't have to create a texture plugin. You can configure your effect plugin to request the scene's render target as a shader resource view. You can then bind it and do a full screen render with whatever processing you need. If you process is basic enough, you could even get by using and xml/hlsl post process definition rather than writing an effect plugin.

2) If you're doing something more complex where your RTT view renders at a different resolution than your gauge texture, or you have multiple views in a picture-in-picture kind of layout, you can create a texture plugin and request the RTT view's textures by name. You can request the RTT textures from the Render callback of your texture plugin as follows:

Code: Select all

    static char sSensorCameraDepth[] = "RadarCameraDepth";
    static char sSensorCamera[] = "RadarCamera";
   
    void RTTPlugin::Render(IUnknown* data)
    {
        // Query for additional render data which contains Render Target additional info
        CComPtr<IRenderData> renderData = NULL;
        res = data->QueryInterface<IRenderData>(&renderData);
        if(FAILED(res) || renderData == NULL)
        {
            return;
        }

        CComPtr<ID3D11ShaderResourceView> inputColor = NULL;
        CComPtr<ID3D11ShaderResourceView> inputDepth = NULL;
        renderData->QueryResource(sSensorCamera, __uuidof(ID3D11ShaderResourceView), (PVOID*)&inputColor);
        renderData->QueryResource(sSensorCameraDepth, __uuidof(ID3D11ShaderResourceView), (PVOID*)&inputDepth);
       // do something with the shader resource
  }
 
  // this needs to be implimented so the system can pre-fetch textures before the callback accesses them via QueryResource
      void RTTPlugin::RequestTextures(const char** sName, unsigned int& uCount)
    {
        sName[0] = sSensorCameraDepth;
        sName[1] = sSensorCamera;
        uCount = 2;
    }
       


I believe the Oculus sample has an example of this as well.
Beau Hollis
Prepar3D Software Architect

JB3DG
Posts: 454
Joined: Mon Jan 09, 2012 6:44 pm

Re: Cameras and texture plugins

Postby JB3DG » Tue Feb 09, 2016 4:20 pm

Thanks a bunch.
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun

JB3DG
Posts: 454
Joined: Mon Jan 09, 2012 6:44 pm

Re: Cameras and texture plugins

Postby JB3DG » Thu Feb 11, 2016 4:54 pm

Just one other question, what are the units for IWindowPlugin::SetFov parameters? Degrees or radians?
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun

Kevin Cartrette
Lockheed Martin
Posts: 542
Joined: Tue Aug 14, 2012 6:47 pm

Re: Cameras and texture plugins

Postby Kevin Cartrette » Thu Feb 11, 2016 6:18 pm

Hello Naruto,

The SetFov function should be in degrees.

Thanks,
-Kevin.
Prepar3D Graphics Software Engineer

JB3DG
Posts: 454
Joined: Mon Jan 09, 2012 6:44 pm

Re: Cameras and texture plugins

Postby JB3DG » Fri Feb 12, 2016 7:46 am

Thanks for the help.
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun

JB3DG
Posts: 454
Joined: Mon Jan 09, 2012 6:44 pm

Re: Cameras and texture plugins

Postby JB3DG » Tue Feb 16, 2016 6:48 am

Final question I hope....What is the depth buffer value range? Example say now I want to get the slant range from a GDATA camera in order to draw a radar display. What units does it use?
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun

User avatar
Beau Hollis
Lockheed Martin
Posts: 1890
Joined: Wed Oct 06, 2010 3:25 pm

Re: Cameras and texture plugins

Postby Beau Hollis » Wed Feb 17, 2016 5:52 pm

We use a standard projection matrix. The depth is 0f-1f. That has to be cross referenced with the near/far value (in meters). Alternatively, we provide access to the projection matrix via the pdk. You also use the PDK to get the view and projection matrix, construct and inverseViewProjection matrix and use it to reconstruct wold space coordinates in meters relative to the camera.

Code: Select all

    /**
    * Get View Matrix for this Camera/Window
    * @param[out] output4x4  4x4 vidw matrix
    */
    virtual void GetViewMatrix(float output4x4[4][4]) const abstract;

    /**
    * Get the standard projection matrix which is used by the Camera/Window 
    * for rendering everything but the virtual cockpit
    * @param[out] output4x4  4x4 vidw matrix
    */
    virtual void GetStandardProjectionMatrix(float output4x4[4][4]) const abstract;

    /**
    * Get the standard projection matrix which is used by the Camera/Window
    * for rendering the virtual cockpit.  The VC projection has a different
    * near and far clip to reduce z-fighting in the cockpit.
    * @param[out] output4x4  4x4 vidw matrix
    */
    virtual void GetVirtualCockpitProjectionMatrix(float output4x4[4][4]) const abstract;
 
Beau Hollis
Prepar3D Software Architect


Return to “Software Development Kit (SDK) Questions”

Who is online

Users browsing this forum: No registered users and 3 guests