Position-maps with Blitztree?

Blitz3D Forums/Blitz3D Beginners Area/Position-maps with Blitztree?

Quantum(Posted 2007) [#1]
I just bought Blitz tree and so far I'm really happy with it's results on a 3D mesh landscape at least... despite the command syntax being incorrect!... ie... MakeTREE("filename",x#,y#,z#, size#=0, rotation#, scalex#, scaley#, scalez#)... returns a "too many parameters" error??... while MakeTREE("filename",pos_x,pos_y,pos_z, treesize=0,2)... appears to work great?

But I'm now trying to place trees using a placement-map... I have created a height-mapped scene, used the tree load command... LoadTreeColorMap("lm/treemap.bmp","lm/trees.txt",terr,20)... using the exact syntax shown in the docs... and once again I get a "not enough parameters" error?... so I added another ",20"... ie... LoadTreeColorMap("lm/treemap.jpg","lm/trees.txt",terr,20,20)... and now it works... or at least the error warning has stopped showing for this line!... but I have no idea what the last number is addressing, as it is obviously not covered in the docs?... and the position-map is still not working...

So I then created the position map using a single pixel 0,255,0 dot on a black texture (the same size as my height-map)... created th text file calling the trees (all exactly as shown in the docs)...ie...

1
"trees\sage\sage.btr" ,5, 5, 5

(# of trees followed by filesname, scale x/y/z)

... and NOW I get a "array index out-of-bounds" error?

Has anyone else here had problems implementing this?... cos I'd be very grateful of any help regarding the correct syntax for the use of placement-maps with Blitztree, as the supplied documentation is clearly out-of-date!


Quantum(Posted 2007) [#2]
Well... just as an update for anyone else who might be thinking of buying Blitz Tree... after 3 days of swearing, ranting & general frustration... I've found the problem :)

Apparently... the version of the "bt3d_include.bb" contained in the "engine code" folder... is designed for use with "TerraEd" only!... however... in the "sample code" folder, where the demo of Blitz Tree resides (and where I hadn't previously looked... assuming it would be the same engine code!), there is another version of the "bt3d_include.bb" that ISN'T written specifically for "TerraEd" height-maps (but has the exact same name).

So if, like me, you don't have "TerraEd"... ONLY use the "bt3d_include.bb" file in the "Sample Code" folder!... it might save you 3 days of high blood pressure! lol... especially if you are a noob like me & still trying to figure-out what does what & why! lol


puki(Posted 2007) [#3]
Do you have any idea what version your bt3d_include.bb is - if not, what file-size is it?


Quantum(Posted 2007) [#4]
Yes Puki... the actual "engine-code" version (TerraEd version that is) 35.8k... and the "sample-code" version is 33.8k :)

I can't find a version number... but I bought it about 10 days ago from the `TGC` site... and despite one of their customer services representatives emailing me & telling me he would take a copy home to find out what the problem was... I've heard nothing back! lol... but as I explained above... I've discovered the problem now.

The "engine-code" folder should have both versions in it & have them re-named appropriately!... eg "bt3d_TerraEd_include.bb" & "bt3d_Gen_include.bb"... thats what I've done with mine now :)


puki(Posted 2007) [#5]
Mmm, the original 'bt3d_include.bb' was 33.8KB and the 1.42 update was 35.8KB.

The 35.8 (TerraEd version - as you call it), should be the 1.42 update.

As far as I know it is not a TerraEd version.

What happens when you use it without a placement-map method?


Quantum(Posted 2007) [#6]
Using the include file in the "Engine-Code" folder, I just keep getting "array out of bounds" errors no matter what I try?

Whereas the smaller version (33k) in the "sample-code" folder works like a charm?

One day I'll have to treat myself to TerraEd & see if it make any difference.

The line(s) where the error show up in the include file are here....

;--- this function loads tree color maps produced by TerraED map maker
Function BT_LoadTerraEDColorMap(nt$,nl$,terrainPH,TerscaleTL#, col_type)

If FileType(nl$)=0 Then RuntimeError nt$+" Tree-list file missing!" : End
If FileType(nt$)=0 Then RuntimeError nl$+" Tree-color placement map file missing" : End
If terrainPH=0 Then RuntimeError "Terrain not found (Tree color map)" : End

;--- setup the treelist from user input file
BTcnt=0
op=ReadFile(nl$)
BTcnt=ReadLine(op)
Dim BTtcm(BTcnt,6 )
Dim BTtcmName$(btcnt)
For bt_temp=1 To BTcnt
treeLISTent$=ReadLine(op)
parser$(treeLISTent$)
BTtcm(bt_temp,1)=par(1);r
BTtcm(bt_temp,2)=par(2);g
BTtcm(bt_temp,3)=par(3);b
BTtcmName$(bt_temp)=par(4);filename
BTtcm(bt_temp,4)=par(5);scale ; ************** Array out of bound error shows HERE!!!
BTtcm(bt_temp,5)=par(6);scale
BTtcm(bt_temp,6)=par(7);scale
Next
CloseFile op

... as you can see... the include file is full of references to TerraEd???... this entire section is missing from the version that I found to work!... I've highlighted exactly where the array error shows in the code snippet above :)

When I used it without a placement map... by entering co-ords for individual trees & loading them as individual scenery objects... it worked fine?... that was the method I had been using for about a week before I decided to try a placement map... thats when I hit all the probs lol


puki(Posted 2007) [#7]
Mmm, the TerraEd stuff certainly is in the 1.42 update.

Rename the 'bt3d_include.bb' in your Sample Code directory to 'bt3d_include.b'. Now copy the 1.42 (TerraEd) into the same directory. Now run the Sample code example - does it work? Forget about your code - does the sample work with the 1.42 update?

If not, post your copy of the sample code.


Quantum(Posted 2007) [#8]
I just tried it & no... the sample code doesn't work with the 1.42 update?... "entity does not exist" error on the "tree_cam"

The sample code btw doesn't use placement maps... it uses random numbers for placement....

For t=1 To 45
x=Rand(0,18000) : z=Rand(0,18000)
atree=MakeTREE("trees/tree_h6/tree036.btr",x,TerrainY(ter,x,0,z),z,treesize=0,type_tree)
a=Rand(2,8) : b=Rand(3,7) : ScaleTree atree,a,a,a : RotateTree atree,0,Rand(-180,180),0
Next


Quantum(Posted 2007) [#9]
Here's the "sample code" though :)....



Graphics3D 1024,768,32,2
Global cam=CreateCamera()
CameraRange cam,5,25000 : EntityRadius cam,15 ; : CameraFogMode cam,1 : CameraFogColor cam,255,255,255 : CameraFogRange cam,1000,15000

Global lig=CreateLight()
LightColor lig,255,255,0
RotateEntity lig,0,180,0
AmbientLight 105,105,105

Include "bt3d_include.bb"


ter=LoadTerrain("hmap_1.bmp")
ScaleEntity ter,20,1,20
;detail=1000:morph=True
TerrainDetail ter,detail,morph

tex0=LoadTexture("bmap_1.bmp")
tex1=LoadTexture("tmap_1.bmp")
tex2=LoadTexture("cmap_1.bmp")
tex3=LoadTexture("rmap_1.bmp")

ScaleTexture tex0,20,20
ScaleTexture tex3,25,25
ScaleTexture tex2,TerrainSize(ter),TerrainSize(ter)
ScaleTexture tex1,TerrainSize(ter),TerrainSize(ter)
TextureBlend tex1,3

EntityTexture ter,tex3,0,0
EntityTexture ter,tex1,0,1
EntityTexture ter,tex0,0,3
EntityTexture ter,tex2,0,2

PositionEntity cam,11221,389,10085

;--- setup collision data
Const type_tree=1, type_cam=2
EntityType cam,type_cam
Collisions type_cam,type_tree,2,2
;---

For t=1 To 45
x=Rand(0,18000) : z=Rand(0,18000)
atree=MakeTREE("trees/tree_h6/tree036.btr",x,TerrainY(ter,x,0,z),z,treesize=0,type_tree)
a=Rand(2,8) : b=Rand(3,7) : ScaleTree atree,a,a,a : RotateTree atree,0,Rand(-180,180),0
Next


FlushMouse()
m=CreateMesh()
;front face
b=LoadBrush( "2_fr.bmp",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,-1,0,0:AddVertex s,+1,+1,-1,1,0
AddVertex s,+1,-1,-1,1,1:AddVertex s,-1,-1,-1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;right face
b=LoadBrush( "2_lf.bmp",49)
s=CreateSurface( m,b )
AddVertex s,+1,+1,-1,0,0:AddVertex s,+1,+1,+1,1,0
AddVertex s,+1,-1,+1,1,1:AddVertex s,+1,-1,-1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;back face
b=LoadBrush( "2_BK.bmp",49)
s=CreateSurface( m,b )
AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0
AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;left face
b=LoadBrush( "2_RT.bmp",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,+1,0,0:AddVertex s,-1,+1,-1,1,0
AddVertex s,-1,-1,-1,1,1:AddVertex s,-1,-1,+1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;top face
b=LoadBrush( "2_UP.bmp",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,+1,0,1:AddVertex s,+1,+1,+1,0,0
AddVertex s,+1,+1,-1,1,0:AddVertex s,-1,+1,-1,1,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;bottom face
b=LoadBrush( "2_DN.bmp",49 )
s=CreateSurface( m,b )
AddVertex s,-1,-1,-1,1,0:AddVertex s,+1,-1,-1,1,1
AddVertex s,+1,-1,+1,0,1:AddVertex s,-1,-1,+1,0,0
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
ScaleMesh m,100,100,100
FlipMesh m
EntityFX m,1
ScaleEntity m,15,15,15
EntityOrder m,100
skybox=m

Global gameFPS = 32
Global framePeriod = 1000/gameFPS
Global frameTime = MilliSecs() - framePeriod , update_frequency=20, clicktime
Global frameElapsed , aap
framePeriod = 1000 / gameFPS
frameTime = MilliSecs () - framePeriod


Repeat

Repeat
frameElapsed = MilliSecs () - frameTime
Until frameElapsed
frameTicks = frameElapsed / framePeriod
frameTween# = Float (frameElapsed Mod framePeriod) / Float (framePeriod)


For frameLimit = 1 To frameTicks
If frameLimit = frameTicks Then CaptureWorld
frameTime = frameTime + framePeriod
click=0
If MouseDown(1)=1 Then click=1
If MouseDown(2)=1 Then click=2
If MouseDown(1)=1 And MouseDown(2)=1 Then click=3
mx=MouseX() : my=MouseY()
UpdateQuads() ; *************************************
Gosub general
UpdateWorld
Next
;HideEntity skybox
RenderWorld frameTween
fps_counter=fps_counter+1 : If fps_counter=update_frequency Then ffps=1000/Float(((MilliSecs()-fps_milli))/update_frequency) : fps_milli=MilliSecs() : fps_counter=0


Color 0,0,0 : Text 1,1,"fps: "+ffps+" "+TrisRendered()
Color 255,255,255 : Text 1,15,"fps: "+ffps+" "+TrisRendered()
Text 1,30,aap
Flip(False)

Until KeyHit (1)

End

.general

mspeedy=MouseYSpeed()
mspeedx=MouseXSpeed()
dest_xang# = dest_xang + (mspeedy/3)
dest_yang# = dest_yang - (mspeedx/3)
xang# = CurveValue (xang, dest_xang, 5)
yang# = CurveValue (yang, dest_yang, 5)
mousetimermm#=MilliSecs()+200
RotateEntity cam, xang#, yang#, 0
MoveMouse 400,300

hx=EntityX(cam)
hy=EntityY(cam)
hz=EntityZ(cam)
If MouseDown(2)=1 Or MouseDown(1)=1 Then MoveEntity cam,0,0,30
If KeyDown(200)=1 Then MoveEntity cam,0,0,40
If KeyDown(208)=1 Then MoveEntity cam,0,0,-30
If KeyDown(203)=1 Then MoveEntity cam,-15,0,0
If KeyDown(205)=1 Then MoveEntity cam,15,0,0
PositionEntity skybox,EntityX(cam),EntityY(cam)-150,EntityZ(cam)

Return

Function CurveValue#(current#,destination#,curve#)
current#=current#+((destination#-current#)/curve#)
Return current#
End Function


puki(Posted 2007) [#10]
Mmm.

I'll email you my 1.42 update - see if mine works with the sample code.


Quantum(Posted 2007) [#11]
I tried it with my program puki... and got the same error cos the include file is identical to mine. It does work with the sample code but thats probably because it doesn't use a placement map :-S

Do you think it's my .txt file thats messing up?... here's what I'm using :-

5
trees\euc\euc.btr .5 .5 .5
trees\ftree_2\ftree2.btr .5 .5 .5
trees\ftree_3\ftree3.btr .5 .5 .5
trees\ftree_4\ftree4.btr .5 .5 .5
trees\ftree_5\ftree5.btr .5 .5 .5

... this works great in the smaller `bt3d_include.bb` file, but throws the "array out of bounds" error on the line I've highlighted above when I use the 1.42 version?

(mine is 1.42 btw... when I un-zipped it, it created a folder named "BlitzTree1_42"... but I was looking for a version number in the code!... Durrrrr lol


puki(Posted 2007) [#12]
I've never had a problem with my copy - both includes work with the sample code. However, I have never tried using placement methods.

Still, if it works with the (what I think is the 1.0.4 version) then great.

I'm not too sure what improvements are in the 1.42 version other than the TerraED compatability.


Quantum(Posted 2007) [#13]
Yeah, both of my versions work with the sample code... it's just placement maps the 1.42 version doesn't seem to like?

Like I said before though... maybe I'll get TerraEd one day and see if it works then! but for now I'm just happy that I got 1.0.4 working lol

Thanks any way puki :)


Quantum(Posted 2007) [#14]
Oh BTW... if anyone out there IS using TerraEd placement maps with Blitz Tree v1.42... I'd really like to see an example of the tree definition .txt file please!... just out of curiosity :)