Page 2 of 4

PostPosted: Sat Mar 10, 2007 1:11 am
by carldt
I uploaded a 0.3, this is pretty much the same, just has a couple of extra pointer casts in case you need to go ZLIST, ZFUNC, ZFORMAT to ZVAR.

Also now the open file dialog box lets you choose All Files *.*, so that you can right click, create new text file, then rename that text file to a .py, then right click on the .py, and edit with IDLE.

cdPython is what I consider to be complete now. I would like to promote it to a 1.0 version, but I won't until some other people have used it so we know for sure it's relatively bug free...

BTW Aaron, please can you add a version string to ExtAPI.h, so that plugins can compare this version in ExtAPI.h that is compiled into their DLL with the value returned by ExtGetApiVersion. This is so the plugin can warn if it uses a version of the API that is different from the version in the L3DT.exe. Otherwise there may be some weird behaviour. In addition it would be nice if you could keep the API backwards compatible, so it doesn't break our plugins.

Thanks.

PostPosted: Sat Mar 10, 2007 7:17 am
by Aaron
Hello Carl,

BTW Aaron, please can you add a version string to ExtAPI.h, so that plugins can compare this version in ExtAPI.h that is compiled into their DLL with the value returned by ExtGetApiVersion.


ExtGetApiVersion returns the version compiled in the DLL. It's used by L3DT to check that the DLL version is OK. I'll put it on the to-do list to add a function that lets a plugin check the API version in L3DT.

This is so the plugin can warn if it uses a version of the API that is different from the version in the L3DT.exe. Otherwise there may be some weird behaviour. In addition it would be nice if you could keep the API backwards compatible, so it doesn't break our plugins.


The API is backwards compatible, and I intend to keep it that way. In part, this is because I've written ~25 plugins, and I don't want to have to recompile them all. If you look through the 'log.txt' file output by L3DT (in %APPDATA%\Bundysoft\L3DT [version]) you can see the API version number of all the plugins, and only one or two will be v2.3, and some are still using v1.0.

Cheers,
Aaron.

some trouble...

PostPosted: Mon Mar 12, 2007 7:05 am
by carldt
I am having trouble here, my script is supposed to collect a bunch of parameters to execute mapconv, for generating a Spring map. But after the call to
Code: Select all
args.EditUI('MapConv parameters')
my string variable has a bad value...

Maybe there's a bug inside Zeolite? Or am I using the API incorrectly?

Code: Select all

import zeolite
import os

args = zeolite.CzList()

compression = zeolite.floatp()
compression.assign(0.5)

compression_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_float, 'compression'))
compression_var.SetValue(zeolite.VarID_float, compression.cast())

maxheight = zeolite.intp()
maxheight.assign(300)
                         
maxheight_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_int, 'max height'))
maxheight_var.SetValue(zeolite.VarID_int, maxheight.cast())

minheight = zeolite.intp()
minheight.assign(50)

minheight_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_int, 'min height'))
minheight_var.SetValue(zeolite.VarID_int, minheight.cast())

lowpass = zeolite.boolp()
lowpass.assign(False)
lowpass_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_bool, 'low pass'))
lowpass_var.SetValue(zeolite.VarID_bool, lowpass.cast())

invert = zeolite.boolp()
invert.assign(False)
invert_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_bool, 'invert'))
invert_var.SetValue(zeolite.VarID_bool, invert.cast())

texture_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_string, 'texture'))

mapname_handle = args.CreateItem(zeolite.VarID_string, 'map name')
mapname_str = zeolite.CzStr()
mapname_str.Attach(mapname_handle)
mapname_str.SetText('Hello World')

print str(mapname_str.GetText())

#texturemap_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_map, 'texturemap'))

#heightmap_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_map, 'heightmap'))

#featuremap_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_map, 'featuremap'))

#typemap_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_map, 'typemap'))

args.EditUI('MapConv parameters')

cmd = 'MapConv'
cmd += ' -c ' + str(compression.value())
cmd += ' -x ' + str(maxheight.value())
cmd += ' -n ' + str(minheight.value())
cmd += ' -o ' + str(mapname_str.GetText()) # value of mapname_str variable is incorrect

print cmd

PostPosted: Mon Mar 12, 2007 7:43 am
by Aaron
Hi Carl,

Handles to variables aren't preserved when you edit a list, so you have to retrieve the handles afterwards using args.GetItem. This is a bit sucky, but it's currently required to allow 'cancel' to undo the changes. I'll see if I can do this more intelligently for the next release.

Cheers,
Aaron.

working better now...

PostPosted: Mon Mar 12, 2007 10:07 am
by carldt
Nearly there I think. All I need now is way to generate the metal map in L3DT...

Code: Select all
import zeolite
import os

# exports a map layer to a BMP file
def saveMapToBMP(mapname, filename):
    hmap = zeolite.CzMap()
    hf = zeolite.cvar.theAPI.project_GetMap(mapname)
    hmap.Attach(zeolite.zmap_to_zvar(hf))

    format = zeolite.CzFormat()
    format.GetByExt(mapname, 0, 'bmp')

    hmap.SaveFile(filename, zeolite.zvar_to_zformat(format.GetZVAR()), True, True)
    return

args = zeolite.CzList()

compression = zeolite.floatp()
compression.assign(0.5)

compression_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_float, 'compression'))
compression_var.SetValue(zeolite.VarID_float, compression.cast())

maxheight = zeolite.intp()
maxheight.assign(300)
                         
maxheight_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_int, 'max height'))
maxheight_var.SetValue(zeolite.VarID_int, maxheight.cast())

minheight = zeolite.intp()
minheight.assign(50)

minheight_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_int, 'min height'))
minheight_var.SetValue(zeolite.VarID_int, minheight.cast())

lowpass = zeolite.boolp()
lowpass.assign(False)
lowpass_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_bool, 'low pass'))
lowpass_var.SetValue(zeolite.VarID_bool, lowpass.cast())

invert = zeolite.boolp()
invert.assign(False)
invert_var = zeolite.CzVar(args.CreateItem(zeolite.VarID_bool, 'invert'))
invert_var.SetValue(zeolite.VarID_bool, invert.cast())

mapname_handle = args.CreateItem(zeolite.VarID_string, 'map name')
mapname_str = zeolite.CzStr()
mapname_str.Attach(mapname_handle)
mapname_str.SetText('HelloWorld')

handle = args.CreateItem(zeolite.VarID_map, 'texturemap')
texture_map = zeolite.CzMap()
texture_map.Attach(handle)

handle = args.CreateItem(zeolite.VarID_map, 'heightmap')
height_map = zeolite.CzMap()
height_map.Attach(handle)

handle = args.CreateItem(zeolite.VarID_map, 'featuremap')
feature_map = zeolite.CzMap()
feature_map.Attach(handle)

handle = args.CreateItem(zeolite.VarID_map, 'typemap')
type_map = zeolite.CzMap()
type_map.Attach(handle)

args.EditUI('MapConv parameters')

# Handles to variables aren't preserved when you edit a list,
# so you have to retrieve the handles afterwards using args.GetItem
compression_var.Attach(args.GetItem('compression'))
maxheight_var.Attach(args.GetItem('max height'))
minheight_var.Attach(args.GetItem('min height'))
lowpass_var.Attach(args.GetItem('low pass'))
invert_var.Attach(args.GetItem('invert'))
mapname_str.Attach(args.GetItem('map name'))

outputfile = mapname_str.GetText()
outputfile.replace(' ','') # remove spaces
outputfile += '.smf'

# Output the maps to BMP format
hfbmp = 'heightmap.bmp'
saveMapToBMP('HF', hfbmp)

texturebmp = 'texture.bmp'
saveMapToBMP('TX', texturebmp)

metalbmp = 'metalmap.bmp'

featurebmp = 'featuremap.bmp'

typebmp = 'typemap.bmp'

cmd = 'D:\Projects\springmapping\Mapconv_v0_6\MapConv.exe'

# compression
cmd += ' -c ' + str(compression.value())

# max height
cmd += ' -x ' + str(maxheight.value())

# min height
cmd += ' -n ' + str(minheight.value())

# output filename
cmd += ' -o ' + outputfile

# texture
cmd += ' -t ' + texturebmp

# metal map
cmd += ' -m ' + metalbmp

# height map
cmd += ' -a ' + hfbmp

# feature map
#cmd += ' -f ' + featurebmp

# terrain type map
#cmd += ' -y ' + typebmp

# lowpass, smoothing
lowpass_var.GetValue(zeolite.VarID_bool, lowpass.cast())
if lowpass.value() == True:
    cmd += ' -l '

# invert height map
invert_var.GetValue(zeolite.VarID_bool, invert.cast())
if invert.value() == True:
    cmd += ' -i '

print cmd

os.system(cmd)

PostPosted: Mon Mar 19, 2007 2:53 am
by Aaron
Hi Carl,

I'm presently working on the methods required for plugins to add custom map layers to the L3DT project, and once that's done I'll add a plugin for a simple brush interface to design metal maps, etc.

Cheers,
Aaron.

MinGW

PostPosted: Sun Mar 25, 2007 9:35 am
by carldt
Hi,

Just thought I'd mention I have managed to compile cdPython using the MinGW toolkit. The plugin loads fine into L3DT, however it crashes when calling a python function (this is the python mscvr71.dll problem all over again).

However, others will be glad to know that MinGW compiled extensions can be loaded by L3DT.

http://www.mingw.org

People who are interested in building L3DT friendly DLLS using MinGW can have a look at the Makefile in the cdPython source.

Note for Aaron: I have made two very small changed to the Plugin API code:

Removed the includes at the top of ExtAPI.cpp:

Code: Select all
// include MFC or windows, depending on developer's choice
//#ifdef _MSC_VER
//   #include "afx.h"
//#else
//   #include "windows.h"
//#endif


And added this to ExtAPI_defines.h:

Code: Select all
#ifdef MFC
   #include <afx.h>
#else
   #include <windows.h>
#endif

#ifdef __MINGW32__
   #include <ctype.h>
#endif

PostPosted: Sun Mar 25, 2007 9:40 am
by Aaron
Hi Carl,

Thanks for that. I'll put those changes into the next API release.

Cheers,
Aaron.

Python 0.9 Released

PostPosted: Sat Mar 31, 2007 10:01 am
by carldt
I have released a new version of cdPython which includes a bunch of zeofunc wrapper functions (see this post for background: http://www.bundysoft.com/phpBB2/viewtopic.php?t=509)

It is version 0.9, you can get it here:

http://l3dtpython.googlecode.com/files/cdPython-0.9.zip

PostPosted: Sat Mar 31, 2007 8:35 pm
by DeathTwister
Sorry guys I been away for a bit,

so heres a dumb questain. Is this a plugin so we can bring in terrains into Blender to work with as a wolrd editor, or for building animations in Blender? That would be sweet as Blender besides it exporting out to TGEA .difs and .dts's now, but it also is a world editor for Ogre, or becoming one anyway and getting terrain into programs is such a pain for us just artist types and not headbanging programmers /winkls......
I just downloaded the newest version of L3DT, and I hear there is a plugin that exports terrains now out of L3DT to TGEA??? gues I will find out when it downloaded.. /winks. Wow that would be nice though, but I am liking very much the idea of a L3DT_2_Blender_Exporter. Now that is thinking..../cheers you guys are awesome.

DT :twisted:

PostPosted: Sun Apr 01, 2007 5:46 am
by Aaron
Hi DT,

DeathTwister wrote:Is this a plugin so we can bring in terrains into Blender to work with as a wolrd editor, or for building animations in Blender?


Nope, this is a python scripting plugin. If you'd like to request a Blender plugin, please start a new thread, rather than going off-topic in this one.

DeathTwister wrote: I just downloaded the newest version of L3DT, and I hear there is a plugin that exports terrains now out of L3DT to TGEA???


An unofficial version of the plugin is on the GarageGames site, in the tools forum. If you want the official version, you'll have to wait a bit longer, as it's still being debugged.

Anyway, getting back on topic, congratulations Carl on v0.9, and particularly on the zeofunc wrapping. That was genius. Downloading now...

Cheers,
Aaron.

cdPython-0.10

PostPosted: Sun Apr 01, 2007 9:00 am
by carldt
Python-0.10 is here, this has a new generated wrapper interface that was previously broken for types that must be set by reference. Functions that take non atomic types, (temp.GetTypeID() >= zeolite.VarID_colour and temp.GetTypeID() <= zeolite.VarID_ProgBox) should work correctly now.

http://l3dtpython.googlecode.com/files/cdPython-0.10.zip

PostPosted: Sun Apr 01, 2007 9:11 am
by Aaron
Hi Carl,

I'll put it on the to-do list to add a function that lets you test whether a variable type can be copied. A bit of an oversight, that.

Best regards,
Aaron.

PostPosted: Sun Apr 01, 2007 12:30 pm
by DeathTwister
Hay guys,

I was not trying to go off topic, I thouight it was on topic /chuckles...Sorry, the math had me confused and it sounded like it was for blender.

May I ask what all this does do, or is for? I guess my pee brain didn't understand what was being said sorry guys, just a dumb artist here.

Hay Aaron, and thanks for the info on TGEA, I will wait a bit then.

No need to respond:

DT

PostPosted: Tue Apr 03, 2007 7:27 pm
by Aaron
Hi Maylock,

I apologise for snapping at you there. I did some more reading, and I see that Blender has a python API too, so your question was not as far off topic as I initially thought.

In answer to your supplementary question; this plugin allows users to run python scripts in L3DT (python is a fancy and newish programming/scripting language). These scripts can do simple things like load/save files, more complex things like read/apply settings, fancy things like custom calculations, and probably much fancier things still. The possibilities are indeed very broad.

Best regards,
Aaron.