[Orxonox-commit 4290] r8961 - in code/branches/environment3/data/levels: . includes

fmauro at orxonox.net fmauro at orxonox.net
Wed Dec 7 15:02:02 CET 2011


Author: fmauro
Date: 2011-12-07 15:02:02 +0100 (Wed, 07 Dec 2011)
New Revision: 8961

Modified:
   code/branches/environment3/data/levels/asteroidField.oxw
   code/branches/environment3/data/levels/includes/asteroidField.lua
Log:
added generateFog function

Modified: code/branches/environment3/data/levels/asteroidField.oxw
===================================================================
--- code/branches/environment3/data/levels/asteroidField.oxw	2011-12-07 13:51:57 UTC (rev 8960)
+++ code/branches/environment3/data/levels/asteroidField.oxw	2011-12-07 14:02:02 UTC (rev 8961)
@@ -33,11 +33,11 @@
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
     <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff2 />
 
-    <!-- Generate asteroid field with diameter 12000 containing 250 asteroids -->    
+    <!-- Generate asteroid field and asteroid belt -->    
     <?lua
     	dofile("includes/asteroidField.lua")
-    	asteroidField(0, 0, 5000, 100, 150, 2000, 50);
-    	asteroidBelt(0, 0, 0, -48, -34, 30, 100, 200, 17000, 21000, 900)
+    	asteroidField(0, 0, 5000, 100, 150, 2000, 50, 1);
+    	asteroidBelt(0, 0, 0, -48, -34, 30, 100, 200, 17000, 21000, 900, 1)
     ?>
     
   </Scene>

Modified: code/branches/environment3/data/levels/includes/asteroidField.lua
===================================================================
--- code/branches/environment3/data/levels/includes/asteroidField.lua	2011-12-07 13:51:57 UTC (rev 8960)
+++ code/branches/environment3/data/levels/includes/asteroidField.lua	2011-12-07 14:02:02 UTC (rev 8961)
@@ -1,3 +1,24 @@
+--[[ fog generator
+generates fog
+	posX, posY, posZ - position in space
+	size - size of billboard
+	brightness - [0,1] fog brightness
+--]]
+function generateFog(posX, posY, posZ, size, brightness)
+		print("<Billboard ")
+			print("position = \"") 
+				print(posX) print(",") 
+				print(posY) print(",") 
+				print(posZ) print("\" ") 
+			print("colour=\"")
+				print(brightness) print(",") 
+				print(brightness) print(",") 
+				print(brightness) print("\" ") 
+			print("material=\"Smoke/Smoke\" scale=")
+			print(size)
+			print(" />")
+end
+
 --[[ asteroid field generator
 generates asteroid field
 	posX, posY, posZ - position in space
@@ -4,8 +25,9 @@
 	minSize, maxSize - size boundaries of each asteroid
 	radius - size of the cube around position in space
 	count - number of asteroids
+	fog - enable fog 0/1
 --]]
-function asteroidField(posX, posY, posZ, minSize, maxSize, radius, count)
+function asteroidField(posX, posY, posZ, minSize, maxSize, radius, count, fog)
 	for i = 1, count, 1
 	do
 		size = (math.random() * (maxSize - minSize)) + minSize
@@ -35,6 +57,10 @@
 		print("</collisionShapes>")
 		
 		print("</StaticEntity>")
+		
+		if fog == 1 and i % 5 == 0 then
+			generateFog(pX, pY, pZ, size*0.7, 0.2)
+		end
 	end
 end
 
@@ -46,8 +72,9 @@
 	minSize, maxSize - size boundaries of each asteroid
 	radius0, radius1 - inner/outer radius
 	count - number of asteroids
+	fog - enable fog 0/1
 --]]
-function asteroidBelt(centerX, centerY, centerZ, yaw, pitch, segments, minSize, maxSize, radius0, radius1, count)
+function asteroidBelt(centerX, centerY, centerZ, yaw, pitch, segments, minSize, maxSize, radius0, radius1, count, fog)
 	dPhi = (2 * math.pi) / segments
 	width = math.abs(radius1 - radius0)
 	radius = (radius1 + radius0) / 2
@@ -68,7 +95,7 @@
 	do
 		asteroidField((radius * math.cos(i * dPhi)),
 					(radius * math.sin(i * dPhi)),
-					0, minSize, maxSize, width,segmentCount)
+					0, minSize, maxSize, width, segmentCount, fog)
 	end
 	
 	print("</attached>")




More information about the Orxonox-commit mailing list