Open csabau opened 2 years ago
Create a blank SwiftUI Xcode project
in that project, draw a line across the screen
Another option to potentially connect two joint would be by using an SNCCylinder ... I think? It seems to be taking in from: and to: arguments but they are SNCVector3 type, which I reckon it means it needs a z value. I don't have that as I've got CGPoints to work with and my skeleton is in 2D. Any work-arounds possible in that case? Is that even something I should be looking into?
At the moment I'm trying to see if I can replicate the body tracking functionality using Unity3D ARFoundation, which looks promising and potentially even more accurate, but so much to wrap my head around at the moment...
Create a blank SwiftUI Xcode project
in that project, draw a line across the screen
I'd do this first
At the moment I'm trying to see if I can replicate the body tracking functionality using Unity3D ARFoundation, which looks promising and potentially even more accurate, but so much to wrap my head around at the moment...
If this relates to drawing a Path, great. My thinking is that it is impertinent to this issue, so I'd place these notes elsewhere.
I've managed to get the drawing done.
I can now Draw a line using the new DrawLine class. This enables be to create a Bezier path, which is then assigned to a CAShapeLayer which I can customise more than a Bezier path (stroke width and transparency) and uses far less resources than drawing with Bezier as it's very low level.
I've set the initializer so that it takes in arguments that would help me create a custom path using CGPoint
values.
So I can draw a line between two (static) specific points and display it.
I now need to see how I can access the joint position data to send it to my class...
I now need to see how I can access the joint position data to send it to my class...
Is DrawLine
a good name for this? maybe LineView
?
also, this appears to be part of the ARSUIView2D
class, is that a good idea?
fd3a19db2b35466ef02608cdaebd96ce9d592262
If you've got this nailed, you can close this issue now
I’ve literally spent all day and still haven’t figured out how to draw a line between two fixed points. I’ve looked at drawing paths, shapes etc, nothing seems to work.
I’ve managed to understand how
makeCircle
works. It basically creates aUIView
, and it gets stylised so that it looks like a circle and it’s then attached to the joint. With a single path however, I find it more difficult. I could create aUIView
as a very thin rectangle so that it appears as a line, but it’s going to be of no use if I attach it to a joint, as the direction and length is determined by two joints constantly moving.I am inclined to think that the best way to draw a line would be using a
Path
(path.move
andpath.addLine
) because it uses CGPoints which (after I figure out how to use) I could have access to based on thejointScreenPoisitions
array. I’m struggling with drawing a path inside aUIView
. I’ve tried creating astruct Line: Shape
, drawing the path andreturn path
, Calle it inside a newUIView
(following themakeCircle
UIView) like so:Line().stroke(.blue)
but it didn’t work and Xcode was giving me a warning saying that(stroke)
will not be used. SO that tells me I'm doing something wrong but don't understand what it is.Can I even draw a path in a UIView? Should I create a separate file altogether that’s a SwiftUI file containing a normal View where I can actually draw a path, and then trying to use that View into a UIView? Sounds like a bit of an overkill for just a line.
But even with a line inside a UIView, would it still work? The UIView needs a frame defined. With the circles that works because the frame is always the square of the circle radius, it just changes location based on the centre with is given by the joint. But a UIView for a line would have a dynamic boundary box and I can’t define it based on 2 corners (say to give the CGPoints of the two joints connecting) but just one set of x,y. So would I create this UIView for the line as a full screen?
Or could / should I add a path as something else and not a UIView?