WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-19-2012, 04:39 PM
tokola tokola is offline
Member
 
Join Date: Nov 2012
Posts: 67
Question 'module' object is not callable???

Hi there.
I am trying to do something seemingly simple. I want to have an avatar (steve) attached to different views and I am using the roboChase code in my own Player class (shown below). The class works fine if I run it but not when used as a module. More specifically, when I try to create a new Player object (p1=Player(viz.MainView)) then I get the following error:
Code:
Traceback (most recent call last):
  File "<string>", line 2, in <module>
TypeError: 'module' object is not callable
Can you please let me know what is the problem? The error message is kind of cryptic! Also, is there a better way to do the same thing, like linking the avatar with the viewpoint (and avoiding the view through the robot's head)?

Code:
import viz
import steve

class Player():
	"""This is the Avatar class"""
	def __init__ (self, view):
		self._view = view
		self._player_matrix = viz.addGroup() #self.view.getMatrix()
		self._avatar = steve.Steve()
		self._avatar.setTracker(self._player_matrix)
		self._updateFunc = vizact.onupdate(0, self.Update)
		
	def UpdatePlayer(self):
		pos = self._view.getPosition(viz.VIEW_ORI)
		quat= self._view.getQuat(viz.VIEW_ORI)
		self._player_matrix.setPosition(pos)
		self._player_matrix.setQuat(quat)
		
	def Update(self):
		vizact.ontimer(0, self.UpdatePlayer)
Reply With Quote
  #2  
Old 11-20-2012, 04:27 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Can you post some example code where you import the module, create the Player object and get the error? The following worked fine for me. The only change I made to the module code was import the vizact library.
Code:
import viz
import PlayerModule
viz.go()

p1=PlayerModule.Player(viz.MainView)
Yes, it's possible to link the avatar to the viewpoint and then offset the avatar from the viewpoint using a link operator.
Reply With Quote
  #3  
Old 11-21-2012, 10:48 AM
tokola tokola is offline
Member
 
Join Date: Nov 2012
Posts: 67
Thanks a lot Jeff,

it was eventually my carelessness, since I was using another class name not residing in the module

The linking works fine besides the fact that I can't get rid of the robot in the first person view, so it collides with the viewpoint and sends it to outer space! I am using the 'renderOnlyToWindows' command but it doesn't work, I assume because of the linking. If, on the other hand, I get rid of the view collision, then I can get through walls which is undesirable. What's the solution in such cases?

I have a similar problem with a hand cursor I have linked with the view in 3D space (not screen) which is offset 0.2m in front of the view and the view collides on it only when I am moving straight in one of the 4 directions. The only solution I found was to set the collisionBuffer() to zero, but then whenever I am too close to objects the cursor disappears behind them. Also collideNone() applied to the hand object doesn't resolve the problem.

Isn't there a way in both these cases to reset the collision of the object, so that it doesn't collide with the viewpoint?!? It seems such an easy fix but still...

Thanks a lot for your feedback!
Reply With Quote
Reply

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to render a texture of the transparent object and then blur it whj Vizard 1 09-25-2012 03:15 PM
retrieve Object names Geoffrey Vizard 11 12-11-2009 04:26 AM
'int' object not callable enkeli Vizard 8 10-22-2009 04:12 PM
'ActionData' object is not callable error Enlil Vizard 2 06-09-2008 05:03 PM
rotate to object jargon Vizard 1 08-08-2005 12:20 PM


All times are GMT -7. The time now is 04:30 AM.


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