[vtkusers] vtkCollisionDetection Coloring Colliding Cells
Goodwin Lawlor
goodwin.lawlor at ucd.ie
Mon Nov 10 12:53:05 EST 2008
Hi,
Hi Prabhat,
prabhat246 wrote:
> Hey all,
>
> I am able to use vtkCollisionDetection class get the colliding cells.
>
> But how if I want to color the colliding cells into differnt color??
The simplest way to do your own colouring of cells may be to use
vtkProgrammableAttributeDataFilter to loop through the ContactCells list
and create whatever scalars you want. A 4 component vtkUnsignedCharArray
can be used to represent RGBA for each cell you want to colour.
Alternatively use a single component array and map the values through a
LUT to get the colours you want.
> and How can I stop the the collission means One object should not get into
> other. If I stop the interaction it will stick to other forever. isn't it??
One way on getting your actors to behave like solid objects is to change
the actor origin to the first point of contact. Actors tend to roll off
each other (there's no mechanics involved!).
So:
vtkRenderer ren
ren AddObserver EndEvent ChangeOrigin
proc ChangeOrigin {} {
if {[collide GetNumberOfContacts] != 0} {
set pts [[collide GetContactsOutput] GetPoints]
set xyz [$pts GetPoint 0]
eval actor1 SetOrigin $xyz
eval actor2 SetOrigin $xyz
} else {
actor1 SetOrigin 0 0 0
actor2 SetOrigin 0 0 0
}
}
hth
Goodwin
More information about the vtkusers
mailing list