How to scale 3D object in Xcode using Inspector? - ios

I'm trying to scale my 3D object which I've exported from Blender in .dae format (In Xcode -> Inspector). When I've changed the value of the scale parameter, Bounding Box didn't change.
Here is what I've in Xcode.
Before scale changing:
After scale changing:
And there is no effect in the simulator too.
What I am doing wrong? When I've exported my model from Blender, I've set these properties, maybe the issue is with my export:
I need to be able to resize the object in Xcode to make it bigger or smaller on the actual screen. How to change Bounding Box value here?

After combining a few good answers, I've found a solution:
Blender
First of all, I need to group all my objects inside the mouth in one. In Blender, I've selected all objects which I want to group in Outliner (press Shift and select) and I've pressed Ctrl+J.
Then, I need to check the 3D manipulator position. Go to Editor Mode, select all vertexes with A, press shift+S and select “cursor to selected”.
Switch to Object mode, press SHIFT+CTRL+ALT+C and select Origin to 3D cursor.
Xcode
In Scene Graf press + and add (It will add an empty node)
Put your objects inside a new node.
When you'll change the scale of your objects, the parent's node Bounding Box will change and you'll see it properly in the simulator.

Related

The object gets blocked by the background in Spark AR

I have a Spark AR effect with custom background (which is masked out where a person is detected).
I have also a 3d object attached in front of the user forehead.
The problem is that the object gets hidden when the user goes slightly farther from the camera, because(?) the view gets blocked by the custom background which becomes closer to the camera than the object.
Is there a way to keep the object fully visible, no matter how far the user goes from the camera?
The only workaround I can make up is to prevent the z coordinate from being less than zero, but it's far from ideal, because I need to keep the object at the same distance to the forehead.
You need to uncheck "Use Depth Test" and "Write to Depth Test" in the material for the object you would like to remain visible.
In the Scene hierarchy, move the object above your canvas/background.
so on the material property u will see Advance render option and if u click it u will see " use depth first " and u have to uncheck it . make sure ur rectangle is before the bg rectangle

ARKit - Adding texture to object in Scene Editor

This would be working perfectly if it weren't for one aspect of what is going on. When I add the texture to the object (drag and drop it onto the object from the menu in the bottom right) it adds it exactly where I want, but it also adds it around the object large (too large for the object) and all blurred, and I want it to just stay white:
Before:
After:
I want it to stay in the middle where it is, and have the surrounding area be the original color of the shirt.
UPDATE
I created a static physics body, and that allowed me to get to the materials of the Plane object. But I can't remove the coloring around the image.
UPDATE
Also, I exported the texture from Blender with Save Image As from Blender UV/Image Editor, I'm not sure if that is the correct way to export a texture to be used correctly in xcode.
UPDATE
I used the .obj file instead and got this far, but when it renders in the app there is no image, only they gray tshirt.
To export a .dae including textures from Blender, make sure to select UV Textures and the Copy checkbox unter Texture Options, in the Export options, during export. Then, in xcode, your texture will be available as a material under the Materials tab, and you just have to drag the image that you were using with the texture, onto the material (make sure you have the correct material selected) in the Scene Editor in Xcode.

What is the best settings for ARKit 3D models

I am exporting 3D models from Cinema4D with .dae file format, and drag them into art.scnassets. Every time I compile the project the 3D object are too big or not in the right position. What is the best setting for models which we want to use in iOS ARKit ? I have search many topics and still not a final solution.
Edited :
I have found that if your object is for instance 50cm in cinema, you need to export it as .dae (1.4, important!) and then select 0.001 meters as scale.
Also, make sure that you position the object at 0, 0, 0 (even if you want it positioned somewhere else in the end, centering it will make editing & repositioning in Xcode easier).
After importing, inside Xcode, click on the .dae file. Select the object in the scene, open the right inspector menu and navigate to the identity inspector.
Then press is movable. This will convert the file to .scn which is better for editing. (is movable should still be unchecked after conversion, if not uncheck, or leave as is)
Then, open the new .scn file and click on your object. You'll see its scale on the right in the identity inspector. If it's still not right, you can change the scale of the bounding box there and also position the object in the scene.

Get SCNMaterial's frame

I have an iPhone 3D model in my SceneKit application, it has a material which I get. It is called iScreen (the image that "is on" the screen of the iPhone):
var iScreen: SCNMaterial!
iScreen = iphone.geometry?.materialWithName("Screen")!
I decided to somehow project a webView there instead of an image.
Therefore I need the frame / position / size of the screen where iScreen "draws" to set the UIWebView's frame. Is that possible?
Note
Of course I tried position, frame, size, etc. but that all was not available :/
you will first have to know to which SCNGeometryElement the material applies (an SCNGeometry is made of one or several SCNGeometryElement).
That geometry element is essentially a list of indices to retrieve vertex data contained in the geometry's SCNGeometrySources. Here you are interested in the position source (it gives you the 3D coordinates of the vertices).
By iterating over these positions you'll be able to find the element's width and height.

Xcode SpriteKit Designer Clear Background Red X

I'm not sure what the issue is, but I'm trying to design a level in Apple's Sprite Kit editor, and I'm running into a problem with SKSpriteNodes that have a transparent background. Sometimes the background doesn't appear as clear. Instead, SpriteKit seems to load a Red X as a background image.
Naturally, I can't have this. Also, it's a problem because I really should be doing all of the level design in the editor instead of manually adding sprites in my Scene code.
Has anyone come across this problem? Could it be a bug in SpriteKit Designer? (There are a number of issues I've had with it since starting to use the tool).
Here is a photo of what it looks like:
I found a kinda hacky way to solve it. Basically, as uchuugaka said, the Red X appears when Sprite Kit fails to load a texture. If you want a clear background, you have to load a clear png file as the background of the sprite. There is no "No Texture" option currently available in the Sprite Kit designer.
Take these steps.
1.) Open any .png file with some transparency in it.
2.) Copy an arbitrary rectangular section of pixels.
3.) Create a new file with said arbitrary pixels.
4.) Save this file as your "clear.png" and import it into your project.
5.) Click on the sprite node with the Big Red X so you can see its setting. Take a screenshot of its position, size, etc. using preview. These settings will get erased when you swap the texture over to clear.png
6.) Swap the texture to clear.png
7.) Re-enter the sprite settings from your screenshot.
8.) Because SpriteKit Editor is currently horribly terribly flawed (see post above), you will need to reset your sprite's physics properites. Set the physics body to none. Then set it to bounding box or circle or alpha mask or whatever you had earlier.
9.) I hope you remembered your collision mask, category mask, and other physics body properties because they just got reset to the default. Re-enter what you had earlier or you will get a very unexpected result.

Resources