![]() |
|
#1
|
|||
|
|||
|
3D world editor
Hello,
Im creating a 3D world editor with Vizard. I want to add a model, place it and be able to replace the models. The user can navigate through the world with wasd and click a model and replace it. So far so good, but i'm experiencing some problems with the object placement. This is the code for a model to follow the mouse-cursor: Code:
# draw model on mouse position if(self.isDrawing): line = viz.MainWindow.screenToWorld(viz.mouse.getPosition()) x,y,z = line.endFromDistance(6) y = 0 self.model.setPosition([x,y,z]) Thanks! |
|
#2
|
|||
|
|||
|
You could try using a viztracker.MouseTracker. Here's a simple example:
Code:
import viz
import viztracker
import vizact
viz.go()
gallery = viz.addChild('gallery.osgb')
ball = viz.addChild('soccerball.osgb')
#Move the object with mouse movements and mousewheel
mousetracker = viztracker.MouseTracker()
link = viz.link(mousetracker,ball)
#Disable the link and place the object with a mousepress
vizact.onmousedown(viz.MOUSEBUTTON_LEFT, link.disable)
viz.mouse(viz.OFF)
|
|
#3
|
|||
|
|||
|
Thanks for your reply. I implemented the mousetracker and it is working better. When the user clicks the mouse i put the model on x,y=0,z so that the model is placed on the ground. I tried to catch a mouse_move event and set the position of the model to the ground so that the user can't move the object in the air or through the ground.
Code:
def onMouseMove(self,e): if(self.isDrawing): x,y,z = self.model.getPosition() self.model.setPosition([x,0,z]) EDIT: I try to get some collision with the mousetracker model but I dont know how, can someone give me some hints? Thanks Last edited by Ploep; 05-03-2012 at 03:31 AM. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| World Transformations | c4am95 | Vizard | 4 | 11-09-2010 01:50 PM |
| why is time faster in my virtual world? | billjarrold | Vizard | 1 | 11-24-2009 06:33 PM |
| button in the world | guxmy01 | Vizard | 1 | 06-10-2008 05:37 PM |
| What are the options for making a movie of a Vizard world? | Karla | Vizard | 1 | 05-13-2008 11:56 AM |
| General Questions about Vizard: World Viz | dav | Vizard | 5 | 08-28-2006 04:44 PM |