Jump to content

Terrain holes via code?


Gandi
 Share

Recommended Posts

  • 2 weeks later...

The Leadwerks Terrain has the feature to allow holes to be placed in it to allow you to pass into Cave/Underground systems etc. I'm not aware of any functions being exposed to allow manipulation of these in code but I could be mistaken.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

I tried to generate an .sbx file with a proper .vis file at runtime and then loading that generated scene, but it just messes up the terrain. I guess I will have to apply some kind of invisibility-shader to the terrain, but I am not so quite sure how to do that.

 

I was hoping that someone knows how th leadwerks scene does this.

Link to comment
Share on other sites

Without using bmx it will be impossible as the required functions are not exposed. But for bmx here is the part of code from my extended dll which handles the TileVisibility.

 

Located in EX_Sceneloader.bmx from this package http://www.leadwerks.com/werkspace/files/file/289-extension-dll-source-release/ :

 

If Int(String(map.ValueForKey("hiddentiles"))) > 0
   Local vfile:String = StripExt(SBXReadFile) + ".vis"
   Local vstream:TStream
   vstream=ReadFile(vfile)
   If vstream
    If vstream.size()=terrain.resolution*terrain.resolution
	 Local x:Int
	 Local y:Int
	 For x=0 To terrain.resolution-1
	  For y=0 To terrain.resolution-1
	   terrain.SetTileVisibility(x,y,vstream.ReadByte())
	  Next
	 Next
	 'vstream.readbytes(terrain.newtonHeightFieldCollisionTag.m_attributes,terrain.resolution*terrain.resolution)
	 terrain.UpdateVisibilityTexture()
    Else
	 AppLog "Visibility file is wrong size.",APPLOG_WARNING
    EndIf
    vstream.close()
   Else
    AppLog "Failed to load file ~q"+vfile+"~q.",APPLOG_WARNING
   EndIf

   loader._progresscount:+1
  EndIf

 

You might find other useful info in the dll source like manual vegetation painting etc.

  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Link to comment
Share on other sites

Hell yeah!

 

I created a new .dll with these two simple functions:

 

Const COMPILE_DLL:Int = True

Function SetTileVisibility(terrain:TTerrain,x:Int,y:Int,state:Byte) "Win32" 'EXPORT
If COMPILE_DLL Then GCEnter()
terrain.SetTileVisibility(x,y,state)
EndFunction

Function UpdateVisibilityTexture(terrain:TTerrain) "Win32" 'EXPORT
If COMPILE_DLL Then GCEnter()
terrain.UpdateVisibilityTexture()
EndFunction

 

And now it works smile.png

 

Thank you very much for the extension dll source. An amazing piece of work you did here.

Link to comment
Share on other sites

If you compile it with the latest version (up to date bmx module) all fixes of the delivered dll should be included in the extended dll as well.

Only completely new functions might be missing, but this should be easy to fix.

  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Link to comment
Share on other sites

It's an extended version of the standard engine dll which exposes additional functionality that Josh did not include in the standard DLL but is accessible in BMax. Can be useful depending on what you are attempting to do with the API. Look at the Asset Store entry for this to get a list of the additional functionality.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...