PDA

View Full Version : Draw a 30* Cone Pointer - Looking for some help.



ShotGun Jolly
December 12th, 2014, 19:43
Guys.. I can really use the help with some XML coding for my Back Crusade ruleset.. I really need to get that 30* cone (pointer) to show up. But I can not get it to appear like it should...

I have followed the excellent instructions from Dulux-Oz in his tutorial; on how to do it. But I can not figure out why I can not get it to appear when I draw it on the map. I can get everything else to work, it shows range, the two points when you draw it and rotate it, but not the actual cone!

Anyone willing to try and help me figure it out???? Please?

Trust me, its not for lack of trying.. but there is something I am missing and I can not get it to work. :(

Jolly

ShotGun Jolly
December 12th, 2014, 21:40
Ok..

Here is the problem that I can not solve..

I have added my custom cone to the radial menu, I can select it and I can draw it. In the below picture, you can see all of the other pointers which I can draw, (Circle, 45* Cone, and Line) Now, look at my mouse, where my mouse is currently resting, you can see one of two small squares.. this is my 30* which I drew. As you can see, there is no outline, just the start and finish points. And that only appears when I mouse over it.

8266

Here is the campaign_Images.XML which I needed to edit to allow the pointers to show up.


<imagecontrol name="image">
<script file="My_Cone.lua" />
<pointertypes>
<arrow>
<icon>pointer</icon>
<label>Draw Arrow</label>
</arrow>
<circle>
<icon>pointer_circle</icon>
<label>Draw Circle</label>
</circle>
<cone>
<icon>pointer_cone</icon>
<label>Draw Cone</label>
</cone>
<custom name="30ConePointer">
<icon>pointer_cone</icon>
<label>Draw a 30-Degree Cone</label>
</custom>
</pointertypes>

And here is the My_Cone.lua which I had to make so the above code could link to it.


function onBuildCustomPointer(nStartXCoord,nStartYCoord,nEn dXCoord,nEndYCoord,sPointerType)
local nLength = math.sqrt((nEndXCoord-nStartXCoord)^2+(nEndYCoord-nStartYCoord)^2);
if nLength == 0 then
return
end
local aShapeCurves = {};
local aDistLabelPosition = {25,25};
local bDrawArrow = false;
local nAngleRadians = math.atan2(nEndXCoord-nStartXCoord,nStartYCoord-nEndYCoord);
-- Call the relevant Pointer Definition Function
if sPointerType == "30ConePointer" then
fpConePointer(aShapeCurves,nLength,30);
end
-- Rotate and Position the Pointer
for nIndex,aCurve in ipairs(aShapeCurves) do
for nPointIndex,aPoint in ipairs(aCurve) do
local nXCoord = aPoint[1]*math.cos(nAngleRadians)-aPoint[2]*math.sin(nAngleRadians)+nStartXCoord;
local nYCoord = aPoint[1]*math.sin(nAngleRadians)+aPoint[2]*math.cos(nAngleRadians)+nStartYCoord;
aCurve[nPointIndex] = {nXCoord,nYCoord};
end
end
return aShapeCurves,aDistLabelPosition,bDrawArrow;
end

What am I doing wrong which causes my custom cone not to appear?

darrenan
December 13th, 2014, 00:44
I know absolutely nothing about the custom drawing stuff, so this may be a total stab in the dark, but could it be the line "local bDrawArrow=false" ? Should that be set to true somewhere?

Trenloe
December 13th, 2014, 01:09
EDIT: Ignore previous info in this post...

I take it you're trying to do something along the lines of this post: https://www.fantasygrounds.com/forums/showthread.php?8971-2-2-0-Feature-Custom-Pointers

If so, this is suggesting that you need to subtract a centerx value from aPoint[1] and subtract a centery value from aPoint[2] in the calculations.

ShotGun Jolly
December 13th, 2014, 01:32
Tried both suggestions, even before Trenloe changed his first suggestion.. ;-)

Neither made any change at all, no matter what:confused:

damned
December 13th, 2014, 01:49
when you get this working - could I make a suggestion/request? great! thanks :) could you package the pointer up as a standalone extension too (if possible) so that people can learn from your learns :) or at least just reuse your damn pointer.

ShotGun Jolly
December 13th, 2014, 02:02
when you get this working - could I make a suggestion/request? great! thanks :) could you package the pointer up as a standalone extension too (if possible) so that people can learn from your learns :) or at least just reuse your damn pointer.

When I get this working, would you show me how to make said extension? As I have no idea how to do that. :p

Besides, with the collective power of the internet on our sides.. I am hoping to solve this, and world hunger in the next few days.. :)

dulux-oz
December 13th, 2014, 02:21
OK, first off you're missing a function - where in your code is the fpConePointer() function?

And, obviously, the functions called by fpConePointer()?


Secondly, I don't think its going to be possible to put this into an Extension, mainly because you have to override other Pointer drawing code and therefore "stuff up" those other Pointers - mind you, if you prove me wrong then I'll take my hat off to you. :)

Cheers

dulux-oz
December 13th, 2014, 02:27
when you get this working - could I make a suggestion/request? great! thanks :) could you package the pointer up as a standalone extension too (if possible) so that people can learn from your learns :) or at least just reuse your damn pointer.

damned => its all in my Pointer Toolkit (on the Wiki and in the Thread on the Forums). Yes, its not the easiest thing in the world to do, but if you read through the doco (RTFM) you shouldn't have that much trouble - and you can always ask me (or others) questions.

I mean, that's why I made the damn thing :)

Cheers

Trenloe
December 13th, 2014, 03:00
damned => its all in my Pointer Toolkit (on the Wiki and in the Thread on the Forums).
Just need to go through your final code and change the multiplication symbols x to * so that it works in FG! :p

Extension attached to do add a 30 degree cone to the CoreRPG ruleset. Thanks to dulux_oz for the code (even without the *s). :D

dulux-oz
December 13th, 2014, 03:09
Just need to go through your final code and change the multiplication symbols x to * so that it works in FG! :p

Extension attached to do add a 30 degree cone to the CoreRPG ruleset. Thanks to dulux_oz for the code (even without the *s). :D

Yeah, well, if you pull the code straight off the Wiki, of course. The Wiki doesn't like "*" so I had to use the old fashioned "x" instead :p

Nice Extension, BTW. It still doesn't invalidate my previous post - it'll still overwrite other Pointer code - still, used by itself it should be OK :)

Cheers

Trenloe
December 13th, 2014, 03:37
It still doesn't invalidate my previous post - it'll still overwrite other Pointer code - still, used by itself it should be OK :)
Can you expand on that please? Not sure what other pointer code this would be overwriting?

dulux-oz
December 13th, 2014, 03:50
Can you expand on that please? Not sure what other pointer code this would be overwriting?

Well, you can only have a maximum of 5 Pointers (that's an FG Limit, not one of mine), so if you had two extensions, one with the 30-Degree Cone and one with another Custom Pointer, some Pointer Code has to give, either one of the Custom Pointers or one of the "Standard" Pointers.

Just to be clear, I wasn't saying that from a technical POV it was impossible, just that we need to be aware that there are "political" limitations on this - its the same type of thing when two different Rulesets or Extensions both modify the same template, etc - something has to "win" and something has to "lose".

I think that's clearer - I hope so :)

Cheers

Trenloe
December 13th, 2014, 03:57
Thanks, so it's the usual extension issues of being aware of other rulesets and/or extensions that might be trying to do something similar. There's nothing special with this pointer code that would stop it being used in an extension - which is not what I thought you were saying when you said "I don't think its going to be possible to put this into an Extension..." Thanks for clarifying.

dulux-oz
December 13th, 2014, 04:28
Thanks, so it's the usual extension issues of being aware of other rulesets and/or extensions that might be trying to do something similar. There's nothing special with this pointer code that would stop it being used in an extension - which is not what I thought you were saying when you said "I don't think its going to be possible to put this into an Extension..." Thanks for clarifying.

No, there's nothing special about the code, its just the usual code conflicts we have to worry about - as you said :)

Sorry if what I said was confusing.

Cheers

damned
December 13th, 2014, 04:33
Thanks Dulux and Trenloe and Jolly.

Dulux - the reason I suggested the extension was despite your beautiful tutotial Shotgun wasnt the first person to struggle to implement the new pointer.
Trenloe - works beautifully
Shotgun - check out the extension and you will see that the extension bit is the easy bit - coding it in the first place is f@#$ing hard bit

dulux-oz
December 13th, 2014, 05:14
Dulux - the reason I suggested the extension was despite your beautiful tutotial Shotgun wasnt the first person to struggle to implement the new pointer.

Yeah, Pointers are definitely an "advanced" topic - I've often wondered if I wasn't doing more harm than good by producing the Toolkit - you know, encouraging people to swim the English Channel when they were really only ready to swim the 1500m. God knows I struggled for days/weeks putting the damn thing together (which I did, primarily, for myself). Oh well, if people find it useful (& they don't drown in the process) :)

Cheers

Blackfoot
December 13th, 2014, 05:22
Hmm.. this sounds like just what I would need to do 30 degree cones in my Champions Ruleset.. I never could quite understand how all of Dulox explanations and code worked/fit into things.
When I dropped the above .ext into the extensions folder though my FG doesn't see it... it's based in CoreRPG right.. so it 'should' work with mine.. hrm.

Trenloe
December 13th, 2014, 05:30
When I dropped the above .ext into the extensions folder though my FG doesn't see it... it's based in CoreRPG right.. so it 'should' work with mine.. hrm.
I only tagged it for the CoreRPG ruleset. Change the ruleset tag for your ruleset.

Blackfoot
December 13th, 2014, 05:31
Since my ruleset inherits CoreRPG shouldn't CoreRPG extensions work with it?
There are other random ones that seem to work.

That did resolve it though.

Trenloe
December 13th, 2014, 05:35
Since my ruleset inherits CoreRPG shouldn't CoreRPG extensions work with it?
There are other random ones that seem to work.
The <ruleset> tag has to specifically list the ruleset name that is being used - not what it may be layered on top of.

If there is no <ruleset> tag in extension.xml then any ruleset can see the extensions.

Blackfoot
December 13th, 2014, 05:39
Hrm.. getting the same thing Shotgun was showing below.. end points without lines.

dulux-oz
December 13th, 2014, 05:40
I never could quite understand how all of Dulox explanations and code worked/fit into things.

OK, so what I'm hearing is that the Toolkit Doco/Tute needs some work - I'll add it to the list of things I need to do. After all, if people can't understand it then what use is it :)

Cheers

Trenloe
December 13th, 2014, 05:52
Hrm.. getting the same thing Shotgun was showing below.. end points without lines.
Try it in a base CoreRPG campaign and see if it works there.

Blackfoot
December 13th, 2014, 06:09
Ahh.. I figured out my issue. It's bumping into that VertexSnap Extension you helped me with a while back Trenloe. Gonna need to combine the two in order for this to work right... looks like I actually need 60 degree cones and not 30 as well. .. A few steps closer here though.. thanks guys.

Trenloe
December 13th, 2014, 06:13
looks like I actually need 60 degree cones and not 30 as well. .. A few steps closer here though.. thanks guys.
I included all of dulux_oz's specifications, which includes 60ConePointer - change the <custom name="30ConePointer"> tag in the extension.xml file to <custom name="60ConePointer">

Blackfoot
December 13th, 2014, 06:14
I had just noticed that.. and it worked!

Trenloe
December 13th, 2014, 06:18
I had just noticed that.. and it worked!
Nice! :)

ShotGun Jolly
December 13th, 2014, 08:15
I have been, err celebrating most of the night and I just got back and I saw this.. I figured out right away I had the change the name of the extension to match what I need it. But I still got the same problem. That being said, I see there could be a issue with conflicting extensions based on what I just read.. I will play around a bit when I wake up.


I REALLY do appreciate everyone's help so far.. Thanks.. I hope to have this solved in the next few days! You guys are great!

Blackfoot
December 13th, 2014, 08:19
Not meaning to hijack the thread ... but .. How crazy would it be to do a 'Hex Shaped' pointer? Or a 'Triangle' instead of a fanned cone?

OK.. so the radius at the center of the equilateral triangle (b) would be = the squareroot of ((c*c)-((c/2)*(c/2))) where (c) is the length of a side.. (a) is half a side.. and (b) is the line that bisects the triangle.

This is also true for the hex.. the radius of the hex is the same..

dulux-oz
December 13th, 2014, 12:29
Not meaning to hijack the thread ... but .. How crazy would it be to do a 'Hex Shaped' pointer? Or a 'Triangle' instead of a fanned cone?

OK.. so the radius at the center of the equilateral triangle (b) would be = the squareroot of ((c*c)-((c/2)*(c/2))) where (c) is the length of a side.. (a) is half a side.. and (b) is the line that bisects the triangle.

This is also true for the hex.. the radius of the hex is the same..

It wouldn't be hard at all - actually, its easier than a cone because there's no curve to worry about.

Just call the fpLine() function (or whatever I've called the damn thing) six times instead of four to draw each line - you've only got to work out the six vertex co-ordinate pairs. Use the square pointer as a base to get you started.

Having said that, when I was playing around developing the Toolkit I created a Hex Pointer and found that the difference between it and the regular Circle Pointer was effectively nothing - so I decided to not bother with a Hex Pointer and use the Circle Pointer instead.

Still, if you want to have a go and need to ask some questions, go ahead.

On a related note, Tren and/or Blackfoot, could I please have a look at the Vertex Extension you mentioned a few posts back - thanks.

Cheers

ShotGun Jolly
December 13th, 2014, 14:21
Just need to go through your final code and change the multiplication symbols x to * so that it works in FG! :p

Extension attached to do add a 30 degree cone to the CoreRPG ruleset. Thanks to dulux_oz for the code (even without the *s). :D

Hey Trenloe, I got it working after. It was indeed a conflict with one of the other extensions I had in the folder. When I removed all the other extensions, I was then able to get it to work!!

Thanks so much!!! Thanks go to everyone for helping with this!!!

ShotGun Jolly
December 13th, 2014, 15:19
Ahh.. I figured out my issue. It's bumping into that VertexSnap Extension you helped me with a while back Trenloe. Gonna need to combine the two in order for this to work right... looks like I actually need 60 degree cones and not 30 as well. .. A few steps closer here though.. thanks guys.

I was having a similar conflict, but it is with the "Enhanced Images Ext" for CORE. If I turn Enhanced on, it over rides the cone extension.

Blackfoot
December 13th, 2014, 17:52
I have issues with the extension working consistently... there's something with the hex vertexes that makes them flaky. but here's what I have.
It is for my custom ruleset so it might be a bit off for other stuff.

Is the equilateral triangle option tricky to pull off? It too seems like just a matter of removing the curve from a cone... although it won't work like the square since it shouldn't use the center as a focal point.

dulux-oz
December 14th, 2014, 03:47
I have issues with the extension working consistently... there's something with the hex vertexes that makes them flaky. but here's what I have.
It is for my custom ruleset so it might be a bit off for other stuff.

Is the equilateral triangle option tricky to pull off? It too seems like just a matter of removing the curve from a cone... although it won't work like the square since it shouldn't use the center as a focal point.

No, just use the endpoints of the two Cone Sides as the endpoints of the line that replaces Cone Curve - conceptually, at least. You'll have to calculate where those end points should be (hint: ((pointer length)/cos(30))/2) but it should be relatively easy - provided you've read and understand the documentation. :)

Incidentally, this issue you guys are having with the Cone as an Extension was what I was referring to when I said (in an earlier post) that you may not be able to put it into an Extension - I knew you guys had been playing around with the imagecontrol code and I could see the potential conflicts.

Oh, and thanks for the Hex Vertex Extension - I'll have a look see and see what's been done.

Cheers

Trenloe
December 14th, 2014, 05:02
Incidentally, this issue you guys are having with the Cone as an Extension was what I was referring to when I said (in an earlier post) that you may not be able to put it into an Extension - I knew you guys had been playing around with the imagecontrol code and I could see the potential conflicts.
The extension I produced uses the XML merge rules, so with design from the ruleset/extension developer it should be able to work together (i.e put the code in your ruleset, use extension loadorder commands or incorporate it into your own extension). For Blackfoot developing his own ruleset this shouldn't even be an issue as he *should* be defining everything he wants within his ruleset and not using an extension.

dulux-oz
December 14th, 2014, 05:41
Hi Guys,

Because I've been informed that some people are having trouble using the Pointer Toolkit I put together this post to try to make things clearer - Enjoy!

IMPORTNAT POINT No 1

Pointers can be considered an "advanced" topic in FG Coding. You NEED to FULLY read and understand the Pointer Toolkit Documentation to be able to use the Toolkit consistently and successfully. Just about all of the issues people have had with getting the Toolkit to work have stemmed from the fact that they HAVEN'T FULLY read and/or understood the documentation (and/or they've been trying to use the Toolkit to do things it wasn't designed to do).
IMPORTNAT POINT No 2

The Pointer Toolkit is NOT designed to be used "as is" - it's a Toolkit - you take the individual tool or tools from the kit and use them in your project.
IMPORTNAT POINT No 3

The Pointer Toolkit includes some SAMPLE or EXAMPLE functions to show you how to achieve certain results. If the Sample functions are useful to use "as is", by all means use them - BUT they were designed as Examples, not as finalised code.
OK, now that we've understood these three very important points, lets get started.

FG has two types of Pointers: Standard Pointers and Custom Pointers.

The Standard Pointers are: Circle, Square, 90-Degree Cone and Arrow. Custom Pointers are Pointers we create.

We don't need to do anything to the FG Code to use the Standard Pointers, UNLESS we want to use one or more Custom Pointers in our Ruleset.

Any Ruleset can have a MAXIMUM of 5 Pointers. The 5 Pointers can be a mix of Standard and Custom Pointers.

Any Pointer is made up of Lines, Curves and Quarter-Ellipse Curves.

To draw a Line we use the fpLineCurve() function from the Toolkit and give it the Starting and Ending X- and Y-Coordinates, plus an Offset. I'll explain what the Offset does later. Most people will use an Offset of 0.

To draw a curve we can use either the fpAngleArcCurve() or the fpEndpointArcCurve() function and give them the Starting X- and Y-Coordinates of the Curve, the X- and Y-Coordinates of the Centrepoint of the Circle the Curve is a part of and either the Angle that the Curve needs to cover in Degrees (for the first function) or the Ending X- and Y-Coordinates of the Curve (for the second function). Both of these functions in turn call the fpArcCurve() function.

To draw a Quarter-Ellipse curve we can use the fpEllipseCurve() function and give it the X- and Y-Radius of the Quarter-Ellipse, plus an Offset. The "flatness" of the Quarter-Ellipse depends upon the ratio of the two Radii: if they are the same (ie 1:1) we end up with a Quarter-Circle.

So, if your Pointer has Lines you need to include the fpLineCurve(), if it has Quarter-Ellipses you need to include the fpEllipseCurve() function, and if it has Curves you need to include the fpArcCurve() function and either (or both) the fpAngleArcCurve() or the fpEndpointArcCurve() function, depending upon how you draw your curves (End-Point or Angle-of-Arc).

These four functions are called Curve Definition Functions.

OK, so How do we do this?

Well, Pointers are part of imagecontrols, so we need to modify the imagecontrol used to display maps, etc. In the CoreRPG this imagecontol is called "image" and is found starting at line 28 of the campaign/campaign_images.xml file. If we look at line 35 of this file we can see that the image imagecontrol calls a script file called image.lua in the campaign/scripts folder. So we know we need to modify these two files: we need to put the relevant functions from the Pointer Toolkit into the image.lua file and make some changes to the image imagecontrol in the campaign_images.xml file. Of course, this is just one way of accomplishing our goal - and we need to be aware that if we modify these two files the next time FG is updated the two files will be reverted back to they way they were before we changed them - some people solve this problem by putting their Custom Pointers in an Extension, but this can lead to conflicts with other Extensions that deal with the image imagecontrol.

To tell FG that we want to use Custom Pointers we need to put a <pointertypes> tag inside the image imagecontrol and a pointer tag for each Custom Pointer AND one for each Standard Pointer. The SAMPLE Code below shows a <pointertypes> tag with 5 pointer tags: one for each of the Standard Pointers and one for a Custom Pointer called "45Cone".


<imagecontrol>
<pointertypes>
<custom name="45Cone">
<icon>pointer_cone</icon>
<label>Draw a 45-Degree Cone</label>
</custom>
<arrow>
<icon>pointer</icon>
<label>Draw Arrow</label>
</arrow>
<square>
<icon>pointer_square</icon>
<label>Draw Square</label>
</square>
<circle>
<icon>pointer_circle</icon>
<label>Draw Circle</label>
</circle>
<cone>
<icon>pointer_cone</icon>
<label>Draw Cone</label>
</cone>
</pointertypes>
<!-- Other imagecontrol tags -->
</imagecontrol>

Once FG sees the <pointertypes> tag and the corresponding <custom> tag it automatically calls a function called onBuildCustomPointer() with takes the Starting and Ending X- and Y-Coordinates of the Pointer, plus a string representing the Custom Pointer name (eg "45Cone"). We don't have to worry about calling onBuildCustomPointer() with the correct values: FG takes care of this for us. We do have to tell onBuildCustomPointer() what to do, such as work out the length of the Pointer, etc, plus draw the Pointer. Obviously, onBuildCustomPointer() should go into the same file that we've placed the required Curve Definition Functions in (eg image.lua or our Extension).

The best way to draw a Pointer is have onBuildCustomPointer() call a Pointer-Drawing function, one for each Custom Pointer. These Pointer-Drawing functions also go into the file with the other functions (eg image.lua).

To draw a Pointer FG expects a table of Coordinates. The Curve Definition Functions return the correctly values in the correct format, so if our Pointer-Drawing function calls the correct Curve Definition Functions with the correct values, then we've drawn our Pointer.

The Pointer Toolkit includes 11 SAMPLE Pointer-Drawing functions and a SAMPLE onBuildCustomPointer() function to show you how to do this.

Pointers are drawn centred around the Start Point (for Circles, Squares, etc) or originating at the Start Point (for Cones and Arrows) and extending out to the End Point. Remember the Offset value used in some of the Curve Definition Functions? This causes the Line/Ellipse-Curve to "slide along" the line from the Start Point to the End Point. If you look closely at the Sample Pointer-Drawing functions you can see how this works.

So, to summarise: take the functions and Sample functions from the Toolkit and place them in a file. Link the file (if it isn't already) to the imagecontol. Tell FG to use the Custom Pointers via the <pointertypes> tag.

And have fun!

I hope this has made things clearer for everyone.

Any question, please ask.

Cheers

dulux-oz
December 14th, 2014, 05:43
The extension I produced uses the XML merge rules, so with design from the ruleset/extension developer it should be able to work together (i.e put the code in your ruleset, use extension loadorder commands or incorporate it into your own extension). For Blackfoot developing his own ruleset this shouldn't even be an issue as he *should* be defining everything he wants within his ruleset and not using an extension.

Yeap, I agree :)

Blackfoot
December 14th, 2014, 22:29
The extension I produced uses the XML merge rules, so with design from the ruleset/extension developer it should be able to work together (i.e put the code in your ruleset, use extension loadorder commands or incorporate it into your own extension). For Blackfoot developing his own ruleset this shouldn't even be an issue as he *should* be defining everything he wants within his ruleset and not using an extension.
Agreed.. i should be.. once I figure out how to mix it all together. Got to get it all working first.

Blackfoot
December 17th, 2014, 02:28
OK.. so I got the Triangle Pointer to work.. a lot of hit and miss and a few calculations that I didn't remember after almost 40 years or so...
function fpTrianglePointer(aShapeCurves,nRadius,nArcDegrees )
-- Draw a Cone with a Radius of nRadius and covering an Arc of nArcDegrees.
local nSide = math.sqrt((nRadius*nRadius)+((nRadius*nRadius)/3));
if nArcDegrees == 0 or
nArcDegrees <= -180 or
nArcDegrees >= 180 then
return;
end
local nArcRadians = math.rad(nArcDegrees);
local nXCoord = -nSide*math.sin(nArcRadians/2);
local nYCoord = nSide*math.cos(nArcRadians/2);
table.insert(aShapeCurves,fpLineCurve(0,0,nXCoord,-nYCoord,0));
table.insert(aShapeCurves,fpLineCurve(0,0,-nXCoord,-nYCoord,0));
table.insert(aShapeCurves,fpLineCurve(-nSide/2,0,nSide/2,0,nRadius));
endNow if I can figure out the Hex one.

dulux-oz
December 17th, 2014, 04:02
OK.. so I got the Triangle Pointer to work.. a lot of hit and miss and a few calculations that I didn't remember after almost 40 years or so...
function fpTrianglePointer(aShapeCurves,nRadius,nArcDegrees )
-- Draw a Cone with a Radius of nRadius and covering an Arc of nArcDegrees.
local nSide = math.sqrt((nRadius*nRadius)+((nRadius*nRadius)/3));
if nArcDegrees == 0 or
nArcDegrees <= -180 or
nArcDegrees >= 180 then
return;
end
local nArcRadians = math.rad(nArcDegrees);
local nXCoord = -nSide*math.sin(nArcRadians/2);
local nYCoord = nSide*math.cos(nArcRadians/2);
table.insert(aShapeCurves,fpLineCurve(0,0,nXCoord,-nYCoord,0));
table.insert(aShapeCurves,fpLineCurve(0,0,-nXCoord,-nYCoord,0));
table.insert(aShapeCurves,fpLineCurve(-nSide/2,0,nSide/2,0,nRadius));
endNow if I can figure out the Hex one.

Excellent! Well done.

Trenloe
December 19th, 2014, 01:31
Just as an FYI to people on this thread - the <square> pointertype for the defaults is incorrect, <rectangle> should be used for the base square pointer.

Blackfoot
February 17th, 2019, 08:59
Hrm. So a hop into the way back machine.. several years of updates later... and this stuff no longer works. :(
It doesn't look like my build a triangle code is even getting called anymore.

Has the way pointers get built changed dramatically at some point?

LordEntrails
February 17th, 2019, 15:41
Hrm. So a hop into the way back machine.. several years of updates later... and this stuff no longer works. :(
It doesn't look like my build a triangle code is even getting called anymore.

Has the way pointers get built changed dramatically at some point?
What ruleset? I know changes were made in 5E. Don't know if those come from Core or not.

Blackfoot
February 17th, 2019, 16:22
What ruleset? I know changes were made in 5E. Don't know if those come from Core or not.All CoreRPG rulesets.. I'm thinking there must have been a change to it in CoreRPG over the last 5 years.

Zacchaeus
February 17th, 2019, 21:59
All CoreRPG rulesets.. I'm thinking there must have been a change to it in CoreRPG over the last 5 years.

There was in the update for November 2016 (https://www.fantasygrounds.com/filelibrary/patchnotes.html).

Moon Wizard
February 17th, 2019, 22:06
The default cone angles can be adjusted per ruleset. Valid values are (180, 120, 90, 60, 45, 30, 5E). The 5E version is equal width/distance (~53 degrees).



<imagesettings>
<pointer defaultconeangle="30" />
</imagesettings>


If you want more than one cone, then you'll still need to write the Lua code.

Regards,
JPG

Blackfoot
February 17th, 2019, 22:15
I had this working with the old code.. I just need to figure out where to tap into it now.. I can't seem to find it.

Ultimately I'm looking for a 'triangle' instead of a cone... and a 'hexagon'.. both regular polygons.. but a 60 degree cone will do part of the job... mostly.

Add that imagesettings code to gameelements?

Blackfoot
February 17th, 2019, 22:30
The 5E version is equal width/distance (~53 degrees).
JPG
Equal width/distance is a 60 degree equilateral triangle (the thing I actually want to do) no? Or does 5e do something else...

Moon Wizard
February 18th, 2019, 00:38
5E is a cone where the width from the origin point is equal to the length from the origin point. It ends being 53.2 degrees or so. It is not the same as an equilateral triangle.

However, you can specify 60 as the default for the cone angle. If nothing specified in the ruleset, then the default cone angle is 90 degrees.

The image control will still call imagecontrol.onCustomBuildPointer for any custom pointers specified in the ruleset code.

Example of specifying custom pointers from the SavageWorlds code:



<imagecontrol>
...
<pointertypes>
<arrow>
<icon>pointer</icon>
<label>Draw Arrow</label>
</arrow>
<custom name="sw_cone">
<icon>pointer_cone</icon>
<label>Draw Cone</label>
</custom>
<custom name="sw_sb">
<icon>pointer_circle</icon>
<label>Draw Small Burst</label>
</custom>
<custom name="sw_mb">
<icon>pointer_circle</icon>
<label>Draw Medium Burst</label>
</custom>
<custom name="sw_lb">
<icon>pointer_circle</icon>
<label>Draw Large Burst</label>
</custom>
</pointertypes>
</imagecontrol>


JPG

Blackfoot
February 18th, 2019, 01:03
Hrm. That's what I had before... and it stopped working way back.. I've just gotten around to trying to fix it.
I had the whole Dulox Toolkit thing setup... and it was working for Equilateral Triangles... but.. yeah.. not since November of 2016 apparently.
It was drawing the end points but none of the lines..

Never did figure out how to make the Hexagon work though.

<windowclass name="imagewindow" merge="join">
<sheetdata>
<imagecontrol name="image">
<default snap="off" drawingsize="500,500" snaphex="vertexandcenter" gridtype="hexrow" />
<pointertypes>
<arrow>
<icon>pointer</icon>
<label>Draw Arrow</label>
</arrow>
<circle>
<icon>pointer_circle</icon>
<label>Draw Circle</label>
</circle>
<custom name="60ConePointer">
<icon>pointer_cone</icon>
<label>Draw 60-Degree Cone</label>
</custom>
<custom name="TrianglePointer">
<icon>pointer_cone</icon>
<label>Draw Triangle</label>
</custom>
<custom name="HexPointer">
<icon>pointer_circle</icon>
<label>Draw Hex</label>
</custom>
</pointertypes>
</imagecontrol>
</sheetdata>
</windowclass>I suppose now I can default 60 degrees for the cone pointer and just set that one as a standard pointer.
<cone>
<icon>pointer_cone</icon>
<label>Draw Cone</label>
</cone>I'm currently trying to figure out where it actually broke if you are telling me that the onBuildCustomPointer is still working. Hrm.

Moon Wizard
February 18th, 2019, 01:05
I'm assuming that it is all still working, as it is used for almost all the Savage Worlds pointers and I haven't heard any issues. Also, I haven't touched that code since 2016. ;)

JPG

Blackfoot
February 18th, 2019, 03:39
OK.. so I figured it out and triangles are working again. :)

Now on to Hexagons.

Blackfoot
February 18th, 2019, 05:13
OK.. so I took the one side of the Equilateral Triangle and that draws one side of the Hexagon.. all I need to do.. (in theory) is flip it around 5 more times to get the various other sides.
I could probably use a little help with the math... it's been a while.

function fpLineCurve(nStartLineXCoord,nStartLineYCoord,nEnd LineXCoord,nEndLineYCoord,nOffset)
local aCurve = {{nStartLineXCoord,nStartLineYCoord-nOffset},
{nStartLineXCoord,nStartLineYCoord-nOffset},
{nEndLineXCoord,nEndLineYCoord-nOffset},
{nEndLineXCoord,nEndLineYCoord-nOffset}};
return aCurve;
end

function fpHexPointer(aShapeCurves,nRadius)
local nSide = math.sqrt((nRadius*nRadius)+((nRadius*nRadius)/3));
table.insert(aShapeCurves,fpLineCurve(-nSide/2, 0, nSide/2, 0, nRadius));
table.insert(aShapeCurves,fpLineCurve(-nSide/2, 0, nSide/2, 0, -nRadius));
end
So the 0 is the point on the offset where it's drawing the line.. and half the side + or - gets you to the ends.
Reverse the Radius gets you the opposite line.
If I set up 3 of these.. it makes a Hexagon. :)

Blackfoot
February 20th, 2019, 08:02
Victory!!
The Hexagonal Pointer!

function fpHexPointer(aShapeCurves,nRadius)
local nSide = math.sqrt((nRadius*nRadius)+((nRadius*nRadius)/3));
table.insert(aShapeCurves,fpLineCurve(-nSide,0,-nSide/2,-nRadius,0));
table.insert(aShapeCurves,fpLineCurve(-nSide,0,-nSide/2,nRadius,0));
table.insert(aShapeCurves,fpLineCurve(-nSide/2,0,nSide/2,0,-nRadius));
table.insert(aShapeCurves,fpLineCurve(-nSide/2,0,nSide/2,0,nRadius));
table.insert(aShapeCurves,fpLineCurve(nSide,0,nSid e/2,-nRadius,0));
table.insert(aShapeCurves,fpLineCurve(nSide,0,nSid e/2,nRadius,0));
end

darrenan
February 20th, 2019, 14:58
Just to geek out on trig for a moment. Equal width/distance from the origin point is not an equilateral triangle, as Moon said. If you think of an equilateral triangle being two right triangles back to back, then each of those right triangles will have tan(x) = 0.5, where x is the angle between adjacent and hypotenuse. The total angle is then 2x, because, two triangles. tan(x) = 0.5 is the same as arctan(0.5) = x, which is ~26.56. Double that, and you get 53.12, or, what Moon said. There will be a quiz on Monday...

https://www.mathsisfun.com/sine-cosine-tangent.html

Since equilateral triangles have 3 60 degree angles, by the same logic as above, the ratio of distance/width is 2 * tan(30) = ~1.15

Blackfoot
February 20th, 2019, 18:04
Dork.

Yeah yeah... I meant oh bother.. Whatever. You know what I meant.

Check out my HEX pointer! :)

https://media.discordapp.net/attachments/410226766964195340/547710765847674913/unknown.png

darrenan
February 20th, 2019, 23:31
who has two thumbs and was in math club in high school? this guy :-)