Saturday, December 13, 2014

How to create working mirrors for P3Dv2 aicrafts


Just a quick heads-up for aicraft developers (and a quick memo for me) - here is how the working mirrors in my T-45C for Prepar3d V2.0 are done.
This is not meant to be a "tutorial", but just a quick note to show one of the possibilities provided by the new features of Prepar3d V2.
Specifically, Prepar3d V2 has an extended camera system, that allows you to easily render-to-texture any view, including IR sensors etc.
To make a working mirror for you Virtual cockpit you simply create a camera view with specific settings, assign a texture name and then use the texture in your 3D model.
In the T-45 there is a camera set as follows:

[CameraDefinition.11]
Title="$Mirror"
Guid={c028e6d3-362d-4211-97c8-8d469c886842}
Description = Real time mirror
Origin = Virtual Cockpit
Category=Cockpit
MomentumEffect = No
SnapPbhAdjust = Swivel
SnapPbhReturn = FALSE
PanPbhAdjust = Swivel
PanPbhReturn = FALSE
Track = None
ShowAxis = FALSE
AllowZoom = TRUE
InitialZoom = 0.60
SmoothZoomTime = 2.0
ZoomPanScalar = 1.0
ShowWeather = Yes
XyzAdjust = TRUE
ShowLensFlare=TRUE
PitchPanRate=30
HeadingPanRate=70
PanAcceleratorTime=0
InitialXyz = 0, 0.5, 0
InitialPbh = 0, 0, 180
ClipMode=Minimum
HideShadows=1
HideReflection=1
HideModels=0
HideParticles=1
HideUserAircraft=1
HideAutogen=1
HideScreenSpace=0
HideMissionObjects=0
ShowLabels=FALSE
HideSky=0
HideTerrain=0
RenderToTexture=TRUE
RenderToScreen=FALSE
TextureSizeX=512
TextureSizeY=512


This should be enough to generate a $mirror texture you can use in the VC. You will need, of course, to orient/flip it properly. Also, I have made the base material "self illuminating" otherwise the mirror would receive shadows from the rest of the cockpit.
In green are the specific lines that do the trick. You can of course customize the camera angles and the rendering setting to your preferences (but remember that more detail means bigger fps hit).

All the parameters are described in detail in the SDK - the trick works in a similar fashion for IR sensors or with other post processing effects.

I will probably add this to all my other planes (starting from the -D version)... when I'll get the time. Problem then is that you end up having two models (one for FSX and one for P3Dv2)... which takes longer to maintain.

Hope this helps. Ah, needless to say this ONLY works in Prepar3D v2.

2 comments:

Siyou Fs said...

This work in Fsx ?

Anonymous said...

Do you even read the post? He said this works ONLY in P3D V2!