PDA

View Full Version : VMap/Wmap manipulation examples?



jeric_synergy
09-03-2015, 05:14 PM
In the supplied Python scripts, are there any that manipulate Weight Maps?

Cuz I haven't spotted any yet.

jeric_synergy
09-15-2015, 11:14 PM
(rather than making a new thread, since I'm still 'working' on this, I'll add on and see if anybody can respond...)

#notAProgrammer

In the Python dox, there's a bit:

vmap(int index) → char

Returns the name of the currently selected vertex map, and returns the LWID of the vmap. index can be one of the following:

lwsdk.LWM_VMAP_WEIGHT
lwsdk.LWM_VMAP_TEXTURE
lwsdk.LWM_VMAP_MORPH

Now, I'd expect "int index" to mean "integer index", but then there's those strings in the bit below. Are these strings defined values somewhere in the guts of the implementation? Or does one need to find the integer values and plug them in?

A foreign language it is....

iain_r
09-16-2015, 06:22 AM
If you have a weight map selected you can use the following. It's a quick hack and throws a SWIG error on a type conversion that I haven't figured out.

The types are in some internal indexed lookup starting at zero.

If you are after the number of maps and more details use lwsdk.LWObjectFuncs instead.

Regards

Iain



#! /usr/bin/env python
# -*- Mode: Python -*-
# -*- coding: ascii -*-

"""
This is a LightWave Generic plug-in.
"""

import sys
import lwsdk

__author__ = "Iain"
__date__ = ""
__copyright__ = ""
__version__ = "1.0"
__maintainer__ = "Iain"
__email__ = ""
__status__ = "Example"
__lwver__ = "11"


class vmap_name(lwsdk.ICommandSequence):
def __init__(self, context):
super(vmap_name, self).__init__()

def process(self, mod_command):
sq = lwsdk.LWStateQueryFuncs()

vname,ind = sq.vmap(lwsdk.LWM_VMAP_WEIGHT)

print("by name", vname)

vname,ind = sq.vmap(0)

print("by index", vname)

ServerTagInfo = [
( "Python Vmap Name", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ),
( "Vmap Name", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ),
( "Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH )
]

ServerRecord = { lwsdk.CommandSequenceFactory("LW_PyVmapName", vmap_name) : ServerTagInfo }

jeric_synergy
09-16-2015, 09:37 AM
Thanks iain_r. --So, things like "LWM_VMAP_WEIGHT" are defined somewhere within the system? Or are they the proper arguments themselves? (Just trying to grok the documentation conventions here.)

ernpchan
09-16-2015, 09:42 AM
They're defined in the system.

iain_r
09-16-2015, 10:58 AM
From lwmodeler.h in the include directory of the SDK

#define LWM_VMAP_WEIGHT 0
#define LWM_VMAP_TEXTURE 1
#define LWM_VMAP_MORPH 2

jeric_synergy
09-16-2015, 11:19 AM
And (please bear with me, zero C experience) "import lwsdk" automatically brings in lwmodeler.h also?

(Thanks everybody for all your assistance.)

iain_r
09-16-2015, 11:44 AM
Sorry, I was just pointing out how the values are assigned within the header file and why using the string or the number gives the same result, basically it's saying where you see LWM_VMAP_WEIGHT use the value 0. The "import lwsdk" will load a module which will contain functions which access components of the sdk. The definitions will be contained in some dll that is referenced as a library call somewhere from within lwsdk, it won't load the header file.

Regards

Iain

jeric_synergy
09-16-2015, 11:45 AM
LOL. And that is why learning this stuff is so difficult. :thumbsup: