WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-27-2007, 10:22 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 180
Pick porblem with arrays

Hello,

I am having a little bit of a problem with the Pick() function.
My code is below, but I will try to explain how the problem came up to begin with.

I was working on a selection class to highlight an object or expand to see different objects when it was clicked. I was using the Pick() function for highlighting the eligable objects, and if the left mouse button was also clicked, it would then set that object as selected and would then cause several spheres to come out and be visible (which would later be equivolent to different selection choices).

Anyways, I had it working, but then I went and used an array to hold each instance of a class called element, which was basically what I was checking for in the selection algorithm.

This is the new, very initial code just to make a sphere highlight when selected.

An array, composed of objects, is passed to the function:

class ElementArray:
def __init__(self):
#Create two arrays
elem1coords = -5,-1,0
elem2coords = 5,1,0
elem1 = Element(elem1coords, viz.ON)
elem2 = Element(elem2coords, viz.ON)
self.myArray = [elem1,elem2]


These objects in the array each have an associated model and I would access it by typing instanceofclass.model.

Before I would just check to see if a variable set equal to viz.pick(1) was equal to the instanceofclass.model and this worked just fine.

Now however, with the new array of objects I find that the addresses that are being referenced are not equal to one another. Basically, I just printed out the picked object and what I am looking for. I watched the output and when I moused over the object, the memory addresses were not the same.

Here is the selection code:

[I]def SelectionLoop(elementArray):
#What is the Mouse over?
item = viz.pick(1)
#Make a loop equal to the array size. Iterate through every element in the array.
for i in range(len(elementArray.myArray)):
#Check to see if the mouse is over the object
print 'elemArray'
print elementArray.myArray[i].model
print 'item.object'
print item.object
if item.object == elementArray.myArray.model:
#highlight the object
item.ambient(5,5,5)
else:
#unhighlight the object
item.object.ambient(0.5,0.5,0.5)


Any help would be great, thank you!

George Lecakes
Rowan University
Reply With Quote
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:15 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC