Replies: 11 comments 1 reply
-
One wouldn't normally replace a graphics pipeline state just to change colour, the proper way to do it would be to change the colour arrays associated with the geometry or change a material descriptor. |
Beta Was this translation helpful? Give feedback.
-
I want to implement the mouse click on the node of the model to set the node to the highlighted state. As mentioned above, click on the wheel node of the car model and set the wheel to the highlighted state (red). I have tested that it is possible to switch the pipeline state (change the color) of the entire model. |
Beta Was this translation helpful? Give feedback.
-
A more idiomatic way to do that is to use a StateSwitch command, which lets you choose e.g. one of several BindGraphicsPipeline commands based on a mask value. A more advanced way to implement highlighting is to build the highliting logic into your shader and store the hightlighting flag variable in a uniform buffer that's bound in a buffer above the whole model (in a StateGroup node). |
Beta Was this translation helpful? Give feedback.
-
I have now implemented a module state switching model->accept(*replaceState), my question is whether this switching method supports the child nodes of the model, as above, whether it supports a certain child node of the model to do this state switching. For example node->accept(*replaceState) |
Beta Was this translation helpful? Give feedback.
-
The VSG supports state inheritance/overriding via the vsg::StateGroup class, so it should be possible to decorate just the children you want to change the state for by inserting a StateGroup above them. A custom "Highlight" node might be the best way, and have this push/pope state or implement a multi-pass effect to do the highlighting. |
Beta Was this translation helpful? Give feedback.
-
Hello, Robert Sfield I'm not sure now if I did the right thing. I combined vsgintersection.cpp demo and clip.cpp demo. Then, after picking mesh, highlight ( But it didn't work. Below is the code I tested, can you give me some comments? #include <vsg/all.h> #ifdef vsgXchange_FOUND include <vsgXchange/all.h>#endif #include auto viewer = vsg::Viewer::create(); class ReplaceState : public vsg::Inherit<vsg::Visitor, ReplaceState>
}; void test(vsg::ref_ptr inReplaceState,vsg::ref_ptrvsg::Node inModel,vsg::ref_ptrvsg::Viewer inViewer)
} vsg::ref_ptr createHightLightPipline(vsg::ref_ptrvsg::Options& inOptions)
} vsg::ref_ptr replaceStateGreen; vsg::ref_ptr replaceStateTest; //replaceStateGreen = createHightLightPipline(options); // replaceStateTest = ReplaceState::create(graphicsPipelineOld); class IntersectionHandler : public vsg::Inherit<vsg::Visitor, IntersectionHandler>
protected: int main(int argc, char** argv)
#ifdef vsgXchange_all
// if (argc > 1)
/* auto viewer = vsg::Viewer::create();*/
} |
Beta Was this translation helpful? Give feedback.
-
I followed your suggestion and inserted StateGroup above the child object to decorate the child object whose state you want to change. On the basis of vsgintersection, try to implement Highlight. Now I pick up a node and set the Highlight color. The Highlight node needs to make the same matrix change as the original node. I try to get the matrix of node directly and apply it to Highlight node as follows: transform->matrix = node->castvsg::MatrixTransform()->matrix; But the size and bit of the model after the Highlight is incorrect, am I missing something Green is the Highlight state I set after picking. |
Beta Was this translation helpful? Give feedback.
-
I wouldn't normally expect a highlight technique to need to use transforms. As a general note doing a dynamic_cast<> or vsg::Object::cast<> should not be assumed to always return a valid pointer - if the object is not of the type being cast to a nullptr will returned so code could easily crash if you start operating on it. I can't help but feel that you are tackling this task in a more complicated way that it need be. Could you provide an example of the highlighting effect that you are after? |
Beta Was this translation helpful? Give feedback.
-
For now, I'm only testing in a special way, using the test.glb model that I provided myself |
Beta Was this translation helpful? Give feedback.
-
Sorry, I should have been more clear, could you provide a screenshot or link to webpage that shows the type of highlighting your are trying to achieve. |
Beta Was this translation helpful? Give feedback.
-
Desktop.2023.12.03.-.16.47.51.02.online-video-cutter.com.mp4 |
Beta Was this translation helpful? Give feedback.
-
In the vsgclip.cpp demo, I saw that a shader can be reassigned to the model. code show as below. model->accept(*replaceState);
If the model is a car, I want to assign another new shader to CarWheeel (change the color to red), you can execute CarWheeel->accept(*replaceStateRed);
Does this logic support in vsg?
Beta Was this translation helpful? Give feedback.
All reactions