Mesh Sculpting


#1

Hi all,

after eve | sun and eve | voronax I´ve been working on couple of other plug-ins that I want to release for free. One of them should be a sculpting tool for polygon meshes (like Zbrush, Blender, Sculptris, etc…have). And I would really appreciate some help. (I am using C++)

I ´ve been reading about sculpting algorithms and they are not that scary (any additional tip on literature would be appreciated). But in order to start I have to do something I haven´t really done before - use screen coordinates. I guess the guys from “uto” know exactly what Im talking about because their Mesh Paint uses the technique… Since the sculpting happens “in 2D” on the screen, I need to “shoot rays” from the screen through the mesh, look for intersections and then apply the sculpting algorithm around the intersection. (I guess this is the optimal method) So…my question is how does this really work? Or what is the best way to do it?

I´ve been looking at this example:

but i am still not sure how to get that ray, that vector from the 2d point “on the screen”… Is that ray maybe a positive Z or Y axis in the screen_cs that just needs to be transformed into the world_cs?

Would appreciate any thoughts on this…

Thanks!

Milos Dimcic
www.programmingarchitecture.com


(Dale Fugier) #2

Perhaps you could create a vector using the camera location and the world point that was transformed from the screen point?


#3

That sounds like a good idea. In that case:

1.How do I get the Camera Location? Isn´t there also a Camera vector (camera location to target location)?
2.And what would be the proper way to transform the screen point to the world point? Is the way from the example above the proper one?

  // Create a 3-D point
  ON_3dPoint pt( point.x, point.y, 0 );
  // Transform it
  pt.Transform( screen_to_world );

(I don´t get this transformation completely. What is exactly screen_cs? Is it the cs in which my viewport is XY plane, and Z axis is “perpendicular to the monitor”? If i click somewhere in the viewport, that doesn´t represent a “point” in space, it represents a line, starting from the screen and going indefinitely in the (minus) monitor-perpendicular direction…so how can I get a single point in space with this 2D to 3D transformation? Actually that infinite line (represented in the 3D space) is exactly the “ray” that I need)

Thanks Dale!


(Dale Fugier) #4

1.)

  ON_3dPoint camera_location = ON_UNSET_POINT;
  ON_3dVector camera_direction = ON_UNSET_POINT;
  CRhinoView* view = RhinoApp().ActiveView();
  if( 0 != view )
  {
    camera_location = view->ActiveViewport().VP().CameraLocation();
    camera_direction = view->ActiveViewport().VP().CameraDirection();
  }

2.) Yes, this is the proper way to transform a 2-D screen point into a 3-D world xy point.

ON::screen_cs is just an enum that tells the function what the source coordinate system is.