Circle Drawing Weland Plugin

Questions about the content creation procedure go here, including using Forge, Anvil, or other editors, or operating emulators like Basilisk II.
Post Reply
User avatar
jonny
Born on Board
Posts: 57
Joined: May 3rd '13, 16:39

I've written a plugin for Weland which will draw circles to your specifications. You specify the center, radius and number of lines (either directly, or by specifying the length of each arc segment or the angle of each arc), et voilà, you get a circle of points with all the lines connecting them. It should interact with existing lines as you'd expect, but there may be some cases I didn't think of, and at least one case (one of the circle points falls at the intersection of two lines that aren't already connected) where the correct behavior is not at all obvious.

At the moment, that's all it does, but I might add to it in the near future if there's interest. Some possible added features would be filling the interior of the circle, drawing multiple concentric circles and optionally connecting their corresponding points (creating a ring), and drawing other shapes.

Comments, questions, suggestions, and bugs reports welcome.

[EDIT]Something important I forgot to mention. There's an odd bug that causes the circle not to appear right away. It's there, but the window isn't redrawn for some reason. Clicking with the select tool or zooming or just about anything else will get the window to redraw and the circle will appear.

[EDIT-2] Updated to specify start and end angle. Arcs > 360 degrees possible.

[EDIT-3]
Installation notes: There are three files included in the zip file. Put CirclePlugin.dll in the Weland Plugins directory before launching Weland. CirclePlugin.cs and CirclePlugin.glade are the source code files, included for anyone interested in writing their own plugins. Note this was the first code I've written in C# (and, by extension, for Mono), so it may not be the best example of how to do it. Notably, it uses GladeXML, which was deprecated by the GNOME group years ago, but Mono still doesn't have documentation for Gtk.Builder.

Usage notes: The center and radius parameters are specified in AlephOne's internal units of 1/1024 of a World Unit. Angles are specified in degrees as real numbers (decimals allowed). The last parameter specifies how many lines are used to draw the circle. Use the popup menu to select how you want to specify this. '# Arcs' directly specifies the number of lines, 'Arc Length' specifies the length of each line and computes the number based on that, and 'Arc Angle' specifies the angle subtended by each arc. Using 'Arc Angle' is really no different than '# Arcs' (number of lines = (EndAngle - StartAngle) / ArcAngle), but maybe some folks would rather use that. It's also a little helpful if you want to draw more than 360 degrees for making sure that end points don't fall on top of each other. In that case, just make sure that your arc angle does not divide evenly into 360.

[EDIT 4] Updated attachment to v1.1. Selecting a point before running plugin will preset parameters with that point as the center of the circle. Selecting a line before running plugin will preset parameters to use that line as diameter.
Attachments
CirclePlugin.zip
(9.19 KiB) Downloaded 338 times
Last edited by jonny on Jun 17th '13, 16:17, edited 3 times in total.
Look out - he's nuts!
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

jonny wrote:[EDIT] Something important I forgot to mention. There's an odd bug that causes the circle not to appear right away. It's there, but the window isn't redrawn for some reason. Clicking with the select tool or zooming or just about anything else will get the window to redraw and the circle will appear.
EDIT: fixed in Weland 1.4.1

Nice plugin!
User avatar
Crater Creator
Vidmaster
Posts: 943
Joined: Feb 29th '08, 03:54
Contact:

Nifty! Thanks for the contribution.
User avatar
PerseusSpartacus
Mjolnir Mark IV
Posts: 334
Joined: Apr 30th '12, 05:03
Location: Somewhere in the 19th Century...

I've never used Plugins for Weland before, so I don't really know how to add a Plugin to the list. I know there's a 'Plugins' folder inside my Weland folder, but what do I do with the actual Plugin?
User avatar
Zott
Vidmaster
Posts: 1666
Joined: Jul 1st '06, 21:14
Location: Earth
Contact:

* Installing Plugins

You can install Weland plugins in one of two places. The easiest is to
put them (the glade and .dll files in this case), in a Plugins directory in the same directory as Weland.

You can also install them in a Plugins directory in Weland's
application data directory:

Windows: C:\Documents and Settings\Weland\Application Data\Plugins
Mac OS X: /Users/<username>/.config/Weland/Plugins
Linux: ~/.config/Weland/Plugins
After installation you can access the plugin by starting Weland clicking the Plugin menu and choosing the appropriate plugin.
Last edited by Zott on Jun 6th '13, 01:18, edited 1 time in total.
User avatar
PerseusSpartacus
Mjolnir Mark IV
Posts: 334
Joined: Apr 30th '12, 05:03
Location: Somewhere in the 19th Century...

Zott wrote:
* Installing Plugins

You can install Weland plugins in one of two places. The easiest is to
put them (the glade and .dd files in this case), in a Plugins directory in the same directory as Weland.

You can also install them in a Plugins directory in Weland's
application data directory:

Windows: C:\Documents and Settings\Weland\Application Data\Plugins
Mac OS X: /Users/<username>/.config/Weland/Plugins
Linux: ~/.config/Weland/Plugins
After installation you can access the plugin by starting Weland clicking the Plugin menu and choosing the appropriate plugin.
(Note that I am using Mac OS X)

I've tried putting the .dll, .cs, and .glade files all inside the Plugins directory in my Weland folder. Nothing. I also cannot find the other directory you're referring to (the /Users/<username>/.config/Weland/Plugins directory).
User avatar
jonny
Born on Board
Posts: 57
Joined: May 3rd '13, 16:39

I guess I should have put some notes about installation in the first post. Sorry bout that.
PerseusSpartacus wrote:(Note that I am using Mac OS X)
Which version? Assuming Weland is working at all, I don't think it matters, but it can't hurt to include more info. I'm using 10.6.8, and it definitely works for me.
PerseusSpartacus wrote:I've tried putting the .dll, .cs, and .glade files all inside the Plugins directory in my Weland folder. Nothing.


You don't need the .cs and .glade files. That's the source code, which I included in the download in case anyone was interested. Just put the CirclePlugin.dll file into the Plugins directory under your Weland directory. (Which it seems you have done.) Also, Weland only loads plugins at launch, so if you already had it running when you put the .dll file into the Plugins folder, it wouldn't show up. Make sure it's there before launching Weland. The next time you run Weland, the Plugins menu should have an entry named 'Draw Circle'. Click that menu item and you'll be presented with a simple little dialog to select the parameters for the circle. I would like to have created an actual draw tool (like the line tool), but I'm pretty sure that's impossible for a plugin.

The parameters for the circle are: the coordinates of the center of the circle, the radius, the start and end angles, and the number of 'arcs' or lines used to draw the circle. The center and radius parameters are in Internal units, i.e., 1/1024 of a WU. The angles are real numbers in degrees. The last item has a pop up menu to let you determine the number of arcs in three different ways. The default is just to specify the number of lines directly, or you can specify the length of each line in internal units (which is really more of an approximation due to rounding, but it should be an upper bound in any case), or you can specify the angle subtended by each arc, again in degrees. That last option is really no different than the first if you think about it, so I may take that out if and when I upload a new version. The start and end angle parameters allow you to draw only part of a circle, or even more than one full circle. The angles increase counterclockwise from east, which is the reverse of how Weland usually handles angles, but how the rest of the world does it. So, if you specify a start angle of 45 and end angle of 135, you'll get the top quarter of a circle.

PerseusSpartacus wrote:I also cannot find the other directory you're referring to (the /Users/<username>/.config/Weland/Plugins directory).
That won't show up in the Finder. You need to use the terminal to access files and directories whose name starts with a '.', and even then you won't see 'dot files' unless you use the '-a' or '-A' option with ls.
Look out - he's nuts!
User avatar
jonny
Born on Board
Posts: 57
Joined: May 3rd '13, 16:39

treellama wrote:
jonny wrote:There's an odd bug that causes the circle not to appear right away.
EDIT: fixed in Weland 1.4.1
I'm not sure how I missed AddDirty(Point). I'll add that to my code, and you can remove the extra Redraw() if you want.
Look out - he's nuts!
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

Plugins shouldn't need to worry about dirty redraws, that's only in there to make scrolling and dragging tolerable. Since that can't happen while plugins are running, a full Redraw() when the plugin completes makes more sense.
User avatar
PerseusSpartacus
Mjolnir Mark IV
Posts: 334
Joined: Apr 30th '12, 05:03
Location: Somewhere in the 19th Century...

jonny wrote:Which version? Assuming Weland is working at all, I don't think it matters, but it can't hurt to include more info. I'm using 10.6.8, and it definitely works for me.
I'm using 10.6 and everything in Weland works for me (except for applying floor and ceiling textures, which crashes Weland every time, at least on the computer I'm using right now).
jonny wrote:You don't need the .cs and .glade files. That's the source code, which I included in the download in case anyone was interested. Just put the CirclePlugin.dll file into the Plugins directory under your Weland directory. (Which it seems you have done.) Also, Weland only loads plugins at launch, so if you already had it running when you put the .dll file into the Plugins folder, it wouldn't show up. Make sure it's there before launching Weland. The next time you run Weland, the Plugins menu should have an entry named 'Draw Circle'. Click that menu item and you'll be presented with a simple little dialog to select the parameters for the circle. I would like to have created an actual draw tool (like the line tool), but I'm pretty sure that's impossible for a plugin.
I put the .dll file in the Plugins directory, but nothing happens, even though I started up Weland after I put it in. The only things that show up in the Plugins menu are 'Enumerate Tags' and 'Auto Shade Level', which I think are default Plugins for Weland.
jonny wrote:The parameters for the circle are: the coordinates of the center of the circle, the radius, the start and end angles, and the number of 'arcs' or lines used to draw the circle. The center and radius parameters are in Internal units, i.e., 1/1024 of a WU. The angles are real numbers in degrees. The last item has a pop up menu to let you determine the number of arcs in three different ways. The default is just to specify the number of lines directly, or you can specify the length of each line in internal units (which is really more of an approximation due to rounding, but it should be an upper bound in any case), or you can specify the angle subtended by each arc, again in degrees. That last option is really no different than the first if you think about it, so I may take that out if and when I upload a new version. The start and end angle parameters allow you to draw only part of a circle, or even more than one full circle. The angles increase counterclockwise from east, which is the reverse of how Weland usually handles angles, but how the rest of the world does it. So, if you specify a start angle of 45 and end angle of 135, you'll get the top quarter of a circle.
Thanks. If I actually get this Plugin working, this should help a lot.
User avatar
jonny
Born on Board
Posts: 57
Joined: May 3rd '13, 16:39

@treellama - Ok. I just realized AddDirty isn't public anyway. I still don't understand how Wrk's StairGenerator managed to get a redraw done (before 1.4.1). Also, I was thinking it would have been neat to force a dirty redraw after each line - like an invisible hand drawing the circle before your eyes. :) But that's just unnecessary eye-candy.

@PerseusSpartacus - I'm not sure what to tell you. What version of Weland are you running? What about Mono? Perhaps you are running an older version of either or both of those? You can check the version of Weland with Get Info from the Finder. To check the version of Mono, open up the Terminal app and type "mono --version". Alternately, you can look in /Library/Frameworks/Mono.framework/Versions, and there will be one or more folders with a version number, and an alias named 'Current'. That alias should point to the highest numbered version among the numbered folders. You can get the latest version of Weland here, and the latest version of Mono here.
Look out - he's nuts!
User avatar
Wrkncacnter
Vidmaster
Posts: 1953
Joined: Jan 29th '06, 03:51
Contact:

jonny wrote:@treellama - I still don't understand how Wrk's StairGenerator managed to get a redraw done (before 1.4.1).
I'm sure there's some hack TL told me to do. I don't remember what it was, but I remember having the problem. The source code for it should be included in the download, so you should be able to find out what I did.

Also, only half the people could get my plugins working as well, so it's not just yours.
User avatar
jonny
Born on Board
Posts: 57
Joined: May 3rd '13, 16:39

Wrkncacnter wrote:
jonny wrote:@treellama - I still don't understand how Wrk's StairGenerator managed to get a redraw done (before 1.4.1).
I'm sure there's some hack TL told me to do. I don't remember what it was, but I remember having the problem. The source code for it should be included in the download, so you should be able to find out what I did.
I checked and didn't see anything special you did to get a redraw.
Wrkncacnter wrote:Also, only half the people could get my plugins working as well, so it's not just yours.
I had to recompile yours against the latest version of Weland and Mono before it would work.
Look out - he's nuts!
User avatar
Wrkncacnter
Vidmaster
Posts: 1953
Joined: Jan 29th '06, 03:51
Contact:

OK, but people couldn't get it working way back when I did it either. I think there might be some 32/64 bit issue?
User avatar
PerseusSpartacus
Mjolnir Mark IV
Posts: 334
Joined: Apr 30th '12, 05:03
Location: Somewhere in the 19th Century...

jonny wrote:@PerseusSpartacus - I'm not sure what to tell you. What version of Weland are you running? What about Mono? Perhaps you are running an older version of either or both of those? You can check the version of Weland with Get Info from the Finder. To check the version of Mono, open up the Terminal app and type "mono --version". Alternately, you can look in /Library/Frameworks/Mono.framework/Versions, and there will be one or more folders with a version number, and an alias named 'Current'. That alias should point to the highest numbered version among the numbered folders. You can get the latest version of Weland here, and the latest version of Mono here.
I currently am using v1.4 of Weland and v2.10.9 of Mono. Not sure if those are the most recent or not.
User avatar
Wrkncacnter
Vidmaster
Posts: 1953
Joined: Jan 29th '06, 03:51
Contact:

Hmm, I looked through chat logs and I see where I'm asking how to make it redraw the screen, but I didn't find any answer. Are you sure mine actually worked?
User avatar
PerseusSpartacus
Mjolnir Mark IV
Posts: 334
Joined: Apr 30th '12, 05:03
Location: Somewhere in the 19th Century...

Just downloaded the version on Simplici7y, but I'm still having the same issue. I copied the CirclePlugin.dll file into my weland-1.4 => Plugins directory, but when I open up Weland and look under the 'Plugins' menu, all I see are 'Enumerate Tags' and 'Auto Shade Level'. What could possibly be going wrong?
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

Get the latest Weland.
User avatar
jonny
Born on Board
Posts: 57
Joined: May 3rd '13, 16:39

@Wrkncacnter - No, I'm not certain it was doing the redraw. Seems like it did, but doesn't really matter now.

@PerseusSpartacus - I'm sorry I really have no idea why it wouldn't be working. Pardon me if this is stupid question, but.... You're not running the Weland app from a mounted dmg file, are you? (I doubt you'd be able to copy the dll file into the Plugins directory if you were.) In other words, have you copied the Weland application to your local hard drive?

Other than that, or trying to put the dll file into your user specific Weland directory (see Zott's comment above re: /Users/<username>/.config/Weland/Plugins), the only thing I can think of at this point is to download and install the latest versions of Mono and Weland (links above). Re-installing Mono will create a new version of the Framework and should update all the appropriate links in /Library/Frameworks. You may want to delete the previous version of Weland (or at least move/rename it), but that shouldn't make a difference either way. I'm not terribly confident updating to the latest versions will help, but it might be worth a shot.
Look out - he's nuts!
User avatar
Chocolateer
Born on Board
Posts: 34
Joined: Jul 4th '11, 20:28
Contact:

jonny wrote:I would like to have created an actual draw tool (like the line tool), but I'm pretty sure that's impossible for a plugin.
I suppose the next best thing would be to have the plugin check which line is selected when the plugin is run, and to use the two points of that line as reference points to create the circle. If the two reference points represented diametrically opposed points on the circle then it would have to have an even number of arcs for them to line up correctly. Alternately, having the reference points represent the center and an end point of the circle would be doable too, but it could be tricky specifying which point is the center and which is the end point.
User avatar
PerseusSpartacus
Mjolnir Mark IV
Posts: 334
Joined: Apr 30th '12, 05:03
Location: Somewhere in the 19th Century...

treellama wrote:Get the latest Weland.
Free at last, free at last! Thank god almighty, I'm free at last! ;)

I just downloaded v1.4.1 of Weland, and now it works. I can't wait to start messing with it. With this tool, I think pretty much anyone will now have the power to recreate The Ascension Factor and then some.
User avatar
jonny
Born on Board
Posts: 57
Joined: May 3rd '13, 16:39

@Chocolateer - That's an interesting idea. I think I can add that rather easily. If a line is selected, I can use that to fill in the x, y, and radius parameters. Sounds useful. I'll look into it this weekend.

@PerseusSpartacus - Good news and glad you like it. Interesting comment about The Ascension Factor, because you can definitely use it to draw more than 360 degrees. I was just thinking about its usefulness in creating spiral staircases. Just make sure that you use arc angles that won't evenly divide into 360. And if you like this plugin, you're going to love the next one. B)
Look out - he's nuts!
User avatar
jonny
Born on Board
Posts: 57
Joined: May 3rd '13, 16:39

Chocolateer wrote:have the plugin check which line is selected when the plugin is run, and to use the two points of that line as reference points to create the circle.
Just uploaded v1.1 to Simplici7y. This version will preset the parameters to use a selected point as the center, or a selected line as the diameter.
Look out - he's nuts!
User avatar
PerseusSpartacus
Mjolnir Mark IV
Posts: 334
Joined: Apr 30th '12, 05:03
Location: Somewhere in the 19th Century...

I've been working on a map for Marathon: Grendel recently (meant to be the final level of the game, in fact) making heavy use of this plugin. The results thus far have been impressive to say the least. Here's a picture of the map so far in Weland:
Screen shot 2013-06-17 at 4.40.55 PM.png
As you can see, with this plugin and a little effort and imagination, you can make something almost worthy of a major Total Conversion. And I haven't even yet downloaded v1.1!

I tip my hat to you, sir, for making the most powerful tool in my arsenal thus far. ;)
User avatar
Ares Ex Machina
Mjolnir Mark IV
Posts: 614
Joined: Jan 23rd '08, 08:07
Contact:

I finally got a chance to try this out today. Awesome plugin!
Post Reply