Thank you for your help...
my Implementation is as follow.
I used Polygon with numpy support to test if moving Polygons and
BoundingBox Polygons overlaps.
My question is:
I get an event on every mouse over of an polygon but i like to have
an event only if mousedown or realy objekt moving.
1. How can i get an event if real objects are moving ?
(onDrag on Drop)
Another question is:
2.How can i Flip y axis in floatcanvas2 like ProjectionFun in FC1?
Matthias
-----Code--------------
import Polygon
class MoveNodeWithCollisionDetection(fc.guiMode.GUIModeMoveObjects):
def __init__(self, nonSelectableNodes = []):
self.nonSelectableNodes = nonSelectableNodes
self.look1=fc.SolidColourLook( line_colour = 'green',
fill_colour = 'red' )
self.look2=fc.SolidColourLook( line_colour = 'red', fill_colour
= 'green' )
def on_move(self, event):
''' filters all static objects and moves the non-static ones '''
if event.node.model ==None:
return
movepoly=None
try:
#print type(event.node.model.points),
points= event.node.model.points
matrix=event.node.worldTransform.matrix
trpoints=numpy.dot( numpy.column_stack( (points,
numpy.ones(len(points))) ), numpy.transpose( matrix ) )[ ..., :-1 ]
#print "matrix:\n",matrix
#print "Transformed points:\n",trpoints
movepoly=Polygon.Polygon(trpoints)
#print movepoly.center()
except Exception, e:
pass
#print e
query = fc.nodes.spatialQuery.QueryWithPrimitive( primitive =
event.node.boundingBox,exact = False )
#for elem in query.primitive:
# elem.look=self.look2
intersectingNodes = self.canvas.performSpatialQuery( query,
order = False )
print "count bounding objects:",len(intersectingNodes)
if movepoly:
for elem in intersectingNodes:
try:
points= elem.model.points
matrix= elem.worldTransform.matrix
trpoints=numpy.dot( numpy.column_stack( (points,
numpy.ones(len(points))) ), numpy.transpose( matrix ) )[ ..., :-1 ]
testpoly=Polygon.Polygon(trpoints)
if testpoly.overlaps(movepoly):
elem.look=self.look1
print "collision" #stop moving
else:
fc.guiMode.GUIModeMoveObjects.on_move( self,
event ) # move if nothing overlaps
elem.look=self.look2
except Exception, e:
pass
#print e
print elem
----------Code------------------------
Am 09.05.2011 21:00, schrieb [email protected]:
> Send FloatCanvas mailing list submissions to
> [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas
> or, via email, send a message with subject or body 'help' to
> [email protected]
>
> You can reach the person managing the list at
> [email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of FloatCanvas digest..."
>
>
> Today's Topics:
>
> 1. Re: FloatCanvas Digest, Vol 55, Issue 3 Collision Detection
> with Floatcanvas2 (meliuss)
> 2. Re: FloatCanvas Digest, Vol 55, Issue 3 Collision Detection
> with Floatcanvas2 (Matthias)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 09 May 2011 09:47:04 +0200
> From: meliuss<[email protected]>
> Subject: Re: [fc] FloatCanvas Digest, Vol 55, Issue 3 Collision
> Detection with Floatcanvas2
> To: [email protected]
> Message-ID:<[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Thank you for your fast answer.
>
> Yes I like to use floatcanvas2 it look's a for me a little bit clearer.
> but I have used floatcanvas1 too.
>
> I like the>>guiMode.GUIModeMoveObjects()<< method to use the
> drag'n'drop function for collision detection.
> In nodes/renderableNode.py i found .intersection() and
> ._drawDebugBoundingBoxes()
> Should i better use a nodeControllers.py.
> I like to get the world-objectpoints from a polygon.
>
> Matthias
>
>
>
>
>
> Am 08.05.2011 21:00, schrieb [email protected]:
>> Send FloatCanvas mailing list submissions to
>> [email protected]
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>> http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas
>> or, via email, send a message with subject or body 'help' to
>> [email protected]
>>
>> You can reach the person managing the list at
>> [email protected]
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of FloatCanvas digest..."
>>
>>
>> Today's Topics:
>>
>> 1. Re: I like using collision detection during moving an object
>> (Chris Barker)
>>
>>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Sat, 07 May 2011 17:38:17 -0700
>> From: Chris Barker<[email protected]>
>> Subject: Re: [fc] I like using collision detection during moving an
>> object
>> To: "Mailing List for the wxPython Float Canvas."
>> <[email protected]>
>> Message-ID:<[email protected]>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> On 5/6/2011 5:02 PM, Matthias wrote:
>>> I am aware that Christoper has already given an answer. However, his
>>> answer seems to be for fc1 while you seem to ask for fc2 specifically
>>> (correct me if I'm wrong).
>> oops, yes, i think that is the case. Sorry for the confusion.
>>
>> -Chris
>>
>>
>>
>> ------------------------------
>>
>> _______________________________________________
>> FloatCanvas mailing list
>> [email protected]
>> http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas
>>
>>
>> End of FloatCanvas Digest, Vol 55, Issue 3
>> ******************************************
>
> ------------------------------
>
> Message: 2
> Date: Mon, 09 May 2011 10:15:39 +0200
> From: Matthias<[email protected]>
> Subject: Re: [fc] FloatCanvas Digest, Vol 55, Issue 3 Collision
> Detection with Floatcanvas2
> To: "Mailing List for the wxPython Float Canvas."
> <[email protected]>
> Message-ID:<op.vu7fwdu5zzzl10@nitrogenycs3>
> Content-Type: text/plain; charset=iso-8859-15; format=flowed;
> delsp=yes
>
> Am 09.05.2011, 09:47 Uhr, schrieb meliuss<[email protected]>:
>
>> Thank you for your fast answer.
>>
>> Yes I like to use floatcanvas2 it look's a for me a little bit clearer.
>> but I have used floatcanvas1 too.
>>
>> I like the>>guiMode.GUIModeMoveObjects()<< method to use the
>> drag'n'drop function for collision detection.
>> In nodes/renderableNode.py i found .intersection() and
>> ._drawDebugBoundingBoxes()
>> Should i better use a nodeControllers.py.
>> I like to get the world-objectpoints from a polygon.
> Hmm, did you get my other mail where I explain how to do this?
>
> -Matthias
>
>
> ------------------------------
>
> _______________________________________________
> FloatCanvas mailing list
> [email protected]
> http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas
>
>
> End of FloatCanvas Digest, Vol 55, Issue 4
> ******************************************
_______________________________________________
FloatCanvas mailing list
[email protected]
http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas