Just can't get GetPixelInfoPoint to work :-(
-
On 18/06/2014 at 09:38, xxxxxxxx wrote:
Howdy,
Hehe, at this point that may be your only option. If you want to keep your code confidential, feel free to pm or email it to one of us.
Adios,
Cactus Dan -
On 18/06/2014 at 09:38, xxxxxxxx wrote:
Scott, I did what you said and the sculpt tool works fine and prints out the name of the object.
-
On 18/06/2014 at 09:44, xxxxxxxx wrote:
Well, I will send it through pm just because I don't want to show my lame code to everyone
Thank you very much in advance. -
On 18/06/2014 at 09:50, xxxxxxxx wrote:
I just sent you a PM with my code, Dan.
I will only send it to Scott if he says it is OK to do so.
Thank you very much in advance to both of you. -
On 18/06/2014 at 10:29, xxxxxxxx wrote:
If Dan's willing to help you out. There's no need to send it to me Rui.
He can probably help you better than I can.
Plus, he's a Mac user. So you can send files to each other. And I can't do that.-ScottA
-
On 18/06/2014 at 10:33, xxxxxxxx wrote:
Thank you very much for the help, anyway, Scott
I guess I will be needing more help in the near future, now that I jumped on the C++ boat.
I can compile for Mac and Windows and that is great. But I'm still a newbie. -
On 18/06/2014 at 10:53, xxxxxxxx wrote:
Howdy,
Well, I added your "CheckRadius" function to the test code that I posted, and it always prints "pPixel is NULL" the same as you're getting. So that function looks like it is the culprit.
But if I change the code in that function to:
LONG x = mouseX; LONG y = mouseY; ViewportPixel *pPixel = vps->GetNearestPoint(current_obj,x,y,radius); if(pPixel) GePrint(LongToString(pPixel->i)); else GePrint("pPixel is NULL");
... then it works.
What is the purpose of the code in CheckRadius()? I mean why the nested for() loops?
Edit:
I can see using the nested for() loops in the sculpting tool example in the sdk project, because that tool would need to affect the surrounding points along with the point under the mouse, therefore the use of:pPixel = pPixel->next;
... but for a painting tool, it just seems like the GetNearestPoint() function would be the easier.
Adios,
Cactus Dan -
On 18/06/2014 at 12:41, xxxxxxxx wrote:
Well, it is a painting tool that should paint ALL points inside the radius.
But since the ViewportPixel structure is a linked list, maybe the GetNearestPoint returns a linked list of all points that are withing the radius.
I will give it a try
Thank you, Dan. -
On 18/06/2014 at 12:54, xxxxxxxx wrote:
Damn!!
Now my CheckRadius function is just:void cPolyPaintTool::CheckRadius(BaseDocument* doc, BaseContainer &data;, Real mouseX, Real mouseY, Real radius) { LONG x = _mouseX; LONG y = _mouseY; LONG rad = radius;      ViewportPixel* pPixel = vps->GetNearestPoint(current_obj, x, y,rad,FALSE,NULL,0);                if (pPixel) GePrint(LongToString(pPixel->i)); else      GePrint("pPixel is NULL"); }
And I still only get "pPixel is NULL". It never printed an index.
-
On 18/06/2014 at 13:56, xxxxxxxx wrote:
Howdy,
Maybe it is working?
Here's a test I did. I added a breakpoint within the while loop in your original CheckRadius() function code, and ran it in the Debugger. The debugger did break at that point, which means that at least one pass through the loop did return a valid pointer to the ViewportPixel. It's just that there were so many other passes that return NULL, that I missed it in the console.
Here's a screen capture video showing it:
http://www.cactus3d.com/BreakPoint.movYou can see in the video that 1 pass did print "1" to the console which is the point's index I clicked on in the viewport.
Adios,
Cactus Dan -
On 18/06/2014 at 14:05, xxxxxxxx wrote:
So, why doesn't it return lots of indexes when I search for the points inside the nested loops?
Because I'm "painting" on top of a very dense mesh.p.s. I don't know how to run a plugin in the Debugger
-
On 18/06/2014 at 14:11, xxxxxxxx wrote:
Howdy,
Well, remember that the console has a line limit, so when it goes over that limit, it starts truncating lines from the beginning.
Have you tried commenting out the line to print when it's NULL, and see if anything is printed to the console?
Adios,
Cactus Dan -
On 18/06/2014 at 14:15, xxxxxxxx wrote:
Yes, I did. And nothing gets printed
-
On 18/06/2014 at 15:17, xxxxxxxx wrote:
Howdy,
When it prints nothing are simply clicking on a point or are you dragging the mouse over the point?
Adios,
Cactus Dan -
On 18/06/2014 at 15:23, xxxxxxxx wrote:
It prints nothing, no matter if I click or drag the mouse over the point(s).
-
On 18/06/2014 at 15:41, xxxxxxxx wrote:
Howdy,
Hmmmm, the code you sent me seems to be working. I commented out all the checks for the tag, and made it a ToolData instead of a DescriptionToolData, since I didn't have the resource files. But I've only tested it in R12 (that's where I do all my initial development) with a simple cube and it seems to be fine.
Adios,
Cactus Dan -
On 18/06/2014 at 16:17, xxxxxxxx wrote:
Weird...
If I change tools (for example, if I choose the Scale tool, and then my plugin tool) it works!! -
On 18/06/2014 at 16:56, xxxxxxxx wrote:
Oh man.
I was going to mention this earlier. But I didn't think it would trip you up.
If you look at the code example I posted. And the code in the sculpting.cpp file. You'll notice that the sculpting.cpp file has an "Update" function in it. Plus a bunch of OpenGL stuff and timers code in it.I removed all that junk from my example. Because It was very ugly code. And very convoluted.
But what that means is that if you want to use the tool on a different object. Then you have to select one of the other tool modes (move, rotate, scale). And then re-select your tool so the new object gets initialized to work with the different object.
It's one of those things that I was meaning to try and fix some day.
The code in the sculpting example that handles this is a complete mess.Since it works fine on the first selected object. I didn't think it would cause a problem for you.
But if that's the reason you're having problems. I should have mentioned it sooner. !Embarrassed
[URL-REMOVED]-ScottA
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
-
On 18/06/2014 at 17:05, xxxxxxxx wrote:
So, I guess I will have to implement the Update function that is in the sculpt tool, right?
-
On 18/06/2014 at 17:20, xxxxxxxx wrote:
If your tool is working properly after you switch to another mode, then select the tool again...Then yes. You'll need to write something to handle that scenario. Like they did in the SDK sculpting example.
I personally never got that far with my plugin.The code they used in the SDK for this is terribly ugly. And I'm sure there's a cleaner, more elegant way to write it without all of those custom methods, timers, and junk.
-ScottA