P3D v4 visibility conditions for scenery objects

#41
You can already copy and paste. Why you think it's disabled?
I have not the faintest but I cannot copy the content of the modeldef.xml out of the modeldef.xml editor nor paste anything in it.
I can now add everything by hand and change things without running errors, so that is OK now.
 

rhumbaflappy

Moderator
Staff member
Resource contributor
#42
Try using this...

XML:
  <!-- time of day visibility -->

  <PartInfo>
    <Name>dawn</Name>
    <Visibility>
      <Parameter>
        <Code>
          (E:TIME OF DAY, enum) 0 == if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

  <PartInfo>
    <Name>day</Name>
    <Visibility>
      <Parameter>
        <Code>
          (E:TIME OF DAY, enum) 1 == if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

  <PartInfo>
    <Name>dusk</Name>
    <Visibility>
      <Parameter>
        <Code>
          (E:TIME OF DAY, enum) 2 == if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

  <PartInfo>
    <Name>night</Name>
    <Visibility>
      <Parameter>
        <Code>
          (E:TIME OF DAY, enum) 3 == if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

    <PartInfo>
    <Name>dawn_or_dusk</Name>
    <Visibility>
      <Parameter>
        <Code>
          (E:TIME OF DAY, enum) 0 == (E:TIME OF DAY, enum) 2 == or if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

  <!-- end time of day visibility -->
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#43
I have not the faintest but I cannot copy the content of the modeldef.xml out of the modeldef.xml editor nor paste anything in it.
I can now add everything by hand and change things without running errors, so that is OK now.
With Ctrl-V you can pasted. I have pasted in samples from this thread into the editor this week. Of course edit mode must be enabled.
 

rhumbaflappy

Moderator
Staff member
Resource contributor
#44
Let's try something else. An object that is to be displayed at dawn, dusk, and night. There are 2 ways to do this.

XML:
    <PartInfo>
    <Name>no_day</Name>
    <Visibility>
      <Parameter>
        <Code>
          (E:TIME OF DAY, enum) 0 == (E:TIME OF DAY, enum) 2 == (E:TIME OF DAY, enum) 3 == or or if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

    <PartInfo>
    <Name>no_day_better</Name>
    <Visibility>
      <Parameter>
        <Code>
          (E:TIME OF DAY, enum) 1 != if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
 

rhumbaflappy

Moderator
Staff member
Resource contributor
#45
Here's something really twisted. It shows an object from dusk to dawn, but only during the summer. It is based from the no_day above, to show the use of even more variable conditions.

XML:
    <PartInfo>
    <Name>no_day_summer_only</Name>
    <Visibility>
      <Parameter>
        <Code>
          (E:ZULU MONTH OF YEAR, number) 6.0 &gt;= (E:ZULU MONTH OF YEAR, number) 8.0 &lt;= (E:TIME OF DAY, enum) 0 == (E:TIME OF DAY, enum) 2 == (E:TIME OF DAY, enum) 3 == or or and if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
Note the or or and order. We loaded the 'stack' with conditions. Then we bring them off in the reverse order. We detect night or dusk or dawn, and it must be summer.
 

rhumbaflappy

Moderator
Staff member
Resource contributor
#46
More complicated yet:

XML:
    <PartInfo>
    <Name>not_2018_no_day_summer_only</Name>
    <Visibility>
      <Parameter>
        <Code>
          (E:LOCAL YEAR, number) 2018 != (E:LOCAL MONTH OF YEAR, number) 6.0 &gt;= (E:LOCAL MONTH OF YEAR, number) 8.0 &lt;= (E:TIME OF DAY, enum) 0 == (E:TIME OF DAY, enum) 2 == (E:TIME OF DAY, enum) 3 == or or and and if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
 

rhumbaflappy

Moderator
Staff member
Resource contributor
#47
Last one for now:

This uses the object variable O:Weather.AmbientTemperature. It will display when using the Winter Wonderland weather theme... apparently the temps in that theme are at or below zero Celsius. Rick could use it to display a wool hat on his driver.

XML:
    <PartInfo>
    <Name>below_zero</Name>
    <Visibility>
      <Parameter>
        <Code>
          (O:Weather.AmbientTemperature, number) 0 &lt;= if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#48
Just a side note, inspired by all this discussion, I have started on implementing support for seasonal textures in the GPW with P3Dv4 output and also for normal P3Dv4 mdl files in MCX.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#50
Ah, I never use the mouse to copy paste. Let me check what happens there.
 
#51
etc...
That one is still intriguing me in MCX. In fact when I use those separate dawn, dusk, day and night entries, I would have to have several parts to do it because the hierarchy editor only shows either dawn, dusk, day or night!
Also thank you for explaining that you must interpret the OR OR AND in reverse. That is also an eyeopener for me.
 

rhumbaflappy

Moderator
Staff member
Resource contributor
#52
O:Weather.AmbientPrecipRate works.

XML:
    <PartInfo>
    <Name>precipitation</Name>
    <Visibility>
      <Parameter>
        <Code>
          (O:Weather.AmbientPrecipRate, enum) 0 != if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
This displays an object if it is raining or snowing.

I can't get O:Weather.AmbientPrecipState to work. Maybe someone else can get it. You could have some snow on a doghouse roof as a model part when cold, and a lot more snow as a roof part if cold and precipitating, and no snow if not cold.

In P3D if I set the weather as cold and snow, then change the season to summer, it still shows cold and snow conditions. Cold objects and precip objects will still show. You could set conditions for date and temp and/or precip and maybe escape the problem of not being able to use O:Weather.AmbientPrecipState. If it rains below 0 temps, at least you would have ice over the existing snow.
 

rhumbaflappy

Moderator
Staff member
Resource contributor
#53
Wind of 15 knots+ :

XML:
    <PartInfo>
    <Name>wind_velocity_15kn+</Name>
    <Visibility>
      <Parameter>
        <Code>
          (O:Weather.AmbientWindVelocity, feet per second) 25.31496 &gt; if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
Wind from the westerly direction:

XML:
    <PartInfo>
    <Name>wind_westerly</Name>
    <Visibility>
      <Parameter>
        <Code>
          (O:Weather.AmbientWindDirection, degrees) 255 &gt;= (O:Weather.AmbientWindDirection, degrees) 285 &lt;= and if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
Combining these in combinations for a windsock might be a big undertaking. Lots of parts. Not sure if any of this can be used with animation, or if you'd use attachments, or use MCX merge function for parts.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#55
Dick, interesting to read that more variables work for scenery now. Last time I looked most weather things did not work.
 

rhumbaflappy

Moderator
Staff member
Resource contributor
#56
Hi Christian.

Ha! You're right. I must have tried a dozen things. So simple. Thanks for replying. :)

XML:
    <PartInfo>
    <Name>rain</Name>
    <Visibility>
      <Parameter>
        <Code>
          (O:Weather.AmbientPrecipState, mask) 4.0 == if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

    <PartInfo>
    <Name>snow</Name>
    <Visibility>
      <Parameter>
        <Code>
          (O:Weather.AmbientPrecipState, mask) 8.0 == if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
 
#57
Dick, since you are a moderator, I think it is worthwhile to make sure that this thread is made a sticky!
Now I have to always add some unhelpful comments to be able to find it back afterwards (I have read it dozens of times already and still need to once in a while check this thread to see where I went wrong again:().
I would think that Arno could agree also?
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#59
I got inspired to update MCX with some features so you don't have to fiddle with the modeldef.xml and the reverse Hungarian notation yourself anymore. Working on it :)
 

rhumbaflappy

Moderator
Staff member
Resource contributor
#60
Now that we know how to change the visibility of a model's part with RPN code, is there a way to change a texture with RPN code?
 
Top