Hi! I have an idea for mudbox plugin and I use CurveBrush plugin as a base code. My goal is to modify the code that I could start to make the stroke every in 3d space not only when cursor is located under the mesh. Is this possible?
Solved! Go to Solution.
Hi! I have an idea for mudbox plugin and I use CurveBrush plugin as a base code. My goal is to modify the code that I could start to make the stroke every in 3d space not only when cursor is located under the mesh. Is this possible?
Solved! Go to Solution.
Solved by imre.major. Go to Solution.
in mudbox a stroke does start outside of a mesh.
try the grab brush if you start outside and move inwards it will push the geo inwards as soon as you touch the mesh.
in mudbox a stroke does start outside of a mesh.
try the grab brush if you start outside and move inwards it will push the geo inwards as soon as you touch the mesh.
Thanks for the reply. I have this idea to make the simple 2d paint sketching plugin inside into mudbox. Very often when I sculpt, I take a screenshot and take that picture into 2d painting app. Do some rough sketching and trying to find ideas for sculpting. I thought that it would be nice to code this feature into mudbox using SDK. But like you said it seams that there is no way to start a stroke outside the mesh.
I was just thinking that there is tools like "Curve loop" where you can start to create a visual guide outside the mesh. Could I do something similar with SDK?
Thanks for the reply. I have this idea to make the simple 2d paint sketching plugin inside into mudbox. Very often when I sculpt, I take a screenshot and take that picture into 2d painting app. Do some rough sketching and trying to find ideas for sculpting. I thought that it would be nice to code this feature into mudbox using SDK. But like you said it seams that there is no way to start a stroke outside the mesh.
I was just thinking that there is tools like "Curve loop" where you can start to create a visual guide outside the mesh. Could I do something similar with SDK?
Drawing on the screen in 2D is completely different from drawing on a 3d scene object.
A common way to do what you're talking about is called "projection". Where you draw on the screen in 2D. And then it gets projected onto the mesh's surface.
AFAIK, there is no such projection option in the Mudbox SDK. But I have not touched it in years. So that might not be true anymore.
This question is exactly why I lobbied for "At least some small level of SDK support".
This question could be answered very simply and quickly by one of the developers.
-ScottA
Drawing on the screen in 2D is completely different from drawing on a 3d scene object.
A common way to do what you're talking about is called "projection". Where you draw on the screen in 2D. And then it gets projected onto the mesh's surface.
AFAIK, there is no such projection option in the Mudbox SDK. But I have not touched it in years. So that might not be true anymore.
This question is exactly why I lobbied for "At least some small level of SDK support".
This question could be answered very simply and quickly by one of the developers.
-ScottA
Hi. Both the functions CurveCreator::BeginStroke and CurveCreator::MouseMove should be called even before the cursor reach the mesh. Did you try putting a breakpoint to either of those, and see if they are called when you press the mouse button while the cursor is not on the mesh?
Hi. Both the functions CurveCreator::BeginStroke and CurveCreator::MouseMove should be called even before the cursor reach the mesh. Did you try putting a breakpoint to either of those, and see if they are called when you press the mouse button while the cursor is not on the mesh?
Thanks a lot. I even didn't know that I can debug plugins while mudbox is running. I tried and it worked perfectly. This really helps a lot. And yes it seams that brushstroke is called even if cursor is not touching the mesh so I will gladly continue to code plugin idea what I have 🙂
Thanks a lot. I even didn't know that I can debug plugins while mudbox is running. I tried and it worked perfectly. This really helps a lot. And yes it seams that brushstroke is called even if cursor is not touching the mesh so I will gladly continue to code plugin idea what I have 🙂
Things are looking good, but still needs some helps. So my goal is to take screen space coords into world space and I'm not quite sure is this the right way: MouseMove gives (float fX, float fY) which are viewport coords range (0-1) then I need to rerange this coords into (-1, 1) and then send them into cameras UnProject function which gives me coords from world space. Is this the right way to handle this??
Things are looking good, but still needs some helps. So my goal is to take screen space coords into world space and I'm not quite sure is this the right way: MouseMove gives (float fX, float fY) which are viewport coords range (0-1) then I need to rerange this coords into (-1, 1) and then send them into cameras UnProject function which gives me coords from world space. Is this the right way to handle this??
I was able to figure this out.. no help needed anymore 🙂
I was able to figure this out.. no help needed anymore 🙂
It's great that you figured it out. But it's generally polite to post some code after your question has been answered. So other people can also benefit from it too.
It's really annoying when someone asks for help...gets it...then bails out without sharing any part of the solution with everyone else.
Since these C++ plugins are fairly long in the tooth with framework code. What most people do is post a small snippet of C++ code rather than the entire plugin code.
In this case. It would be good netiquette if you posted your screen space-to-world space code. Or whatever feel that you can.
Thanks,
-ScottA
It's great that you figured it out. But it's generally polite to post some code after your question has been answered. So other people can also benefit from it too.
It's really annoying when someone asks for help...gets it...then bails out without sharing any part of the solution with everyone else.
Since these C++ plugins are fairly long in the tooth with framework code. What most people do is post a small snippet of C++ code rather than the entire plugin code.
In this case. It would be good netiquette if you posted your screen space-to-world space code. Or whatever feel that you can.
Thanks,
-ScottA
Hi!. The reason why I don't show my code is that I'm from Finland and my code includes a lot of finnish word so it could be quite hard others to use that. But I hope that the goal I had in previous post I got it to work so the main steps are there to anyone to follow and I'm glad to help anybody if they need futher help.
Hi!. The reason why I don't show my code is that I'm from Finland and my code includes a lot of finnish word so it could be quite hard others to use that. But I hope that the goal I had in previous post I got it to work so the main steps are there to anyone to follow and I'm glad to help anybody if they need futher help.
"I'm glad to help anybody if they need futher help"
That's great. Because I need further help. 😉
I would like to see how you handled the screen to world conversions.
It's easy to translate Finnish to English. So that's not a problem.
Can you please post your source code in your other thread along with the Sketch.mp file?
Thanks,
-ScottA
"I'm glad to help anybody if they need futher help"
That's great. Because I need further help. 😉
I would like to see how you handled the screen to world conversions.
It's easy to translate Finnish to English. So that's not a problem.
Can you please post your source code in your other thread along with the Sketch.mp file?
Thanks,
-ScottA
void CurveCreator::MouseMove( float fX, float fY, float fXDelta, float fYDelta , AxisAlignedBoundingBox &a, float ) { // determine where the user clicked in 3d space Vector normal,zero,v_up,v_right,pV1,pV2,planeN,v_position,distance,nn,oli; zero.Set(0, 0, 0); v_position = Kernel()->Scene()->ActiveCamera()->Forward(); float tulos = m_fSTimes.m_cValue; v_position.SetLength(tulos); distance = v_position - zero; float matka = distance.Length(); distance.SetLength(matka*0.9f); nn = distance; nn.Normalize(); v_up = Kernel()->Scene()->ActiveCamera()->Up(); v_right = Kernel()->Scene()->ActiveCamera()->Right(); pV1 = v_up - distance; pV2 = v_right - distance; planeN = pV2 & pV1; planeN.Normalize(); normal = nn; float xnew, ynew, tValue; xnew = fX - 1 + 2 * fX*0.5f; ynew = 1 - fY - 2 * fY*0.5f; Vector newCoord,newVec,CamVec,ShootVec,final; newCoord.Set(xnew, ynew, 0.0f); newVec = Kernel()->Scene()->ActiveCamera()->UnProject(newCoord); CamVec = Kernel()->Scene()->ActiveCamera()->Position(); ShootVec = newVec - CamVec; // calc t constant value for vector and plane tValue = ((normal.m_fX*distance.m_fX) + (normal.m_fY*distance.m_fY) + (normal.m_fZ*distance.m_fZ)-(CamVec.m_fX * normal.m_fX)-(CamVec.m_fY*normal.m_fY)-(CamVec.m_fZ*normal.m_fZ) )/ ((ShootVec.m_fX*normal.m_fX)+ (ShootVec.m_fY*normal.m_fY)+ (ShootVec.m_fZ*normal.m_fZ)); // calc intersection of the line and plane final.m_fX = CamVec.m_fX + ShootVec.m_fX * tValue; final.m_fY = CamVec.m_fY + ShootVec.m_fY * tValue; final.m_fZ = CamVec.m_fZ + ShootVec.m_fZ * tValue;
Hi! Here is the code I have used to change screen space into world space.
void CurveCreator::MouseMove( float fX, float fY, float fXDelta, float fYDelta , AxisAlignedBoundingBox &a, float ) { // determine where the user clicked in 3d space Vector normal,zero,v_up,v_right,pV1,pV2,planeN,v_position,distance,nn,oli; zero.Set(0, 0, 0); v_position = Kernel()->Scene()->ActiveCamera()->Forward(); float tulos = m_fSTimes.m_cValue; v_position.SetLength(tulos); distance = v_position - zero; float matka = distance.Length(); distance.SetLength(matka*0.9f); nn = distance; nn.Normalize(); v_up = Kernel()->Scene()->ActiveCamera()->Up(); v_right = Kernel()->Scene()->ActiveCamera()->Right(); pV1 = v_up - distance; pV2 = v_right - distance; planeN = pV2 & pV1; planeN.Normalize(); normal = nn; float xnew, ynew, tValue; xnew = fX - 1 + 2 * fX*0.5f; ynew = 1 - fY - 2 * fY*0.5f; Vector newCoord,newVec,CamVec,ShootVec,final; newCoord.Set(xnew, ynew, 0.0f); newVec = Kernel()->Scene()->ActiveCamera()->UnProject(newCoord); CamVec = Kernel()->Scene()->ActiveCamera()->Position(); ShootVec = newVec - CamVec; // calc t constant value for vector and plane tValue = ((normal.m_fX*distance.m_fX) + (normal.m_fY*distance.m_fY) + (normal.m_fZ*distance.m_fZ)-(CamVec.m_fX * normal.m_fX)-(CamVec.m_fY*normal.m_fY)-(CamVec.m_fZ*normal.m_fZ) )/ ((ShootVec.m_fX*normal.m_fX)+ (ShootVec.m_fY*normal.m_fY)+ (ShootVec.m_fZ*normal.m_fZ)); // calc intersection of the line and plane final.m_fX = CamVec.m_fX + ShootVec.m_fX * tValue; final.m_fY = CamVec.m_fY + ShootVec.m_fY * tValue; final.m_fZ = CamVec.m_fZ + ShootVec.m_fZ * tValue;
Hi! Here is the code I have used to change screen space into world space.
Thank You!
-ScottA
Can't find what you're looking for? Ask the community or share your knowledge.