Skip to content

Commit

Permalink
Internalize aoplane.xml to use as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Beherith authored May 9, 2024
1 parent 7c24e29 commit e82c709
Showing 1 changed file with 53 additions and 3 deletions.
56 changes: 53 additions & 3 deletions obj2s3o.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,58 @@ def bakeAOPlateS3O(filepath, xnormalpath, sizex = 5, sizez = 5, resolution= 128)
objfilehandle.close()

# --------------------- edit xnormal settings XML file------------------------
xml = open('aoplane.xml', 'r')
xmlln = xml.readlines()
try:
print("Looking for aoplane.xml in ", os.getcwd())
xml = open('aoplane.xml', 'r')
xmlln = xml.readlines()
except FileNotFoundError:
print ("Couldnt find aoplane.xml, falling back to internal one.")
xml= ''' <?xml version="1.0" encoding="UTF-8"?>
<Settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="3.17.0">
<HighPolyModel DefaultMeshScale="1.000000">
<Mesh Visible="true" Scale="1.000000" IgnorePerVertexColor="true" AverageNormals="UseExportedNormals" BaseTexIsTSNM="false" File="S:\models\!AO\corfus+plane2.obj"/>
</HighPolyModel>
<LowPolyModel DefaultMeshScale="1.000000">
<Mesh Visible="true" File="S:\models\!AO\corfus+plane2.obj" AverageNormals="UseExportedNormals" MaxRayDistanceFront="0.500000" MaxRayDistanceBack="0.500000" UseCage="false" NMTangentSpace="true" UsePerVertexColors="true" UseFresnel="false" FresnelRefractiveIndex="1.330000" ReflectHDRMult="1.000000" VectorDisplacementTS="false" VDMSwizzleX="X+" VDMSwizzleY="Y+" VDMSwizzleZ="Z+" BatchProtect="false" CastShadows="true" ReceiveShadows="true" BackfaceCull="true" NMSwizzleX="X+" NMSwizzleY="Y+" NMSwizzleZ="Z+" HighpolyNormalsOverrideTangentSpace="true" TransparencyMode="None" AlphaTestValue="127" Matte="false" Scale="1.000000" MatchUVs="false"/>
</LowPolyModel>
<GenerateMaps GenNormals="false" Width="128" Height="128" EdgePadding="1" BucketSize="16" TangentSpace="true" ClosestIfFails="true" DiscardRayBackFacesHits="true" File="S:\models\!AO\corfusplaneuniform.bmp" SwizzleX="X+" SwizzleY="Y+" SwizzleZ="Z+" AA="4" BakeHighpolyBaseTex="false" BakeHighpolyBaseTextureDrawObjectIDIfNoTexture="false" GenHeights="false" HeightAutoNormalize="true" HeightMinVal="-2.000000" HeightMaxVal="2.000000" GenAO="true" AORaysPerSample="256" AODistribution="Uniform" AOConeAngle="162.000000" AOBias="0.079850" AOAllowPureOccluded="true" AOLimitRayDistance="false" AOAttenConstant="1.000000" AOAttenLinear="0.000000" AOAttenCuadratic="0.000000" AOJitter="true" AOIgnoreBackfaceHits="false" GenBent="false" BentRaysPerSample="128" BentConeAngle="162.000000" BentBias="0.080000" BentTangentSpace="false" BentLimitRayDistance="false" BentJitter="false" BentDistribution="Uniform" BentSwizzleX="X+" BentSwizzleY="Y+" BentSwizzleZ="Z+" GenPRT="false" PRTRaysPerSample="128" PRTConeAngle="179.500000" PRTBias="0.080000" PRTLimitRayDistance="false" PRTJitter="false" PRTNormalize="true" PRTThreshold="0.005000" GenProximity="false" ProximityRaysPerSample="128" ProximityConeAngle="80.000000" ProximityLimitRayDistance="true" GenConvexity="false" ConvexityScale="1.000000" GenThickness="false" GenCavity="false" CavityRaysPerSample="128" CavityJitter="false" CavitySearchRadius="0.500000" CavityContrast="1.250000" CavitySteps="4" GenWireRays="false" RenderRayFails="true" RenderWireframe="true" GenDirections="false" DirectionsTS="false" DirectionsSwizzleX="X+" DirectionsSwizzleY="Y+" DirectionsSwizzleZ="Z+" GenRadiosityNormals="false" RadiosityNormalsRaysPerSample="128" RadiosityNormalsDistribution="Uniform" RadiosityNormalsConeAngle="162.000000" RadiosityNormalsBias="0.080000" RadiosityNormalsLimitRayDistance="false" RadiosityNormalsAttenConstant="1.000000" RadiosityNormalsAttenLinear="0.000000" RadiosityNormalsAttenCuadratic="0.000000" RadiosityNormalsJitter="false" RadiosityNormalsContrast="1.000000" RadiosityNormalsEncodeAO="true" RadiosityNormalsCoordSys="AliB" RadiosityNormalsAllowPureOcclusion="false" BakeHighpolyVCols="false">
<NMBackgroundColor R="127" G="127" B="255"/>
<BakeHighpolyBaseTextureBackgroundColor R="0" G="0" B="0"/>
<HMBackgroundColor R="0" G="0" B="0"/>
<AOOccludedColor R="0" G="0" B="0"/>
<AOUnoccludedColor R="255" G="255" B="255"/>
<AOBackgroundColor R="0" G="0" B="0"/>
<BentBackgroundColor R="127" G="127" B="255"/>
<PRTBackgroundColor R="0" G="0" B="0"/>
<ProximityBackgroundColor R="255" G="255" B="255"/>
<ConvexityBackgroundColor R="255" G="255" B="255"/>
<CavityBackgroundColor R="255" G="255" B="255"/>
<RenderWireframeCol R="255" G="255" B="255"/>
<RenderCWCol R="0" G="0" B="255"/>
<RenderSeamCol R="0" G="255" B="0"/>
<RenderRayFailsCol R="255" G="0" B="0"/>
<RenderWireframeBackgroundColor R="0" G="0" B="0"/>
<VDMBackgroundColor R="0" G="0" B="0"/>
<RadNMBackgroundColor R="0" G="0" B="0"/>
<BakeHighpolyVColsBackgroundCol R="255" G="255" B="255"/>
</GenerateMaps>
<Detail Scale="0.500000" Method="4Samples"/>
<Viewer3D ShowGrid="true" ShowWireframe="false" ShowTangents="false" ShowNormals="false" ShowBlockers="false" MaxTessellationLevel="0" LightIntensity="1.000000" LightIndirectIntensity="0.000000" Exposure="0.180000" HDRThreshold="0.900000" UseGlow="true" GlowIntensity="1.000000" SSAOEnabled="false" SSAOBright="1.100000" SSAOContrast="1.000000" SSAOAtten="1.000000" SSAORadius="0.250000" SSAOBlurRadius="2.000000" ParallaxStrength="0.000000" ShowHighpolys="true" ShowAO="false" CageOpacity="0.700000" DiffuseGIIntensity="1.000000" CastShadows="false" ShadowBias="0.100000" ShadowArea="0.250000" AxisScl="0.040000" CameraOrbitDistance="0.500000" CameraOrbitAutoCenter="true" ShowStarfield="false">
<LightAmbientColor R="33" G="33" B="33"/>
<LightDiffuseColor R="229" G="229" B="229"/>
<LightSpecularColor R="255" G="255" B="255"/>
<LightSecondaryColor R="0" G="0" B="0"/>
<LightTertiaryColor R="0" G="0" B="0"/>
<BackgroundColor R="0" G="0" B="0"/>
<GridColor R="180" G="180" B="220"/>
<CageColor R="76" G="76" B="76"/>
<CameraRotation e11="0.830360" e12="0.030508" e13="0.556389" e21="0.082067" e22="0.980913" e23="-0.176262" e31="-0.551147" e32="0.192022" e33="0.812009"/>
<CameraPosition x="-116.732773" y="66.481682" z="159.097763"/>
<LightPosition x="0.000000" y="2.000000" z="5.000000"/>
</Viewer3D>
</Settings>'''
xmlln = xml.splitlines()

xmlfilename = 'xnormalsettings.xml'
xmlout = open(xmlfilename, 'w')
for l in xmlln:
Expand Down Expand Up @@ -1109,4 +1159,4 @@ def bend_foliage_normals(model, minu = 0, maxu = 0.5, minv = 0, maxv = 1, blendf
if args.bakevertexao:
bakeAOS3O(inputfile, args.xnormalpath, 'isbuilding' in args, 'isflying' in args, len(args.piecelist) > 0, args.minclamp, args.bias, args.gain, args.piecelist)
if args.setradiusheightoffset:
setradiusheightoffset(inputfile, args.output, args.setradiusheightoffset)
setradiusheightoffset(inputfile, args.output, args.setradiusheightoffset)

0 comments on commit e82c709

Please sign in to comment.