get coordinates from the .obj
is there a way i can get coordinates of a click point from the 3d object
Yes it is not so hard. U can wrap to a gesturedetector, and on x and y coordinates u just run your method on the mesh vertices. When the click x y pos is near on a coordinate u can set it to a list. After u just select the one whats z coordinate is the nearest to the camera. Thats all
@klaszlo8207 I'm not that familiar with gesture detector. An example would be great.Thanks
return new GestureDetector(
onTapDown: (TapDownDetails details) => onTapDown(context, details),
child: new Stack(fit: StackFit.expand, children: <Widget>[
new Container(color: Colors.white),
new Positioned(
child: new Text('hello'),
left: posx,
top: posy,
)
]),
);
void onTapDown(BuildContext context, TapDownDetails details) {
print('${details.globalPosition}');
final RenderBox box = context.findRenderObject();
final Offset localOffset = box.globalToLocal(details.globalPosition);
setState(() {
posx = localOffset.dx;
posy = localOffset.dy;
});
}
here
@klaszlo8207 works great
return new GestureDetector( onTapDown: (TapDownDetails details) => onTapDown(context, details), child: new Stack(fit: StackFit.expand, children: <Widget>[ new Container(color: Colors.white), new Positioned( child: new Text('hello'), left: posx, top: posy, ) ]), );void onTapDown(BuildContext context, TapDownDetails details) { print('${details.globalPosition}'); final RenderBox box = context.findRenderObject(); final Offset localOffset = box.globalToLocal(details.globalPosition); setState(() { posx = localOffset.dx; posy = localOffset.dy; }); }here
@klaszlo8207 works perfectly.assuming one had predetermined points how would one go about it .Thanks.
Sorry I dont understand what you wrote. What do u want?
I have an obj file i have all the vertices coordinates in xyz ...
example points
v 0.822220 0.216242 -0.025730 v -0.822220 0.216242 -0.025730 v 0.811726 0.220845 0.029668 v -0.811726 0.220845 0.029668 v 0.777874 0.214472 0.075458 v -0.777874 0.214472 0.075458 v 0.724172 0.189587 0.073470 v -0.724172 0.189587 0.073470 v 0.704111 0.180226 0.027508
how would i go about selecting say a point v -0.777874 0.214472 0.075458. in 2d
v 0.822220 0.216242 -0.025730 this is a vertex (Vect3) have x,y,z value x: 0.822220 y: 0.216242
but when You draw the triangle on a 2D surface it has a value like: 200, 250 (x, y)
so First you want to those vertices convert to 2d ints (in this library you can see how the programmer do that)
create a new List<Vect3> and XYZ values that is int
After you have the gesturedetector touched point, you just loop throug on that list and lets say you select the first one that is nearest to the camera (Z), and nearest to that XY touched value (lets say distance is 5)
@klaszlo8207 i have been trying to wrap my head about converting the points to 2d and ended up confused.an example would be really helpful.thanks. I'm trying to get a point in a 3d obj and place a Container(color:Colors.red) on the position.
Assuming i have a 3d car object I want to be able to select the door and move the select container to other parts within the door. Thanks