Help Using Groups/Layers On Pick
by Unk · in Torque Game Builder · 07/18/2006 (3:44 pm) · 5 replies
Hey guys,
Can someone post a working example of how to utilize Groups/Layers on a Pick function like PickPoint? (Please don't quote the reference as I have that already.)
I have tried all combinations I can think of but whenever I do a pick when specifying a graphgroup or layergroup my list comes up empty.
I have tried this with the original 1.1.0 install build and from a CVS debug build from 6/28.
Thanks for your help.
-Unk
-----------------------------------------------
THIS RETURNS A LIST:
%pick = $scenegraph.pickPoint(%posx,%posy);
-----------------------------------------------
THESE VARIATIONS DO NOT:
%pick = $scenegraph.pickPoint(%posx,%posy,1,1);
------
%pick = $scenegraph.pickPoint(%posx,%posy,"1","1");
------
%pick = $scenegraph.pickPoint(%posx,%posy,BIT(1),BIT(1));
------
%groupMask = 1;
%layerMask = 1;
%pick = $scenegraph.pickPoint(%posx,%posy,%groupMask,%layerMask);
------
%groupMask = Bit(1);
%layerMask = Bit(1);
%pick = $scenegraph.pickPoint(%posx,%posy,%groupMask,%layerMask);
------
%pick = $scenegraph.pickPoint(%posx,%posy,%groupMask = 1,%layerMask = 1);
------
%pick = $scenegraph.pickPoint(%posx,%posy,"%groupMask = 1","%layerMask = 1");
Can someone post a working example of how to utilize Groups/Layers on a Pick function like PickPoint? (Please don't quote the reference as I have that already.)
I have tried all combinations I can think of but whenever I do a pick when specifying a graphgroup or layergroup my list comes up empty.
I have tried this with the original 1.1.0 install build and from a CVS debug build from 6/28.
Thanks for your help.
-Unk
-----------------------------------------------
THIS RETURNS A LIST:
%pick = $scenegraph.pickPoint(%posx,%posy);
-----------------------------------------------
THESE VARIATIONS DO NOT:
%pick = $scenegraph.pickPoint(%posx,%posy,1,1);
------
%pick = $scenegraph.pickPoint(%posx,%posy,"1","1");
------
%pick = $scenegraph.pickPoint(%posx,%posy,BIT(1),BIT(1));
------
%groupMask = 1;
%layerMask = 1;
%pick = $scenegraph.pickPoint(%posx,%posy,%groupMask,%layerMask);
------
%groupMask = Bit(1);
%layerMask = Bit(1);
%pick = $scenegraph.pickPoint(%posx,%posy,%groupMask,%layerMask);
------
%pick = $scenegraph.pickPoint(%posx,%posy,%groupMask = 1,%layerMask = 1);
------
%pick = $scenegraph.pickPoint(%posx,%posy,"%groupMask = 1","%layerMask = 1");
About the author
#2
-Unk
07/19/2006 (11:08 am)
I appreciate it, man. I am pretty sure I must be setting the parameters wrong but I couldn't find any source to compare it to.-Unk
#3
This way you can get the results of a pick by passing in a position. Then call one of the utility functions to remove every id from the pick list that does not match the filter.
I would still be interested if someone figures out how to get this working inside the pick function. I am starting to suspect it is a bug.
-Unk
07/19/2006 (5:10 pm)
While I wasn't able to filter the results of a pick when calling the pick itself, I realized that it wouldn't be that difficult to appy a filter on the backend. Incase anyone else is trying to do something similar here are the utility functions I came up with:function filterByGraphGroup(%picklist,%graphgroupfilter)
{
%slots = (getWordCount(%picklist) - 1);
for(%slot = 0; %slot <= %slots; %slot++)
{
%ID = getWord(%picklist,%slot);
%group = %ID.getGraphGroup();
echo("===== Processing FilterByGraphGroup - Slot:" SPC %slot @ "/" @ %slots SPC "- ID:" @ %ID @ " =====");
echo("Current List:" SPC %picklist);
if(%group != %graphgroupfilter)
{
%picklist = removeWord(%picklist,%slot);
%slot -= 1;
%slots -= 1;
echo("ID:" @ %ID SPC "Removing From List - Mismatched Groups:" SPC %group @ "/" @ %graphgroupfilter);
echo("New List:" SPC %picklist);
}
else
{
echo("ID:" @ %ID SPC "Passed Filter");
}
}
echo("Done Processing List:" SPC %picklist);
return %picklist;
}
function filterByLayer(%picklist,%layerfilter)
{
%slots = (getWordCount(%picklist) - 1);
for(%slot = 0; %slot <= %slots; %slot++)
{
%ID = getWord(%picklist,%slot);
%layer = %ID.getLayer();
echo("===== Processing FilterByLayer - Slot:" SPC %slot @ "/" @ %slots SPC "- ID:" @ %ID @ " =====");
echo("Current List:" SPC %picklist);
if(%layer != %layerfilter)
{
%picklist = removeWord(%picklist,%slot);
%slot -= 1;
%slots -= 1;
echo("ID:" @ %ID SPC "Removing From List - Mismatched Layers:" SPC %layer @ "/" @ %layerfilter);
echo("New List:" SPC %picklist);
}
else
{
echo("ID:" @ %ID SPC "Passed Filter");
}
}
echo("Done Processing List:" SPC %picklist);
return %picklist;
}
function filterByGraphGroupAndLayer(%picklist,%graphgroupfilter, %layerfilter)
{
%slots = (getWordCount(%picklist) - 1);
for(%slot = 0; %slot <= %slots; %slot++)
{
%ID = getWord(%picklist,%slot);
%group = %ID.getGraphGroup();
%layer = %ID.getLayer();
echo("===== Processing filterByGraphGroupAndLayer - Slot:" SPC %slot @ "/" @ %slots SPC "- ID:" @ %ID @ " =====");
echo("Current List:" SPC %picklist);
if((%group != %graphgroupfilter)||(%layer != %layerfilter))
{
%picklist = removeWord(%picklist,%slot);
%slot -= 1;
%slots -= 1;
echo("ID:" @ %ID SPC "Removing From List - Mismatched Group or Layer - Group:" SPC %group @ "/" @ %graphgroupfilter SPC "- Layer:" SPC %layer @ "/" @ %layerfilter);
echo("New List:" SPC %picklist);
}
else
{
echo("ID:" @ %ID SPC "Passed Filter");
}
}
echo("Done Processing List:" SPC %picklist);
return %picklist;
}This way you can get the results of a pick by passing in a position. Then call one of the utility functions to remove every id from the pick list that does not match the filter.
%pick = $scenegraph.pickPoint(%posx,%posy); //THEN %pickid = filterByGraphGroup(%pickid,1); //OR %pickid = filterByLayer(%pickid,1); //OR %pickid = filterByGraphGroupAndLayer(%pickid,1,1);
I would still be interested if someone figures out how to get this working inside the pick function. I am starting to suspect it is a bug.
-Unk
#4
Below is an update to these functions plus a couple additional functions (changes marked in bold).
These functions are primarily helpful for filtering a list of objects at the mouse position by layer and graphgroup.
All of these functions apply one of these filters to a tab delimited list of id's stored in a string:
In addition, there are three new functions that call a pick prior to applying a filter:
I also corrected a bug where the filters would return a string with trailing whitespace which does not get ignored when concatenating strings.
-Unk
(Post Too Long - See Below)
08/08/2006 (8:49 am)
[Update:]Below is an update to these functions plus a couple additional functions (changes marked in bold).
These functions are primarily helpful for filtering a list of objects at the mouse position by layer and graphgroup.
All of these functions apply one of these filters to a tab delimited list of id's stored in a string:
[b]filterByGraphGroupFilter(string,graphgroup number)[/b] - filters by passed in graph group [b]filterByLayerFilter(string,layer number)[/b] - filters by passed in layer) [b]filterByGraphGroupAndLayerFilter(string,graphgroup number,layer number)[/b] - filters by both graph group and layer.
In addition, there are three new functions that call a pick prior to applying a filter:
[b]getPickPoint(object id, filter,graphgroup number, layer number[/b]) - Gets objects at object pos and applies given filter. [b]getPickPointByPosition(position, filter,graphgroup number, layer number[/b]) - Gets objects at given position and applies given filter. [b]getPickRadius(object id, radius, filter,graphgroup number, layer number[/b]) - Gets objects in radius around given object position and applies given filter.
I also corrected a bug where the filters would return a string with trailing whitespace which does not get ignored when concatenating strings.
-Unk
(Post Too Long - See Below)
#5
08/08/2006 (8:49 am)
function filterByGraphGroup(%picklist,%graphgroupfilter)
{
%slots = (getWordCount(%picklist) - 1);
for(%slot = 0; %slot <= %slots; %slot++)
{
%ID = getWord(%picklist,%slot);
%group = %ID.getGraphGroup();
//echo("===== Processing FilterByGraphGroup - Slot:" SPC %slot @ "/" @ %slots SPC "- ID:" @ %ID @ " =====");
//echo("Current List:" SPC %picklist);
if(%group != %graphgroupfilter)
{
%picklist = removeWord(%picklist,%slot);
%slot -= 1;
%slots -= 1;
//echo("ID:" @ %ID SPC "Removing From List - Mismatched Groups:" SPC %group @ "/" @ %graphgroupfilter);
//echo("New List:" SPC %picklist);
}
else
{
//echo("ID:" @ %ID SPC "Passed Filter");
}
}
//echo("Done Processing List:" SPC %picklist);
[b]%pickid = stripTrailingSpaces(%pickid);[/b]
return %picklist;
}
function filterByLayer(%picklist,%layerfilter)
{
%slots = (getWordCount(%picklist) - 1);
for(%slot = 0; %slot <= %slots; %slot++)
{
%ID = getWord(%picklist,%slot);
%layer = %ID.getLayer();
//echo("===== Processing FilterByLayer - Slot:" SPC %slot @ "/" @ %slots SPC "- ID:" @ %ID @ " =====");
//echo("Current List:" SPC %picklist);
if(%layer != %layerfilter)
{
%picklist = removeWord(%picklist,%slot);
%slot -= 1;
%slots -= 1;
//echo("ID:" @ %ID SPC "Removing From List - Mismatched Layers:" SPC %layer @ "/" @ %layerfilter);
//echo("New List:" SPC %picklist);
}
else
{
//echo("ID:" @ %ID SPC "Passed Filter");
}
}
//echo("Done Processing List:" SPC %picklist);
[b]%pickid = stripTrailingSpaces(%pickid);[/b]
return %picklist;
}
function filterByGraphGroupAndLayer(%picklist,%graphgroupfilter, %layerfilter)
{
%slots = (getWordCount(%picklist) - 1);
for(%slot = 0; %slot <= %slots; %slot++)
{
%ID = getWord(%picklist,%slot);
%group = %ID.getGraphGroup();
%layer = %ID.getLayer();
//echo("===== Processing filterByGraphGroupAndLayer - Slot:" SPC %slot @ "/" @ %slots SPC "- ID:" @ %ID @ " =====");
//echo("Current List:" SPC %picklist);
if((%group != %graphgroupfilter)||(%layer != %layerfilter))
{
%picklist = removeWord(%picklist,%slot);
%slot -= 1;
%slots -= 1;
//echo("ID:" @ %ID SPC "Removing From List - Mismatched Group or Layer - Group:" SPC %group @ "/" @ %graphgroupfilter SPC "- Layer:" SPC %layer @ "/" @ %layerfilter);
//echo("New List:" SPC %picklist);
}
else
{
//echo("ID:" @ %ID SPC "Passed Filter");
}
}
//echo("Done Processing List:" SPC %picklist);
[b]%picklist = stripTrailingSpaces(%picklist);[/b]
return %picklist;
}
[b]
function getPickPoint(%obj,%filter,%graphgroupfilter,%layerfilter)
{
//echo("===== Function getPickPoint - Obj:" SPC %obj SPC "- Filter:" SPC %filter SPC %graphgroupfilter @ "/" @ %layerfilter);
%objpos = %obj.getPosition();
//echo("Objpos:" SPC %objpos);
//break up position (needed??)
%tempposx = getAxisPos("x",%objpos);
%tempposy = getAxisPos("y",%objpos);
%pickid = $scenegraph.pickPoint(%tempposx,%tempposy);
//echo("Pickid:" SPC %pickid);
if(%filter $= "")
{
//echo("Found Filter NONE:" SPC %filter);
%pickid = stripTrailingSpaces(%pickid);
return %pickid;
}
if(%filter $= "filterByGraphGroup")
{
//echo("Found Filter filterByGraphGroup:" SPC %filter);
%pickid = filterByGraphGroup(%pickid,%graphgroupfilter);
%pickid = stripTrailingSpaces(%pickid);
return %pickid;
}
else if(%filter $= "filterByLayer")
{
//echo("Found Filter filterByLayer:" SPC %filter);
%pickid = filterByLayer(%pickid,%layerfilter);
%pickid = stripTrailingSpaces(%pickid);
return %pickid;
}
else if(%filter $= "filterByGraphGroupAndLayer")
{
//echo("Found Filter filterByGraphGroupAndLayer:" SPC %filter);
%pickid = filterByGraphGroupAndLayer(%pickid,%graphgroupfilter,%layerfilter);
%pickid = stripTrailingSpaces(%pickid);
return %pickid;
}
}
function getPickPointByPosition(%pos,%filter,%graphgroupfilter,%layerfilter)
{
//echo("===== Function getPickPoint - Obj:" SPC %obj SPC "- Filter:" SPC %filter SPC %graphgroupfilter @ "/" @ %layerfilter);
//echo("Pos: ", %pos);
//break up position (needed??)
%tempposx = getAxisPos("x",%pos);
%tempposy = getAxisPos("y",%pos);
%pickid = $scenegraph.pickPoint(%tempposx,%tempposy);
//echo("Pickid:" SPC %pickid);
if(%filter $= "")
{
//echo("Found Filter NONE:" SPC %filter);
return %pickid;
}
if(%filter $= "filterByGraphGroup")
{
//echo("Found Filter filterByGraphGroup:" SPC %filter);
%pickid = filterByGraphGroup(%pickid,%graphgroupfilter);
%pickid = stripTrailingSpaces(%pickid);
return %pickid;
}
else if(%filter $= "filterByLayer")
{
//echo("Found Filter filterByLayer:" SPC %filter);
%pickid = filterByLayer(%pickid,%layerfilter);
%pickid = stripTrailingSpaces(%pickid);
return %pickid;
}
else if(%filter $= "filterByGraphGroupAndLayer")
{
//echo("Found Filter filterByGraphGroupAndLayer:" SPC %filter);
%pickid = filterByGraphGroupAndLayer(%pickid,%graphgroupfilter,%layerfilter);
%pickid = stripTrailingSpaces(%pickid);
return %pickid;
}
}
function getPickRadius(%obj,%radius,%filter,%graphgroupfilter,%layerfilter)
{
//echo("===== Function getPickRadius - Obj:" SPC %obj SPC "- Filter:" SPC %filter SPC %graphgroupfilter @ "/" @ %layerfilter);
%objpos = %obj.getPosition();
//echo("Objpos:" SPC %objpos);
//break up position (needed??)
%tempposx = getAxisPos("x",%objpos);
%tempposy = getAxisPos("y",%objpos);
%pickid = $scenegraph.pickRadius(%tempposx,%tempposy,%radius);
//echo("Pick Radius List:" SPC %pickid);
if(%filter $= "")
{
//echo("Found NO Filter: ", %filter);
%pickid = stripTrailingSpaces(%pickid);
return %pickid;
}
if(%filter $= "filterByGraphGroup")
{
%pickid = filterByGraphGroup(%pickid,%graphgroupfilter);
//echo("Applying Filter: ", %filter);
%pickid = stripTrailingSpaces(%pickid);
return %pickid;
}
else if(%filter $= "filterByLayer")
{
//echo("Applying Filter: ", %filter);
%pickid = filterByLayer(%pickid,%layerfilter);
%pickid = stripTrailingSpaces(%pickid);
return %pickid;
}
else if(%filter $= "filterByGraphGroupAndLayer")
{
//echo("Applying Filter: ", %filter);
%pickid = filterByGraphGroupAndLayer(%pickid,%graphgroupfilter,%layerfilter);
%pickid = stripTrailingSpaces(%pickid);
return %pickid;
}
}
[/b]
Torque Owner Thomas Buscaglia