Ticket #3073: Trees_demo.xml

File Trees_demo.xml, 2.5 KB (added by wraitii, 9 years ago)

Tree sandbox to test instancing. Should run much faster than without the patch.

Line 
1<?xml version="1.0" encoding="UTF-8"?>
2
3<Scenario version="5">
4 <Terrain patches="25" texture="blackness" priority="0" height="16384"/>
5 <Script><![CDATA[//
6
7 var patches = 25;
8 var x0 = 20, z0 = 20, x1 = patches*16*4-20;
9 var x = x0, z = z0;
10 var maxh = 0;
11 var gap = 14;
12
13 var iii = 0;
14 while (iii < 5000)
15 {
16 //var ent = Engine.AddEntity("gaia/flora_tree_cretan_date_palm_patch"); // stupid amount of polys
17 //var ent = Engine.AddEntity("gaia/flora_tree_palm_tropical");
18 var ent = Engine.AddEntity("gaia/flora_tree_pine");
19 //var ent = Engine.AddEntity("gaia/flora_tree_oak");
20 //var ent = Engine.AddEntity("gaia/flora_tree_poplar_lombardy");
21
22 if (!ent) {
23 print("Failed to load "+template+"\n");
24 continue;
25 }
26
27 var cmpFootprint = Engine.QueryInterface(ent, IID_Footprint);
28 if (!cmpFootprint) {
29 print(template+" has no footprint\n");
30 continue;
31 }
32 var shape = cmpFootprint.GetShape();
33 var w, h;
34 if (shape.type == 'circle') {
35 w = h = shape.radius*2;
36 } else {
37 w = shape.width;
38 h = shape.depth;
39 }
40
41 if (x + w >= x1) {
42 // Start a new row
43 x = x0;
44 z += maxh + gap;
45 maxh = 0;
46 }
47
48 var cmpPosition = Engine.QueryInterface(ent, IID_Position);
49 cmpPosition.MoveTo(x + w/2, z);
50 cmpPosition.SetYRotation(Math.PI*3/4);
51
52 var cmpOwnership = Engine.QueryInterface(ent, IID_Ownership);
53 if (cmpOwnership)
54 cmpOwnership.SetOwner(1);
55
56 x += w + gap;
57 maxh = Math.max(maxh, h);
58 iii++;
59
60 }
61
62 //]]></Script>
63 <Environment>
64 <LightingModel>standard</LightingModel>
65 <SkySet>default</SkySet>
66 <SunColour r="0.811765" g="0.792157" b="0.701961"/>
67 <SunElevation angle="0.785398"/>
68 <SunRotation angle="5.49779"/>
69 <TerrainAmbientColour r="0.313726" g="0.376471" b="0.521569"/>
70 <UnitsAmbientColour r="0.501961" g="0.501961" b="0.501961"/>
71 <Water>
72 <WaterBody>
73 <Type>lake</Type>
74 <Colour r="0.3" g="0.35" b="0.7"/>
75 <Height>5</Height>
76 <Shininess>150</Shininess>
77 <Waviness>4.0</Waviness>
78 <Murkiness>0.45</Murkiness>
79 <Tint r="0.28" g="0.3" b="0.59"/>
80 <ReflectionTint r="0.28" g="0.3" b="0.59"/>
81 <ReflectionTintStrength>0</ReflectionTintStrength>
82 </WaterBody>
83 </Water>
84 </Environment>
85 <Camera>
86 <Position x="141.287" y="78.0967" z="32.4902"/>
87 <Rotation angle="0"/>
88 <Declination angle="0.523599"/>
89 </Camera>
90 <ScriptSettings><![CDATA[
91 {
92 "Name":"Trees Demo",
93 "Description":"Every unit in the game.",
94 "Keywords": ["demo"],
95 "PlayerData":
96 [
97 {
98 "Civ":"hele"
99 }
100 ],
101 "RevealMap":true,
102 "GameType":"endless"
103 }
104 ]]></ScriptSettings>
105 <Entities/>
106 <Paths/>
107 <Triggers/>
108</Scenario>