View Full Version : Making plugins...

Karl Hansson
02-17-2003, 03:29 PM
Hello, Ill go right to the point:
I want to learn how to develop plugins for lightwave. I know very little about programming but Im very eager to learn. Where do I begin and how do I start? What will I need. Ive been looking at Metrowerks Codewarrior learning edition... I dont know is that a good place to start? My goal is to learn lscript, c, c++ and open gl programming. Any suggestions? Tips?

I want to create plugins that help out in character rigging and animation. An idea I have is to make a plugin or a application that handles everything about weightmapping, bonerigging, smartskinnig, paranting, IK&FK, expressionscripting and with the ability to test the bonerotations, bonedeformations and smartskinning live at any time during the rigging process, weighting process and smartskinning process. All this under one interface and apart from the animation timeline. When the character enters the animationtimeline its fully rigged, expressed and tested - ready for action.

I know this is a longshot for someone that initially dont know any programming. But it is a goal and I like to amaze my self.:rolleyes:

02-17-2003, 05:07 PM
Im a programmer (as a hobby, not very good but i get by), im not very good with c++ but thats what im wanting to learn at the mo, i mainly use a program called Delphi (uses pascal), and im also going to start getting into lscript, a lot can be done with lscript and lscripts can also now be installed into lightwave as if they were plugins so i think that would be the best place to start. There is a few pdf's that came out a while back with a lot of lscript info and some tutorials, i think u can get them on the newtek site. Im going to have a good read through them when i get some time.
Im sure some other ppl can better advise you (and me too:)) but i think best place to start is with lscript.


02-17-2003, 05:43 PM
Newtek has a very neat LW Plugin development mailing list over on Yahoo. It has tons of information in the archives as well as being extremely active of late. It's a very good resource. There's been a couple of plugin programming tutes posted of late as well...


02-17-2003, 06:08 PM
I'm also interested in learning to write plug-ins for Lightwave. In fact, I'm thinking about taking some programming classes here at the local college later this year. I was wondering if anyone had any suggestions on what language would be a good all around language to use. I know they have classes for C+ but I haven't looked any further then that yet.

02-17-2003, 06:24 PM

Learn that and you should be all set.


02-17-2003, 06:36 PM
Oh and Karl, I don't mean to discourage you by any means. I think you should just break down and get either ACS4 ( http://acs.polas.net/acs/ ) or maybe even the setup machine (http://www.anzovin.com/setupmachine/setupmachinelw.html ) when it becomes available for Lightwave. I mean, who knows what kind of character tools are going to be in LW8 anyway? I guess I'm just saying maybe I would concentrate on learning some programming first. Who knows, you might find something else at that point you may want to add on to Lightwave rather then new character tools. That would be my only tip for you.
As I said, I'd like to take some programming classes but they have plenty of good books out there for beginners if you want to teach yourself.

02-17-2003, 06:57 PM
C++ is the most usefull programming language to learn cos of the huge ammount of other programming/scripting languages that are based on it, but in theory any programming language is capable of generating lw plugins, i think tho all the headers that you need to interface with lw (in the lw sdk?) will be in c++ so to use them with something like Delphi or VB they would have to be ported and thats a lengthy process for someone with a lot of knowledge :)

Also there are lots of free c++ compilers (borland have a very good one for free www.borland.com) and a lot of free IDE's too, do a google search, so u dont have to spend loads on Borlands C++ Builder or Microsofts Visual Studio, tho both of those are very nice to use :)


02-17-2003, 07:20 PM
Karl: If you want to program LW plug-ins you need to download the LW SDK, buy or download a C compiler (Code Warrior, Visual Studio, Borland C++ or GNU gcc) and read a lot.

The complete SDK and documentation is free, all the compilers excepting GNU gcc are comercial ($). Most software developers (NewTek included) think the best way to learn how to program is studing basic documentation and reading other's people code.

NOTE: Lightwave is programmed in C, not C++. C++ is a bit different, and can be cofusing to learn both at the same time, for this porpouse I recommend to start with C and focus in data structures.

Maybe you could try Lscript first, its application is limited compared with a plug-in, but still powerful.

Karl Hansson
02-17-2003, 11:36 PM
Thanks guys. I can imagin that if you know programming you can do almost anything. The Character setup plugin Im wanna make is just a goal and probably buy the time I know enough programming to take on that project Im sure there'll be equal tools out there. But Im sure the ones I know programming (enough) I dont think there'll be any shortages of plugin ideas.

02-18-2003, 04:41 PM
I would strongly recommend if you are a newbie to programming that you start out with LScript - You can do a LOT in it, and its syntax is similiar to C, so if you can master LScript, you should be able to pick up C/C++ a lot more easily later on...

LScript is a very nice little development tool. Besides, the other advantage is that LScript is pretty much cross platform - With C Plugins, you'll need someone to recompile versions for Mac, Intel, etc if you wanted to share them with the other platforms.

Ideally, I recommend getting a copy of Microsofts Visual C++ - I used to be a very pro-Borland programmer (and Delphi still is my RAD tool of choice) however for C/C++, I've found MS VC a much better product all-round. Though Borland still had the best DOS gui environment IMHO! :)

Besides, less work involved compiling plugins with VC then BC, or any other C development toolset for that matter - MSVC will compile pretty much fine - BC needs a few extra steps to compile working plugins (I think you need to link the runtime libraries in, making your plugins pretty large - Its been a while since I've touched plugin development!)

Also, some of the extra features of C++ (like classes) can make programming plugins easier then C. I'll have my old 5.5 plugins (Lampy, HUD, etc) and source code available on my website shortly if you want some examples to pick apart.

I'll let you know when they're online... Probably in a week or two when I find time to set up a page for them...

02-18-2003, 05:10 PM
I would agree with those who say learn C first.
It's a bit easier to get your head around than C++. At least for me. Take classes if you can. Thats a tough one though when you want to program plugs and the instructor whants you to parse a character string and rearange it alphabetcally.
Or some other BORING thing.
But that's exacatly what you need (not the boring thing).
My problem has always been to jump ahead and although I have learned a few things the "good" coders I've worked with learned the nuts and bolts first.
But I also have a major case of adult A.D.D. not good for programming.
Shiny things distract me!

02-18-2003, 10:37 PM
a guy in the lscript mailing list named carl (looper) said something interesting: if you're going to learn C / C++, learn it because you want to program apps, not simply because you want to learn the SDK and program for lw. he said that learning C / C++ and learning the SDK is enough to blow your brains apart. :D

needless to say, i kind of agree with him. i'm learning C++ right now, though i've paused for work, and i'm telling you, there's a whole world out there that goes beyond lw, and learning that to program plugins is pretty steep. if you want to learn C or C++ set your eyes on coding apps - your interest should go beyond writing plugins for lw.

of course, this is just my opinion. i think, for example, nik lever, learned how to program with only lw plugins on his mind. :)

lscript, indeed will give you a lot of power. the point of lscript is to give SDK access (albeit limited - but who knows how much it will open up in the coming versions?) without the heavy overhead of learning a full-fledged programming language.

i tend to disagree in some aspects that learning lscript will give make it easier for you to learn C or C++. while syntax is simliar, and the OO features of lscript can familiarize you with the concept when it's time to write C++, it _really_ different in terms of 'way of thinking.' it's _way_ more complex. (this coming from an lscriptwriter trying to learn C++, okay? :) )

lastly, one of bigger differences between .p plugs and lscripts is not so much of functionality as it is the _speed_ in which computations and functions are called.

02-18-2003, 11:26 PM
Originally posted by SpankDaddy
[Also there are lots of free c++ compilers (borland have a very good one for free www.borland.com) and a lot of free IDE's too, do a google search, so u dont have to spend loads on Borlands C++ Builder or Microsofts Visual Studio, tho both of those are very nice to use :)

James.. [/B]

I have an interest right now in using the Shades project and Shaderman as a framework to port Renderman math into Lightwave custom shaders (Thank you Mr. Landis!). I'm new to this also, and know J and S about it so far :)

Not being a progammer and wishing to limit my time to my Shades goal only, I installed DevC++ (which has the ming32 compiler), a free IDE. I managed to compile several Lightwave sample plugins by adding a makefile (Thank you Mr. Wright!), but haven't yet been able to compile Shades.

This is due to a lack of C knowledge on my part, though using Visual C++ may make it easier as it appears to be the tool of choice for other programmers porting these shaders.

The site below has an introduction and a setup tutorial, which helped me. His opinion is that expensive IDEs essentially make you pay fo the interface:



Elmar Moelzer
02-19-2003, 04:16 AM
I can only encourage everyone to learn plugin programming.
My advice is that newbies should start with L- script. It is very much like C, but more accessible and the L- Script - docs are pretty well written and especially the L- script- userguide can really help you get started with programming.
C is a subset of C++, so you cant really do wrong by learning C.
Although LW is C only as is the SDK one can do C++wrappers to make C++ plugin- programing possible. It is very likely that we will erlease our wrapper as well as a few othr tools, that will make C++- plugin- programming nearly as comfortable as L- script.
While we are talking about L- script etc: A very good and very easy start for learning L- script is by playing with LS- commander and LSID. You can do a whole lot with that and you easily get a feeling for the code...

02-19-2003, 08:24 AM
Actaully, I've read that to program in C++ you almost have to 'unlearn' C.

02-19-2003, 10:35 AM
Originally posted by hrgiger
Actaully, I've read that to program in C++ you almost have to 'unlearn' C.

Yeap, this is true. C is not a subset of C++, and C++ is not a superset of C. I learned C more than 10 years ago while programming tools for a Cray supercomputer in my university, beleive me, I was very good doing that. Now, for some reason I canīt learn C++:confused: . If this is not enough now there is a new language called C#. :mad:

With C++ you have the option to tell the compiler which part of your code is C with the pragma extern c{your c code}.

Lscript is very slow for big tasks (as with all interpreted languages), I remember a LW to RenderMan exporter, the length of the script is around 30 lines of code, but the translation for a very simple scene (1 light, 1 camera, and 1 sphere) took several minutes.

02-20-2003, 11:07 AM
LScript will always be slower than C for coding. It's the nature of the languages. However, the original thought of starting with LScript and then moving into C is very valid. You can learn a lot about programming if you start with a high-level scripting language (like LScript), and develop an understanding about Lightwave programming as well. When you reach the limits of LScript (in speed or functionality) you have already developed a basic knowledge that will aid your transition to C, and the SDK will not be so completely unwieldy, since you will already have some exposure to LW-think in coding.

Karl Hansson
02-20-2003, 02:26 PM
I have now started learning about Lscript. So far all is well.

Whats the major difference between c and c++? Is c more limited than c++?
If not then what's c++ good for?

02-20-2003, 04:08 PM
My comment is a simplification and if I'm wrong please be patient. If you want to know the real differences maybe is better to search online for a begginer guide to C++.

C++ is younger than C and seems to be a superset but is not (actually I think is not a complete mature language and the standarization was in 1999). Sometimes is possible to compile C code like C++ code (but requires knowledge about the differences between languages). I learned C first and honestly can't find a good reason to program with C++, I think is just a matter of preference or hype.

C++ seems to be more strict than C because you need to declare (variables, classes, functions, etc) and initialize (pointers, classes) almost everything. While writing functions in your program you MUST write the prototype while in C you do this only if you want (to be formal). C++ use classes (complex data structures) and C has the same but with the name of structures. I understand not all the data types (one or two) in both languages are the same (or have the same name). C++ uses namespaces and the STL while C doesn't know what is this. The worst point to me while making the switch was to understand pointers, in both languages are very similar but different enough to confuse you and make you (and the compiler) cry, and LW use pointers a lot.

Maybe one reason to use C++ is the fact that many programmers use as the language of choice, so if you want to develop a plug-in or maintain the code of the program...

Lightwave is one of the few common 3D programs I know who are programmed with C (Blender is another example). Maya and RenderMan use C++. Then a language doesn't limit a program to admit plug-ins. I find easier to program plug-ins in LW than Maya.

Karl Hansson
03-10-2003, 07:44 AM
Is it harder to write c++ plugins for LW (which is c) than to write c plugins for it?

03-10-2003, 06:52 PM
Hi folks. Just wanted to jump in with my $.02.

I'm a software developer and I've programmed in both C and C++ (got a gig doing Java right now). In my experience, learning C is a great place to start, as C++ is in fact a superset of C. I remember reading somewhere that C++'s creator, Bjarne Stroustrop (yipes I probably butchered the spelling of his name), initially described C++ as "C with classes".

IMHO, the power of C++ is in the fact that it's "object oriented", which is a beautiful thing once you become a convert. You can actually write what are essentially C programs using C++, but if you don't keep an object-oriented philosophy in mind when you code, you'll never really take advantage of what C++ has to offer.

I would suggest that anyone starting out in programming begin with C. When you get to the part about pointers, pay close attention. When you get to the part about "abstract data types" and structures, hopefully, you'll think "hmmm, this is pretty neat + useful." (Among other things) C++ takes the concept of structures to another level (classes) and makes things even MORE neat + useful.

Also, if you're just starting out, spend time on the basic concepts until you're extremely comfortable with them...it will pay off later.


03-10-2003, 09:21 PM
pasghetti, thanks for the tip... actually, i tried learning C++, and something just didnt click.. all i wanted was to program lightwave and C was all that was required. i was hoping that C, and books that teach it, were more easy on me. :D

it should be also pointed out that lscript is in many ways "object-oriented" as well.

Karl Hansson
03-11-2003, 12:03 AM
Thanks guys. What does "objec oriented" mean?

03-11-2003, 03:22 AM
Originally posted by Karl Hansson
Thanks guys. What does "objec oriented" mean?

in layman's definition (because i am layman), "object oriented" means that the program is run off Objects. objects are like 'super variables' or 'super functions'.

in lscript, for instance:

selected = Scene().firstSelect();

the Object there is Scene(). Scene() is like a container full of variables and functions. firstSelect() is one such function that is contained in the Scene() object. in this case, firstSelect() gets the first selected object in layout.

curtime = Scene().currenttime;

in this one, currenttime is a variable inside Scene().

when you refer to variables inside an Object, you say it is a data member. when it is a function, you call it a method.

03-14-2003, 06:34 PM
One of the best books on C++ is Bruce Eckel's Thinking in C++, which happens to be freely available at Bruce's site (http://mindview.net/). It is designed for a C programmer, but the print edition includes Thinking in C (which I have not read).

To weigh in on the C vs. C++ debate, I don't think it really matters. C is frustrating for a beginner, especially if you have any experience with a high-level scripting language. Once you've used a language with strings, associative arrays, and garbage collection, C's pointers and arrays will seem like flint and steel. On the other hand, you won't fully understand C++ until you understand C. In fact, Thinking in C++ gave me a better understanding of C.

Another good C book is Expert C Programming, which explains why 31 Oct and 25 Dec are one and the same. A good book on programming, in general, is Code Complete, although it would benefit from a second edition.

I'm hard pressed to recommend a single resource on object-oriented programming. C++, Java, Python, Perl, and even UnrealScript all support object-oriented programming.

One of my first exposures to programming was entering machine language games on the Commodore 64 from magazines. After staring at a page full of hexadecimal numbers, I figured that programming must be horribly tedious. Then I learned about higher level languages, abstract data types, and object-oriented programming.

I got kind of the same feeling following through a tutorial on box modeling. The thought of placing thousands of points with a mouse reminded me of pages full of machine language. Instead, bevel here, extrude there, subdivide, and voila, a dumpy looking character! Okay, so I have a lot to learn.

03-14-2003, 07:44 PM
I remember Commodore and Ahoy! magazines. All the programs with confirmation code at the end of every line.