export blender file and import into scenekit does not work - swift

I tried to do this:
1) import file into blender (worked) -> it is the original file from apples vehicle example rc_car
2) exported it to .dae file (seemed to work, but unfortunately not in a way scenekit understands it properly)
(without any changes)
if i then start again the apple vehicle example, the car isn't visible and "invisible" hopping around
i did set global orientation to y_up and apply global orientation checked in blender when exporting.
what am i missing/making wrong?
p.s. what also is weird is that the dae file inside says:
Z_UP
although in export i defined y_up !?
I tried also other formats like obj, ply, alembic ...with the same result or nodes had other names than in the original.

This post: 56183036 is how I set the initial orientation and scale on my Turbo Squid models. It looks like you've already figured out that downloaded models don't always start with the rotation desired.
At the end there is a command line for setting Y-Up. Blender versions have changed since I did this, so I can't speak to y-up within Blender.
Models can be pretty finicky and some I've downloaded, just don't work after export. I found that trying a very simple model to make sure my math is working first, helps. A few times, my scale or color scheme was just way off and I didn't know it, couldn't see it, etc.
Hope that helps...

Related

Modifying .mo built-in files containing constants

As a part of my studies, I am interested in modifying some constant properties of a medium like water. For example, in Buildings.Media.Water that cannot be accessed by Dymola (I opened it in Visual Studio Code), I am going to change a constant e.g. density. Is there any way to do so? or should I do it through partial medium?
This question is also applied to some thermo-physical properties like thermal diffusivity that I could not find it in the constants of water.
I would be thankful for your advise.
In Dymola you should be able to modify constants if you double-click the package containing the constant(s) and then edit the text using the Modelica-Text view. This way you should be able to edit all constants in the package. Obviously write-access is required to do so (which you e.g. don't usually have for the MSL).
Using inheritance (partial medium) makes sense if you want to be able to switch between multiple media quickly or you don't have write access. For experimentation it should be fine to directly change values - being careful not to forget to revert...
Regarding the thermal diffusivity: it probably simply is not there. You could inherit from the original package and add it if that is the best solution to your needs.

How do I export Whitewater as VDB from Houdini to use in another program?

I've had great success exporting fire and smoke as VDB to then open in another 3D program, but I keep failing at exporting whitewater as VDB which can successfully be opened in the next program. It imports with the right attributes and dimensions, but nothing is visible within the object, just the boundary box.
I can't seem to find straightforward documentation on how to do it. My steps are to go into "whitewater_import" add a filecache node to the "render" null and save it to the frame range to disk with the proper naming convention.
I'm using Blenders experimental branch New Object Types. But again, I've had no problem with Fire and Smoke sims in this workflow, I think I'm just doing the process wrong for the whitewater.
Thanks for any help!

How can i cut/use part of object as object?

I have this lamp object. And i marked with a red circle the part i want to cut and make as a different object. Only the yellow part i want to make it object. So i can later use it in the game is object and also as item.
This is the lamp inspector:
Create a prefab of the lamp object and export it as a unity package.
You can then import it in other project as Custom package.
Source : https://docs.unity3d.com/Manual/HOWTO-exportpackage.html
Depending on the type of the model u have (obj, fbx etc) u need to go to 3d Modelling software like Blender or Max to modify the model. There u would be able to do any change to model u would like to including diving in too and maybe changing of shapes! Once done u can import them back into unity and have two different objects!
Taking the model into max as suggested would be the right idea. You'll likely take it in as an FBX.
Once you seperate the lamp from the post you may want to affect it's pivot.
For MAX look here
Be careful when exporting out the fbx again. I have noted that it seems to be best to export the model back out in metres. Automatic unit conversion may give unwanted results.

Changing the compression format of multiple textures

I'm using the following method to compress a bunch of textures:
public void OnPostprocessTexture (Texture2D t) {
EditorUtility.CompressTexture(t, TextureFormat.DXT5, 2);
}
The idea is to try to compress the texture when importing it. I have a project with many textures which are not using an optimal format.
The problem is that these changes are not saved anywhere, if you check the editor you'll see that the format remains the same. I can leave the script there and reimport everything in the build server, but I'd like a way to save these changes.
The only way I can think of this is to create another texture using the format I want and copying/replace the texture. Is there a better way to do this?
Edit
Doing some more tests, I noticed something strange: EditorUtility.CompressTexture is somehow compressing NPOT textures. This is before running the script:
And this is after running EditorUtility.CompressTexture:
How does this work?
While Sergey's answer helps me change the format, it won't compress NPOT textures and I really need to save these bytes.
You have 2 problems here.
Problem 1
You are trying to do it inside OnPostprocessTexture method, which is too late. You need to do it inside OnPreprocessTexture method instead.
Problem 2
EditorUtility.CompressTexture compresses a texture object itself (an object that resides in RAM), not a corresponding asset (an object that resides on disk).
The correct way of doing what you want to do is using TextureImporter.textureFormat.
Solution
Here is a working example:
public void OnPreprocessTexture()
{
TextureImporter textureImporter = assetImporter as TextureImporter;
textureImporter.textureFormat = TextureImporterFormat.DXT5;
}
Answer to comment
Another detail: I don't agree that CompressTexture creates an object in RAM instead of the disk, I think it creates a file inside the Library folder (that at some point is loaded into the RAM).
No, it doesn't create anything inside Library folder. It's quite easy to check:
Start with minimal Unity3D project: only one texture and only one editor script (a descendant of AssetPostprocessor with your OnPostprocessTexture method.
Open Library folder and write down number of files and their size.
Reimport the texture from Unity editor (it will result in execution of your OnPostprocessTexture method).
Open Library folder and see that no files were added and total size of files remains the same (at least this is how it works on my machine).
Answer to edited question
Doing some more tests, I noticed something strange: EditorUtility.CompressTexture is somehow compressing NPOT textures.
If I try to reproduce it, Unity outputs an error line to console: "!hasError".
Despite that Unity editor says that the texture is compressed with DXT5 after such a manipulations, the actual texture format is D3DFMT_A8R8G8B8 when you check it in a plugin.
One thing to note here. Actually, DXT compression doesn't require textures to be of power of two size. It requires them to be of size of multiple of 4. Hope this helps :)

CAEmitterLayer - kCAEmitterLayerRectangle render mode?

I want to make particles inside the rectangle.
What is wrong in this code? It is emitted from only the emitter position, not, random position in rectangle.
fireEmitter = [CAEmitterLayer layer];
[self.view.layer fireEmitter];
fireEmitter.emitterPosition = self.view.center;
fireEmitter.emitterSize =CGSizeMake(100, 100);
fireEmitter.renderMode = kCAEmitterLayerRectangle;
fireEmitter.emitterCells = [NSArray arrayWithObjects:fire, nil];
kCAEmitterLayerRectangle is not a valid value for renderMode. Instead you should use one of these values
kCAEmitterLayerUnordered
kCAEmitterLayerOldestFirst
kCAEmitterLayerOldestLast
kCAEmitterLayerBackToFront
kCAEmitterLayerAdditive
The kCAEmitterLayerRectangle value should be set as the emitterShape which defaults to kCAEmitterLayerPoint. That is why you are only emitting from a single point. The valid emitterShapes are:
kCAEmitterLayerPoint
kCAEmitterLayerLine
kCAEmitterLayerRectangle
kCAEmitterLayerCuboid
kCAEmitterLayerCircle
kCAEmitterLayerSphere
Please refer to the documentation for their meaning.
As David already pointed out the value you are using isn't valid for renderMode. It is used in emitterShape.
This can be a very frustrating error because Xcode doesn't give you a warning since they are of the same type (NSString). Such an error can easily be overlooked even having read the documentation.
Using a tool like Particle Playground (for UIKit emitters) or Particle Designer (for cocos2d emitters) can help a lot since they only allow the values as specified in the documentation.
They both let you configure your emitter layer/cell on your mac. Particle Playground exports the emitter as an objective c class for easy import in your project. Particle Designer exports in an exchange format which can easily be imported into the correct cocos2d emitter classes.
Full disclosure: I wrote Particle Playground and I do not have any affiliation with Particle Designer (even though I really like, use and recommend it for cocos2d projects).