F.L.E Thread #3

Miscellaneous Forums/Blitz Showcase/F.L.E Thread #3

F.L.E free landscape editor. Thread 3. prev threads found below.
FLE THREAD 1
http://www.blitzbasic.co.nz/Community/posts.php?topic=37611
FLE THREAD 2
http://www.blitzbasic.co.nz/Community/posts.php?topic=37805

yes, jfk. I had to drop your funtion it was too slow to really use. I replaced it with a simplified function that just runs through all verts on layer1. records the highest, records the lowest.. records the distance between them divided by the number of layers, then runs though the verts again , checking the height versus the each layers threshhold, and fades accordingly based on the current brushspeed.

http://www.hoverhavok.mmocrafter.com/fle14.jpg?

the 4 pics show how using different brushspeeds will effect the autotexture.

Could you top this thread with the most recent download? Just to make things easy for people to find.

new version up.
http://www.hoverhavok.mmocrafter.com/fle_compiled.zip

Rifraf: when will you be releasing the source to that compiled version?

We should get a site dedicated to this project or something

I wont be posting the source anymore, you can always work with the my old source if you like. I have posted the compiled version in the Blitz tools area.

right now im putting a detailed help file together.

I still can't "paint." I'll try the latest version, though...happy days...

dont have a paint issue here.. looked over the code, dont see how you can have one.

new shot.. some progress.
this shot if from a terrain that originally 40k tris
and at export was reduced to only 21k. I am still trying to fine tune the export optimize, but it works well as is.

http://www.hoverhavok.mmocrafter.com/fle16.jpg?

Looking good, RifRaf. The texture in that shot is less than good looking, might wanna take the one in the archive I posted a while back and use it. It works nicely.

theres another shot of the same terrain outside the editor. I dont have any "quality textures" to test with, and im not much of an artist. so ill have to use the ones i have for now :)

You can take those I provided with my archive. Doesn't make a difference to me, but they work nicely.

NIce scene, Rifraf, but you shouldn't turn mipmapping off for the trees IMHO. Instead paint the transparent color of the masked textures green while setting the alphabytes of those textels to zero, this will look better and is also faster.

Depeding on the usage of the scene I'd also suggest to use a higher scaling of the textures if you are planing to use it without a dense fog that will hide everything that is bejond 50 Meters away.

thanks. jfk. Those are blitztrees however. I havent made any of my own. Made a help file.. its in this code box, and will from now on me included in the zip.

F.L.E v1.0
The Free Lanscape Editor .  by Rifraf ( Gamemaker04@... )

HELP

Section 1. moving around and choosing brushes
Section 2. Choosing and using textures
Section 3. Functions

[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
S E C T I O N #1    moving around and choosing brushes
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

  when you start FLE you will see 2 GUIs or Graphical menus.
  the movement GUI is the one near the bottom right corner 

)  It has many arrows on it, and also has many checkboxes.
)  You can left click on these arrows to navigate.  
)  One set will  turn you left and right, and tilt you up and down.  
)  The other set  will move you up, down, left and right.  
)  The two arrows near the upper  middle of this GUI will Move 
	 you forward and backward
) The small dot near the forward and back arrows will reset your turn and tilt
  On this GUI you will also see alot of brush selections. Ill explain each one here.
) you may also use arrow keys, and insert, delete, home, end, page up, and page down for 
 movement controls.
_______________
[[[[[[[[BRUSHES]]]]]]]
===============

(((PAINT))). when you select paint.  and hold the right mouse button on a terrain area. 
then that area will fade into the active texture.
(((RAISE))). when you select raise, and hold the right mouse button on a terrain area
then that area will lift, and terraform to a higher position.. 
(((LOWER))) similar to the raise brush, but instead of moving the terrain upward, it will 
fall downward.
(((PULL))) This brush will pull the selected area of terrain in the direction of its own normal.
 (normals are the direction a peice of terrain is facing)
(((PUSH)) Similar to raise brush, but PUSH will move the selected area of terrain away from 
its own normal direction (normals are the direction a peice of terrain is facing)
(((COLOR))) this brush when selected will prompt you to select a color, then when you use 
brush you will alter the color the selected area of terrain.
(((SMOOTH)) this brush will smooth out sharp edges in the selected area of terrain.

[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
S E C T I O N #2    choosing and using textures
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

FLE will start with the startup textures in place.  they are.
             Tex1.png, Tex2.png, Tex3.png, Tex4.png, Tex5.png, and Tex6.png

1).To select your active texture use the left and right arrown on the TEXTURE slider
2).To replace active texture with another texture on your hard drive you simply click 
	on the thumbnail image of the active texture.
3).You may change a texture at any time, and the current terrain will instatly reflect the changed
texture.  You may also change the active textures scale using the TEXTURE SCALE slider arrows.
4). You may use the BRUSH SPEED slider arrows to select how fast a painting operation will fade
the active texure onto the terrain.
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
S E C T I O N #3   FUNCTIONS
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

Functions are used by clicking the function button on the left gui window.
the function buttons in this version are.

Ridge, Smooth, Autotexture, Randomize, New Map, Light Map, Load FLE, Save FLE, 
and Export.

Lets go over them
1). RIDGE .  this will paint the active texture onto steep slopes.
2).SMOOTH .  This will smooth out rough edges and points on the entire terrain
3).AUTOTEXTURE.  This will assign heigt values to each of the 6 textures, 1 being the 
lowest and 6 the highest. Then it will paint all areas of the terrain based on height.
Your current BRUSH SPEED setting will effect how opaque this effect is. You should 
set it all the way up(to the right) for the most obvious effect.
4).RANDOMIZE  This will paint random textures across the entire terrain.
5).NEW MAP,  With this you can start a fresh map, and select a new terrain size
6).LIGHT MAP.  This will highlight and shadow areas of the map, and it will assume
the light source is located at your current location.
7).SAVE FLE.  this will save your work in a format that FLE can reload later, so 
that you can continue working on the terrain where you left off at a later time.
8).LOAD FLE.  this will load a previously saved terrain
9).EXPORT.   This will save the terrain as an optimized .B3D mesh.  Usually tris and verts are
cut in half.. or greater. When you export FLE will also save a lightmap and a colormap. 
you dont need to use these in Blitzbasic when you load a B3D file, however if you choose to not
use vertexlighting then these two files will be useful. then are .bmp files.


Thats pretty much it for now.  things i plan to add are
1).Object placement(any 3d model)
2).Dynamic debris creation and placement ( rocks ect)
3).Direct X mesh exporter *.X

Thank you for trying F.L.E.   I hope you find it useful.

alot of thanks goes out to the blitz community, alot of small functions from the code archives were adapted to be used in this program. 

     -Jeff (Rifraf) gamemaker04@...


how did you make that water?

I really need to....

its just a plane, textured

I already answered you somwhere else, TextureWobbler is a Tool that lets you create animated textures for water fx. check out the toolbox.

Well, basicly for water you only need a plane or something like that and set the alpha to 0.5 or something. THere are a lot of methods to get waterish stuff, some of them are using way too much polygons IMHO.

I have released TextureWobbler as a freewaretool although it is the quinte essence of my artistic work and a lot of people asked me "how did you do the water FX". It's there.

@jfk, did someone ask about texturewobble? what am i missing here :)

new version up.. alot of small bug fixes. same link as above

When I hold Ctrl in the compiled version to move the camera view, it moves wildly to the upper left. I guess you picked the wrong X,Y coordinates for mouse movement and you're just not using MouseXSpeed and MouseYSpeed.

no, when i made it it was using mousespeed. I forgot i had control down as an alternative mouse look, i had planned to remove it all together.. ill take care of it in the next release

Rifraf - I guess it was No Enemies who asked how to make water FX somewhere, thus I mentioned (again) texturewobbler, the tool.

PICTAR

Now guess what I made that in ;)
It wasn't FLE and it wasn't ALE.

Actually, it's my own terrain editor. It uses the same concepts as FLE and works very nicely. I'll release the source code under the MPL soon enough.

I know how to make water, how do I make that water? How can you make it transparent? Can you do something like:

EntityAlpha waterplane, 90


Is EntityAlpha a command?

@NoEnemies:
EntityAlpha is a command that uses 0.0 to 1.0
0.0 being totally see thru (not even seeing it cuz its so see thru), and 1.0 ( not being able to see thru at all cuz u can fully see it)
it would be:

EntityAlpha waterplane, 0.9


btw, to rifraf (and everyone else who helped on FLE), great Job, FLE is a great editor and i like it a lot... ;D

thanks! I knew it!

I guess EntityAlpha is even described in the Command reference. Just click Help and follow the clues. Some would say RTFM. ;) Maybe also try to load the watertexture with the Alpha Flag instead (tex=loadtexture("water.bmp",2)), this will make the darker pixels more transparent and the brighter ones more opaque.

UPDATED SHOT..
making some progress, havent found alot of time to work with it. but i improved the lightmapping quite a bit, changed default texture size so they are a little larger on program start. and now the Brush speed effects almost every function.. even lightmapping.

http://www.hoverhavok.mmocrafter.com/fle18.jpg?

I havent uploaded new version yet, i will do that soon

Is the most recently updated version in the Toolbox?

no not yet, ill post when ive uploaded it. im at work at the moment

That is lovely.

ok newest version is up .. same link. you can get it from toolbox. or http://www.hoverhavok.mmocrafter.com/fle_compiled.zip

whats new?
1).Better lightmappig (IMO)
2).Better optimized mesh export. I tested a 120k tri terrain, and it exported down to 42k.
3).The BrushSpeed setting effects almost everything now.
so you have more control over how fast you push, pull, raise , lower terrain, how sharp your lightmapping is.. ect.

.

latest screenie looks very nice

Rif the new BrushSpeed effects makes a big difference, thanks!

Thanks...turns out my subconsious mind made me push the left button! I have no control over myself now. I've gone completely insane. I can't tell left from right! AHHHHHHHH!!!!

FLE + CLE = ALE Dead

xmlspy: The latest version of CLE (which is residing on my hard drive until I finish the GUI version) should prove a very formidable opponent for ALE. As for FLE, I see no reason to use ALE when FLE has pretty much everything ALE has as far as I can see.

Just my take on the situation. While ALE was good when released, as far as I can see there no longer remains a reason to use it over FLE aside from the better looking GUI, and where that's concerned, CLE will blow FLE's away. (I'm sure RifRaf agrees with me that the FLE GUI isn't the best looking- it serves its purpose exactly as it should, but it could use some new looks) ;)

i like my gui.. needs a redraw of main images, but i like its deisgn and flow.. but thats just me. FLE will get an update tommorrow, I have added another type of autotexture.. there are now two.

the RIDGE button , has been replaced with new code.. it now autotextures the terrain based on vertex normals, while the Auto texture, will texture the terrain based on vertex heights.

also fixed some bugs in the fle save, and fle load.. older versions of .FLE files will not load properly anymore from the older versions into the new one i upload.

Oh yeah, RifRaf, I might redraw the GUI. If you want the new version if and when I finish it I'll stick it on my ftp and you can download it.

FLE updates.. use the same link as above.

changes are
..Fixed a bug in load/save FLE.. older version FLE files wont load properly in this new version.
..Heightmap laoder is now also effected by Brushspeed setting, so you have direct control over amplitude of terrain maps.
..the old ridge function , has been removed I have replaced it with a autotexturing function that textures the terrain by vertex normals. .. the old autotexture still works the same. by terrain height.

thats it for now.. still a work in progress. .X export comming soon.




Remade the GUI images. As far as I'm concerned, they look better than the originals.

ooo, I like it. <edit> nevermind...had a brain fart.

wow, that is nice looking gui graphics, thanks! new version uploaded including new gui gfx.
ok heres a shot of the new gui gfx in action.. i like it alot.



WOW nice GUI. A great product just got greater.

One suggestion (great GUI, by the way): Make the little checkbox blue. I think you'd be able to see it better on the Brush Speed/Size...those scrolly things. And maye make it a circle. But other than that....it's wonderful...absolutely genius...

Its the same GUI code under the hood, Noel updated the skin with some really cool looking gfk.. if were up to my artistic ability. FLE skin would have looked plain forever.

I knew it was the same code...HA!

RifRaf: I was wondering if I could have a look at your lightmapping code. Right now I've got shadow casting and lighting overall (smooth, not the faceted kind) down, but the aliased edges are bugging me and running a couple rounds of box filtering over it is making it too blurry for normal application.

By the way, if you could e-mail a specs sheet of the FLE format to me that'd be good (trying to make FLE and CLE cross-compatible). I'd send you the CLM specs sheet too, of course. I can't translate the code for my importer to FLE, but it should be a simple matter of just changing a few lines to suit yours.

@noel .. didnt you say my code was too sloppy? :) lol. I dont do anythign special, just check line of sight to sun spot, then do light variance based on normals.

Workign on a tree editor to hopefully compliment fle. Nothing like The stuff over at aliencodec, if you got a few bucks i recommend thiers, but perhaps these will work as placeholder trees until you get the good editors. since i obviously cannot bundle any aliencodec tree makers with fle.. this is the best i can do.. its still in early stages, and this tree was made with very low res textures, and no lightmappig in the leaves.



@noel .. didnt you say my code was too sloppy? :)


That doesn't mean I can't decipher it ;)

And the tree editor has improved a lot since I tried it (considering that when I tried it was just a trunk ;)

Anyhow, talk to you about it later.

heres the save() function to save FLE format.

Function savework()
 ; File Requester

 ; (for a loader filerequester use:)
 ;     sAFilter$ = "Blitz3D (*.B3D)" + Chr(0) + "*.B3D" + 

Chr(0) + "3D Studio (*.3DS)" + Chr(0) + "*.3DS" + Chr(0) + "DirectX7 (*.X)" + Chr(0) + "*.X" + Chr(0) + "All Files (*.*)" + Chr(0) + "*.*" + Chr(0)
 ;     sFileName$ = DLLGetOpenFileName$("Please select a Mesh File...","",sAFilter$,OFN_HIDEREADONLY Or OFN_FILEMUSTEXIST)
 ; for more info about the blitzsys read the blitzsys docs from the original distribution
 ;
 sAFilter$ = "F.L.E project (*.FLE)" + Chr(0) + "*.FLE" + Chr(0) + "All Files (*.*)" + Chr(0) + "*.*" + Chr(0)
 sFileName3$ = DLLGetSaveFileName$("Save F.L.E progress (*.FLE) As...","",sAFilter$,OFN_HIDEREADONLY Or OFN_FILEMUSTEXIST ) ;Or OFN_OVERWRITEPROMPT)

 If sFileName3$<>""
  ; actually we save 2 files, when you enter "test", it will be "test_1.b3d" and "test_2.b3d"
  ; so the Win-Api-built-in overwriting-prompt isn't useful anyway.
  If Upper$(Right$(sFileName3$,4))=".FLE" Then sFileName3$=Left$(sFileName3$,Len(sFileName3$)-4)
  FN$=sFileName3$+".FLE"

 sfile=WriteFile (fn$)
 WriteInt sfile, numlayers
 WriteInt sfile, lsegments
  For i=1 To numlayers
   WriteString sfile,use_tex$(i)
   WriteFloat sfile,layertexscale(i)
   Next 

  For i=1 To numlayers
   s=GetSurface(layer(i),1)
   vc=CountVertices(s)-1
    For v=0 To vc
     WriteFloat sfile, VertexX(s,v)
     WriteFloat sfile, VertexY(s,v)
     WriteFloat sfile, VertexZ(s,v)

     
     WriteFloat sfile, VertexRed(s,v)
     WriteFloat sfile, VertexGreen(s,v)
     WriteFloat sfile, VertexBlue(s,v)

     WriteFloat sfile, VertexAlpha(s,v)
   Next
  Next
CloseFile sfile
Else
Return
  EndIf
End Function


heres the load function. if you want to modify this to load CLE terrains i will gladly throw it in as an option when loading work.

Function loadwork(sf$="")
 ; File Requester

 ; (for a loader filerequester use:)
 ;     sAFilter$ = "Blitz3D (*.B3D)" + Chr(0) + "*.B3D" +

 Chr(0) + "3D Studio (*.3DS)" + Chr(0) + "*.3DS" + Chr(0) + "DirectX7 (*.X)" + Chr(0) + "*.X" + Chr(0) + "All Files (*.*)" + Chr(0) + "*.*" + Chr(0)
 ;     sFileName$ = DLLGetOpenFileName$("Please select a Mesh File...","",sAFilter$,OFN_HIDEREADONLY Or OFN_FILEMUSTEXIST)
 ; for more info about the blitzsys read the blitzsys docs from the original distribution
 ;
If sf$="" Then 
 sAFilter$ = "Load F.L.E (*.FLE)" + Chr(0) + "*.FLE" + Chr

(0) + "All Files (*.*)" + Chr(0) + "*.*" + Chr(0)
 sFileName3$ = DLLGetopenFileName$("Load F.L.E project (*.FLE).","",sAFilter$,OFN_HIDEREADONLY Or OFN_FILEMUSTEXIST ) ;Or OFN_OVERWRITEPROMPT)
Else
sfilename3$=sf$
EndIf

 If sFileName3$<>""
  FN$=sFileName3$

For i=1 To numlayers
FreeTexture  layertexture(i)
FreeBrush layerbrush(i)
ClearSurface GetSurface(layer(i),1)
FreeEntity layer(i)
Next

If fn$<>"" Then 
  If FileType(fn$)=1 Then 
;sets get segment size
 checkf=ReadFile(fn$)
 numlayers=ReadInt(checkf)
 lsegments=ReadInt(checkf)
;RuntimeError numlayers+" "+lsegments
 For i=1 To numlayers
  use_tex$(i)=ReadString(checkf)
  loadscale#(i)=ReadFloat#(checkf)

;strip path
     ; so strip the path
	  For i2= Len(use_tex$(i)) To 1 Step -1
	   If Mid$(use_tex$(i),i2,1)="" Then
	    use_tex$(i)=Right$(use_tex$(i),Len(use_tex$(i))-i2)
	    Exit
	   EndIf
	  Next

  
  Next
 CloseFile checkf
 EndIf
 EndIf


hope its not too sloppy :)

It could be more flexible, but it's your format so I'm not complaining.

lol.. its called simplified. not limited. no need to make simple tasks complex imo

Yeah, but considering CLE will be undergoing a lot of changes, it's worth the time I spent to make the file format easily changed without corrupting files made in older versions.

I haven't tested this (frankly, I can't- easily, at any rate), but most errors should be easily fixed when encountered.

;; CLE Texture type, used to store textures loaded from CLMs.
Type CLETexture
	Field Path$
	Field Flags%
	Field Blend%
	Field SX#
	Field SY#
	Field Texture%
	Field Index%
End Type

;; Textures
Global CLE_Textures = 0

;; Chunk constants
Const CLM_HEADER = $1000			;;  Header- one string and a float
Const CLM_AUTHOR = $1001			;;  Author of the file being saved

Const CLM_TEXTURES = $3001		;;  Opening of the texture list
Const CLM_TEXTURE = $3002		;;  Opening of a texture
Const CLM_TEXTUREPATH = $3003		;;  Sets the path from which the texture will be loaded from
Const CLM_TEXTUREFLAGS = $3004	;;  Sets the flags the texture is loaded with
Const CLM_LOADTEXTURE = $3005		;;  Tells the importer to load the texture at this point because it has sufficient data to do so
Const CLM_TEXTUREBLEND = $3006	;;  Sets the blend mode of the texture
Const CLM_TEXTURESCALE = $3007	;;  Sets the scale of the texture

Const CLM_LAYERS = $2000			;;  Opening of the layers, one byte and one int
Const CLM_LAYER = $2001			;;  Opening of a CLE layer, one byte
Const CLM_LAYERFORMAT = $2002		;;  1- Alpha
Const CLM_LAYERDATA = $2003		;;  N Bytes; refer to CLM_MESHFORMAT
Const CLM_HEIGHTDATA = $2004		;;  The heightmap information- two floats to set delta and minimum y and all bytes to determine height afterwards
Const CLM_LAYERTEXTURES = $2005	;;  The textures applied to the layer
Const CLM_HEIGHTFORMAT = $2006	;;  The format in which the heightmap data is stored


Function LoadCLM(sf$="")
	 ; File Requester
	
	 ; (for a loader filerequester use:)
	 ;     sAFilter$ = "Blitz3D (*.B3D)" + Chr(0) + "*.B3D" +Chr(0) + "3D Studio (*.3DS)" + Chr(0) + "*.3DS" + Chr(0) + "DirectX7 (*.X)" + Chr(0) + "*.X" + Chr(0) + "All Files (*.*)" + Chr(0) + "*.*" + Chr(0)
	 ;     sFileName$ = DLLGetOpenFileName$("Please select a Mesh File...","",sAFilter$,OFN_HIDEREADONLY Or OFN_FILEMUSTEXIST)
	 ; for more info about the blitzsys read the blitzsys docs from the original distribution
	 ;
	If sf$="" Then
		 sAFilter$ = "Load CLM (*.CLM)" + Chr(0) + "*.CLM" + Chr(0) + "All Files (*.*)" + Chr(0) + "*.*" + Chr(0)
		 sFileName3$ = DLLGetopenFileName$("Load Cower Landscape Mesh (*.CLM).","",sAFilter$,OFN_HIDEREADONLY Or OFN_FILEMUSTEXIST ) ;Or OFN_OVERWRITEPROMPT)
	Else
		sfilename3$=sf$
	EndIf
	
	If sFileName3$<>""
		FN$=sFileName3$
		
		For i=1 To numlayers
			FreeTexture  layertexture(i)
			FreeBrush layerbrush(i)
			ClearSurface GetSurface(layer(i),1)
			FreeEntity layer(i)
		Next
		
		in = ReadFile(FN$)
		
		texts = CLE_Textures
		
		While Not Eof(in)
			Class = ReadInt(in)
			Size = ReadInt(in)
			
			Select Class
				Case CLM_TEXTURE
					c.CLETexture = New CLETexture
					c\sx# = 1
					c\sy# = 1
					c\blend = 5
					c\Index = CLE_Textures
					CLE_Textures = CLE_Textures + 1
				
				Case CLM_TEXTUREPATH
					Path$ = ReadString(in)
				
				Case CLM_TEXTUREFLAGS
					Flags = ReadShort(in)
				
				Case CLM_TEXTURELOAD
					c\Texture = LoadTexture(Path$,Flags)
					TextureBlend c\Texture,c\Blend
					ScaleTexture c\Texture,c\sx,c\sy
				
				Case CLM_TEXTURESCALE
					c\sx = ReadFloat(in)
					c\sy = ReadFloat(in)
					If c\Texture <> 0 Then
						ScaleTexture c\Texture,c\sx,c\sy
					EndIf
				
				Case CLM_TEXTUREBLEND
					c\blend = ReadByte(in)
					If c\Texture <> 0 Then
						TextureBlend c\Texture,c\blend
					EndIf
				
				Case CLM_LAYERS
					Layers = ReadByte(in)
					Segments = ReadInt(in)
					
					For i = 1 To Layers+1
						s = GetSurface(layer(i),1)
						ClearSurface s,1,1
						For x = 0 To Segments-1
							For y= 0 To Segments - 1
								vx# = Float(x)/Segments
								vz# = Float(y)/Segments
								
								vertex = CountVertices(s)
								
								AddVertex s,vx,0,vz,vx,vz
								VertexNormal s,0,1,0
							Next
						Next
						
						For x = 0 To Segments-2
							For y = 0 To Segments-2
								v0 = x + y * Segments
								v1 = x + 1 + y * Segments
								v2 = x + 1 + (y+1) * Segments
								v3 = x + (y+1) * Segments
								AddTriangle s,v0,v1,v2
								AddTriangle s,v2,v3,v0
							Next
						Next
					Next
				
				Case CLM_LAYER
					l = ReadByte(in)+1
					
				Case CLM_LAYERFORMAT
					Alpha = 0
					Format = ReadByte(in)
					If (Format And 1) = 1 Then Alpha = 1
				
				Case CLM_LAYERDATA
					s = GetSurface(layer(l),1)
					For i = 0 To CountVertices(s)-1
						r# = 255 : g# = 255 : b# = 255 : a# = 1.0
						If Alpha = 1 Then a# = Float(ReadByte(in))/255
						VertexColor s,i,r,g,b,a
					Next
				
				Case CLM_LAYERTEXTURES
					textures = ReadShort(in)
					b = CreateBrush()
					BrushFX b,2
					If i > 1 Then BrushFX b,2+32
					For i = 1 To textures
						index = ReadInt(in)
						For c.CLETexture = Each CLETexture
							If c\index = index Then BrushTexture b,c\Texture,0,i
						Next
					Next
					PaintEntity layer(l),b
					FreeBrush b
				
				Case CLM_HEIGHTFORMAT
					hmf = ReadByte(in)
					h = ((hmf And 1) = 1)
				
				Case CLM_HEIGHTDATA
					For i = 0 To Segments*Segments-1
						height# = 0.0
						If h Then height = ReadFloat(in)
						For n = 1 To Layers
							s = GetSurface(layer(i),1)
							VertexCoords s,i,VertexX(s,i),height,VertexZ(s,i)
						Next
					Next
						
				Default
					SeekFile FilePos(in)+Size
			End Select
		Wend
		
		Return 1
		
	 EndIf
End Function


a few minor bug fixes


www.hoverhavok.mmocrafter.com/fle_compiled.zip