Author Topic: Terrain Map Dev Thread [SUCCESS PAGE 2]  (Read 5280 times)

Merge multiple dts files into one, each with it's own node name.
Then use static shapes and call the node functions on it.
For static shapes, won't this break collision?

Also, I don't NEED 8000 shapes, itd just be nice for smoother vehicle collision. Its for terrain maps. (more faces = bigger resolution overall, allowing the map to be less bumpy while still retaining changes in elevation.)

You can put tons of convex meshes in a single dts for collision.

Its only 1kb per shape, approx 8mb total download

Thing is, bl takes like 10 minutes to download those 8MB.
It's unbelievably slow for files not on the CDN.
« Last Edit: May 02, 2017, 06:55:17 PM by Zeblote »

You can put tons of convex meshes in a single dts for collision.
See, I tried that. I edited Tendon's script to put 60 collision meshes in each dts but the collision still didn't work :/

Thing is, bl takes like 10 minutes to download those 8MB.
It's unbelievably slow for files not on the CDN.
Yeah, gotcha.

Here's my version of Tendon's export.py that I edited: Maybe I did something wrong?
Code: [Select]
import bpy
import os

def get_override(area_type, region_type):
for area in bpy.context.screen.areas:
if area.type == area_type:             
for region in area.regions:                 
if region.type == region_type:                   
override = {'area': area, 'region': region}
return override
#error message if the area or region wasn't found
raise RuntimeError("Wasn't able to find", region_type," in area ", area_type,
"\n Make sure it's open while executing script.")

#we need to override the context of our operator   
override = get_override( 'VIEW_3D', 'WINDOW' )

#override is for resizing an object by the median center of it's vertices.  It's not needed here, but maybe in the future.

def dodtloveports(exportpath,blpath):
#setup script files
if os.path.exists(exportpath + 'server.cs') == False:
textserver = open(exportpath + 'server.cs', "w")
textserver.write("exec(\"./data.cs\");")
textserver.close()
if os.path.exists(exportpath + 'description.txt') == False:
textdesc = open(exportpath + 'description.txt', "w")
textdesc.write("Title: MAPNAME\n")
textdesc.write("Author: NOT AVAILABLE\n")
textdesc.write("THIS FILE WAS AUTOGENERATED\n")
textdesc.close()
textdata = open(exportpath + 'data.cs', "w")
textdata.write("package LoadMapPackage\n")
textdata.write("{\n")
textdata.write("\tfunction GameConnection::startLoad(%client)\n")
textdata.write("\t{\n")
textdata.write("\t\tif(!isObject(\"MapGroup\"))\n")
textdata.write("\t\t{\n")
textdata.write("\t\t\texec(\"" + blpath + "place.cs\");\n")
textdata.write("\t\t\tMissionCleanup.add(\"MapGroup\");\n")
textdata.write("\t\t}\n")
textdata.write("\t\tParent::startLoad(%client);\n")
textdata.write("\t}\n")
textdata.write("};\n")
textdata.write("activatepackage(LoadMapPackage);\n\n")
textplace = open(exportpath + 'place.cs', "w")
textplace.write("new SimGroup(MapGroup)\n")
textplace.write("{\n")
#export detail32
if bpy.data.groups.get("detail32") is not None:
objects = bpy.data.groups['detail32'].objects
for object in objects:
bpy.ops.object.select_all(action='DESELECT')
object.select = True
bpy.ops.object.duplicate(linked=False,mode='DUMMY')
dupe = bpy.context.selected_objects[0]
dupe.name = "DETTEMPSHAPE"
bpy.context.scene.objects.active = dupe
bpy.ops.transform.translate(value=dupe.location*-1)
bpy.ops.object.transform_apply(location=True,scale=True,rotation=True)
bpy.ops.export_scene.dts(filepath=exportpath + "shapes\\" + object.name + ".dts",select_object=True)
textdata.write("datablock staticShapeData(SS" + object.name.replace(".","DOT") + "Data)\n")
textdata.write("{\n")
textdata.write("\tshapefile = \"" + blpath + "shapes/" + object.name + ".dts\";\n")
textdata.write("};\n")
textplace.write("\tnew StaticShape(\"SS" + object.name.replace(".","DOT") + "\")\n")
textplace.write("\t{\n")
textplace.write("\t\tposition = \"" + "%.6f" % object.location[0] + " " + "%.6f" % object.location[1] + " " + "%.6f" % object.location[2] + "\";\n")
textplace.write("\t\trotation = \"1 0 0 0\";\n")
textplace.write("\t\tscale = \"1 1 1\";\n")
textplace.write("\t\tdataBlock = \"SS" + object.name.replace(".","DOT") + "Data\";\n")
textplace.write("\t\tcansetIFLS = \"0\";\n")
textplace.write("\t};\n")
bpy.ops.object.delete(use_global=False)
else:
print("detail32 group not found.  No visible meshes to export.")
#export collision-1
if bpy.data.groups.get("Collision-1") is not None:
#create NULL SHAPE for detail32 layer of collision objects.
bpy.ops.object.select_all(action='DESELECT')
scene = bpy.context.scene
me = bpy.data.meshes.new("NULLTEMPSHAPE")
me.vertices.add(1)
nullob = bpy.data.objects.new("NULLTEMPSHAPE", me)
nullob.location = (0,0,0)
nullob.select = True
scene.objects.link(nullob)
scene.objects.active = nullob
scene.update()
if bpy.data.groups.get("detail32") is not None:
bpy.ops.object.group_link(group='detail32')
else:
bpy.ops.object.group_add()
nullob.users_group[0].name = "detail32"
objects = bpy.data.groups['Collision-1'].objects
counter = 0;
for object in objects:
if object != nullob:
if counter == 0:
# First Time
if not 'ColGroup' in bpy.data.groups:
bpy.ops.group.create(name="ColGroup")
counter = counter + 1


#otherwise do the other stuff
bpy.ops.object.select_all(action='DESELECT')
object.select = True
bpy.ops.object.duplicate(linked=False,mode='DUMMY')
dupe = bpy.context.selected_objects[0]
dupe.name = "COLTEMPSHAPE"
bpy.context.scene.objects.active = dupe
bpy.ops.transform.translate(value=dupe.location*-1)
bpy.ops.transform.resize(value=(2,2,2))
bpy.ops.object.transform_apply(location=True,scale=True,rotation=True)
bpy.ops.object.group_link(group="ColGroup")

if counter > 60:
#export everything
bpy.ops.object.select_all(action='DESELECT')
exportObjects = bpy.data.groups['ColGroup'].objects
for exportObject in exportObjects:
exportObject.select = True
bpy.ops.export_scene.dts(filepath=exportpath + "shapes\\" + object.name + ".dts",select_object=True)
textdata.write("datablock staticShapeData(SS" + object.name.replace(".","DOT") + "Data)\n")
textdata.write("{\n")
textdata.write("\tshapefile = \"" + blpath + "shapes/" + object.name + ".dts\";\n")
textdata.write("};\n")
textplace.write("\tnew TSStatic(\"TSS" + object.name.replace(".","DOT") + "\")\n")
textplace.write("\t{\n")
textplace.write("\t\tposition = \"" + "%.6f" % object.location[0] + " " + "%.6f" % object.location[1] + " " + "%.6f" % object.location[2] + "\";\n")
textplace.write("\t\trotation = \"1 0 0 0\";\n")
textplace.write("\t\tscale = \"0.5 0.5 0.5\";\n")
textplace.write("\t\tshapename = \"" + blpath + "shapes/" + object.name + ".dts\";\n")
textplace.write("\t};\n")
counter = 0
bpy.ops.object.delete(use_global=False)

nullob.select = True
bpy.ops.object.delete(use_global=False)
else:
print("Collision-1 group not found. No collision meshes to export.")
#close script files
textdata.close()
textplace.write("};")
textplace.close()

dodtloveports('C:/Program Files (x86)/Steam/SteamApps/common/Blockland/Add-Ons/Map_TheSlopesv21/',"Add-Ons/Map_TheSlopesv21/")

It might just be a problem with your model.


maybe if you gave the dts a loscol the normal static shapes type will have that effect too??
I've never tested LOSCol w/a camera that's attached to a vehicle.  Is that what LOSCol is for?  I want to try that.


Here's my version of Tendon's export.py that I edited: Maybe I did something wrong?
As far as I can tell... probably not?  If you have the object centers for the collision shapes all set to 0 0 0 there shouldn't be any problems.

But if you have the object centers set to the bounds center of each seperate object...
Code: [Select]
bpy.ops.transform.translate(value=dupe.location*-1)That line will set each object's transform to 0 0 0.  So you'd end up with all of the objects stacked on top of each other.
And this line:
Code: [Select]
textplace.write("\t\tposition = \"" + "%.6f" % object.location[0] + " " + "%.6f" % object.location[1] + " " + "%.6f" % object.location[2] + "\";\n")Is going to use the position of every 60th object.  So the offset will be weird.

Maybe you could try exporting the objects in groups smaller than 60. Or you could make a .blend specifically for testing your version of the script.

Better- before spending all of this time making the exporter work, try exporting a group of the shapes as a single dts manually, to see if the collision is ok.
I tested exporting 2 cubes seperated by 4 units as a single dts.  The cube faces that faced each other were invalid, and I could drive into the cubes through most of the faces. :c

I think loscol is for raycasting so it should work

Howdy-bump. I will be looking into this stuff tonight/tomorrow.

One other problem I encounter with static maps is building. In old terrain maps, you could build inside the terrain. In static maps, not so much. Would like to look into packaging brick plant to allow for building INSIDE of tsstatic.

Howdy-bump. I will be looking into this stuff tonight/tomorrow.

One other problem I encounter with static maps is building. In old terrain maps, you could build inside the terrain. In static maps, not so much. Would like to look into packaging brick plant to allow for building INSIDE of tsstatic.
there should be mods floating around that do this already, but if you wanted to make it yourself, you'd probably just be looking at packaging serverCmdPlantBrick with a new version that doesn't error check. a true solution is a bit more involved than this though, not sure if for this specific application there's a better option

there should be mods floating around that do this already, but if you wanted to make it yourself, you'd probably just be looking at packaging serverCmdPlantBrick with a new version that doesn't error check. a true solution is a bit more involved than this though, not sure if for this specific application there's a better option
To prevent bricks being placed in other bricks, I could do a check similar to how jvs doors check if someone is stuck.


No collision issues here, 2 cubes. Trying more setups.



I also made the cubes larger and discovered the same issue that @Tendon talked about.
For some reason, vehicles are OK on top of all the cubes, but they will ghost through some sides of different cubes.



Edit: Projectiles work 100%- its just the vehicles that don't work 100%.
« Last Edit: May 26, 2017, 12:03:07 PM by --LegoPepper-- »


Angled tops seem to be completely reliable. As the type of terrain I want to make does not require there to be 90 degree angle collision, its possible that I could get this to work just fine :O

I have successfully optimized the download for a map.
Instead of using 2500 datablocks, it uses less than 100.



The only real problem is the collision density is VERY VERY LOW. It's like driving on a bunch of bricks instead of a bunch of modter bricks.

I will do experiments to fix this in the future.

However, players and projectiles work completely :)

Ok, neat.  So this could be used for a footbased tdm?