change color of part of a custom node
Posted: Thu Jul 23, 2015 6:45 am
Hi to everyone!
I have 2 questions for you guys, piled up during these days of sourceforge ko, but I start only with the more pressing.
I need to dynamically change the colour of specified faces of a custom scene node, and I have some problems.
my node is made by triangles, in fact I render with this line of code in my render() method:
now, I need to highlight some faces of this node, for a sort of selection by the mouse, ok?
I thought to work on the vertices colour; so I implemented a member function of the same scene node class that, if the ray determined by the mouse intersect a triangle, change its colour:
I also implemented a function to restore the original colour if it it's not selected anymore.
All this stuff, in the end, it works. But sometimes my application crash: looking in the call stack, while it's doing the render() function.
Anyway, before going deep in implementation details, I'd like to have some opinion about the method to do that: I don't know if my way it's the correct one to render the selection of part of a triangle custom node.
Help me please!
I have 2 questions for you guys, piled up during these days of sourceforge ko, but I start only with the more pressing.
I need to dynamically change the colour of specified faces of a custom scene node, and I have some problems.
my node is made by triangles, in fact I render with this line of code in my render() method:
Code: Select all
smgr->getVideoDriver()->drawIndexedTriangleList(vertices, VertIndNum, indices, triangles.size());
I thought to work on the vertices colour; so I implemented a member function of the same scene node class that, if the ray determined by the mouse intersect a triangle, change its colour:
Code: Select all
vertices[selTri->idxFirstVertex].Color = SColor(255, 255, 255, 0);
vertices[selTri->idxFirstVertex + 1].Color = SColor(255, 255, 255, 0);
vertices[selTri->idxFirstVertex + 2].Color = SColor(255, 255, 255, 0);
All this stuff, in the end, it works. But sometimes my application crash: looking in the call stack, while it's doing the render() function.
Anyway, before going deep in implementation details, I'd like to have some opinion about the method to do that: I don't know if my way it's the correct one to render the selection of part of a triangle custom node.
Help me please!