> 1 - mouse = camera.coord2d_to_3d(event[2], event[3])
> 2 - new_center = camera.position()
> 3 - #context = soya.World(scene)
> 4 - context = scene.RaypickContext(new_center, 1)
> 5 - result = context.raypick(camera.position(),
> camera.vector_to(mouse))
> 
> As in the tutorials, I try inestead of the contex.raypick the 
> self.raypick but id didnt work, I see that self refers in the examples
> 
> to soya.World, so I tried uncommenting the line 3 and comenting the 
> 1,2,4 but it didnt work..

If you don't want to create a context, you should not create a new world
!
Typically you should use the same world that you would use to call
RaypickContext.
E.g. :

1 - mouse = camera.coord2d_to_3d(event[2], event[3])
2 - new_center = camera.position()
3 - context = scene
5 - result = context.raypick(camera.position(), camera.vector_to(mouse))


> palm_model = soya.Shape.get("palm_soya")
> palm = soya.Volume(scene, palm_model)
> palm.set_xyz ( impact.x, impact.y, impact.z)
> palm.solid = 1
> 
> I exec the same raytrace and it returns the same point with the same 
> parent object, the ray goes through the recently placed palm and I
> liked to be able to select that palm tree, I tried several things,
> nothing work..

You mean you want to get the "palm" object ? You can get it as
impact.parent.

BTW, as the parent of impact is not always the scene, you should replace
:

  palm.set_xyz ( impact.x, impact.y, impact.z)

by :

  palm.move(impact)

move performs frame coordinate conversion automatically if needed.


> The other problem is more strange, with that same code, when it places
> 
> the palm (when I click with mouse1) if a select a point far away from 
> the center it adds a extra offset to the impact point; For example I 
> select a screen point (lets say in a 1024x768 screen)  that is in 
> 1000x700 inestead of placing the palm shape in that point it places it
> 
> in the 1100x710 something like that, the farther away from the center 
> the bigger the "offset" I get.


hum... maybe the formula for coord2d_to_3d is not perfect (as it is
partially empirical).

Jiba

Reply via email to