Creating text / number objects in ARKit - ios

I want to create some objects (boxes, cylinders, pyramids, doesnt really matter) which display text / a number on the side / on all of it's sides. Short of making individual materials with the numbers displayed on them by hand, is there a simple way to achieve this?
I am using Swift 4 in XCode.

First thing, please try not to be discouraged. Thank you for reaching out to the ARKit community on stack :-)
We are here to help each other.
(I do feel your pain…and why I am trying to help)
Here is an interesting stack page that has helped me with placing items on the sides of objects(like boxes cylinders, pyramids).
I hope it can help you or others.
SCNBox different colour or texture on each face
Rickster pointed out some other possibilities.
We all learn by sharing what we know.
Smartdog

Depends on what you mean by "by hand". If you want the text displayed on the surface of the geometry, like a texture map, then texture-mapping it is the way to go. If you draw your text into a UIImage, you can set that as the material contents, which is a bit more dynamic than, say, creating a bunch of PNGs that each have a different number on them. Just make sure to choose an image size/resolution that looks good at the size your objects are displayed at.

For anyone lost in the internet trying to find an answer to this it's stupidly simple. Use SCNText and set it as a node. I just wasted 7 hours of my life trying to make number .dae models position themselves next to each other because there is no mention of this feature anywhere.
I hope I saved you as much pain as I just endured discovering this.

Related

Blender correctly text the image on object

Is it possible in BLENDER version 2.82a to adjust the texture so that the corners of the tower are not moved up or down so that they fit correctly? Sorry for the bad English I use the translator. I'm attaching pictures. Thank you for the advice.I am a beginner.
yes it is possible. But you would need a seamless texture so it can repeat itself over the object. This is what happens when I copy and paste the texture multiple times next to each other:
The seams are clerly visible.
And any instructions for proper mapping? I've looked at the tutorials everywhere, but somehow I can't

Memory Usage of SKSpriteNodes

I'm making a tile-based adventure game in iOS. Currently my level data is stored in a 100x100 array. I'm considering two approaches for displaying my level data. The easiest approach would be to make an SKSpriteNode for each tile. However, I'm wondering if an iOS device has enough memory for 10,000 nodes. If not I can always create and delete nodes from the level data as needed.
I know this is meant to work with Tiled, but the code in there might help you optimize what you are looking to do. I have done my best to optimize for big maps like the one you are making. The big thing to look at is more so how you are creating textures I know that has been a big killer in the past.
Swift
https://github.com/SpriteKitAlliance/SKATiledMap
Object-C
https://github.com/SpriteKitAlliance/SKAToolKit
Both are designed to load in a JSON string too so there is a chance you could still generate random maps without having to use the Tiled Editor as long as you match the expected format.
Also you may want to consider looking at how culling works in the Objective-C version as we found more recently removing nodes from the parent has really optimized performance on iOS 9.
Hopefully you find some of that helpful and if you have any questions feel free to email me.
Edit
Another option would be to look at Object Pooling. The core concept is to create only sprites you need to display and when you are done store them in a collection of sorts. When you need a new sprite you ask the collection for one and if it doesn't have one you create a new one.
For example you need a grass tile and you ask for one and it doesn't have one that has been already created that is waiting to be used so it creates one. You may do this to fill a 9 x 7 grid to fill up your screen. As you move away grass that gets moved off screen gets tossed into the collection to be used again when the new row comes in and needs grass. This works really well if all you are doing is displaying tiles. Not so great if tiles have dynamic properties that need to be updated and are unique in nature.
Here is a great link even if it is for Unity =)
https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/object-pooling

Triangle, with 3 levels, containing text on iOS

I need some advice with my current project. The big problem being, I'm an android dev, helping out on iOS for the next few days.
I need to create a triangle, with 3 levels of text (as seen in the image below). Just adding labels at the different levels is leaving me with a lot of unused space. I have also though of using CGMutablePathRef to create a triangle, but it doesn't seem I can add a label to it, like you can to a CALayer. Or am I missing something?
Please, any advice would be appreciated (and example code even more so, as my iOS skills are still quite shocking).
Regards

How to check intersection of two images that aren't rectangular?

New user to the site, but I have used it in the past so I felt it best to ask my question here, for the best chance of getting a response.
What I'm dealing with is one object, this being the sprite for my latest app, which I need to check for when it comes in to contact with another object, in this case, a tunnel which will curve.
Now, I'm aware of CGRectIntersectsRect, however I can't see that being helpful, as if I've got 2 UIImages, that being the top and bottom of a "mountain", and said pieces curving, there's no doubt that the sprite would touch the "rectangle".
What I need is something to trigger when the sprite hits the actual wall, however my limited knowledge of Objective-C isn't helping my case.
I imagine someone out there will know what I can do to resolve this, as for all I know it could be a simple solution.
Thank you in advance everyone!
First, I'd probably not build these basic pieces yourself. For iOS 7, you can use SpriteKit, which is built-in. If you want to support older versions of iOS, look at cocos2d (it's good for iOS 7, too).
But to the question, one approach for detecting arbitrary overlaps is to draw both objects into a buffer and check if there are any overlapping pixels (for instance, by drawing one in in pure red, and another in pure green, and then looking for pixels that have both). For a discussion of how to do this kind of thing in Core Graphics, see Clipping a CGRect to a CGPath, which provides sample code for the simplest version (checking for the intersection of a rectangle and curve), but the same approach can be used more generally. Note that this drawing can get expensive if you're doing it constantly, so usually you first check whether the bounding rectangles overlap. That tells you whether it's even worth the trouble to look closer.
But first I'd look at SpriteKit.

Stretching a UIImage across the length of a UIBezierPath

What I basically need to achieve is a Fruit Ninja - style "slash" effect, where the "slash" trails the user's touch and follows the shape of the user's gesture, and is thinner the longer the distance the user has swiped.
The simplest way to achieve this seemed to be to collect all the points the user passes through in a UIBezierPath, and "stretch" an image through the length of the BezierPath. This would achieve the kind of "trailing" effect I was looking for and also ensure that the line is thinner if the distance travelled is longer.
However I can't seem to find a way to actually implement this. Is this even possible?
Alternatives? Thanks.
P.S: This is for a low-medium priority section of a regular app and not a game, so I would like to avoid having go down to OpenGL and spend a lot of time to achieve this (with completely custom drawing, etc). Something at the SDK level would be preferred, and if that's not possible at all, we'll just figure out a different UI.
Thanks!
For pretty easy-to-use stretching teqhniques of images/views you could look into
https://github.com/hfossli/AGGeometryKit/
I recommend trying to draw using CoreGraphics. See this link
http://www.effectiveui.com/blog/2011/12/02/how-to-build-a-simple-painting-app-for-ios/
Okay. Maybe you can use this.
https://github.com/hfossli/AGDraw
Just something I wrote a while ago. Hit clear and try to draw something (clear will toggle between two types of strokes). You'll see the width of the penstroke will increase with the velocity you use.. I guess that fits your need. If you fix some bugs, please make a pull request. You are free to use the code, but I will add a MIT license later.

Resources