Do 3D models have size information? - unity3d

I know 3d model (.fbx, .obj etc) files have accurate scale information. But do they also have embedded unit measurement information (inches, centimeters)?
Is it possible to include units information where I draw a cube of 1*1*1 cm and then later generate another cube of 1*1*1 m. If so how interoperable are they?
Can I generate these 2 different size cubes in one software(say unity or 3ds max), export fbx file and then import it in another software like playcanvas. Will they recognize the different sizes ?

Objects imported to Unity3D usually comes with a renderer component, most likely, MeshRenderer, you can then retrieve the size info with below code snippet:
var renderer= GetComponent<Renderer<();
var bound = renderer.bounds;
var center = bound.center;
var radius = bound.extents.magnitude;

Related

how to break apart a large obj model and large single texture into smaller models with seaparate textures

I have a large 3d model in .obj format with a large 20000*20000 texture. (it was generated by photogrammetry) I need to keep all the texture detail but want to use it with the Unity game engine. Unity only supports textures up to 8192*8192 so i think i need to break the model into smaller pieces and generate smaller textures(below 8192) from the original file.
How can i do this so i get separate textures for each piece? i.e. each model doesn't use the same large texture? I have access to 3DS Max
This is not the website to get those kind of answers. Autodesk has their own websites for asking these types of questions.

How to convert `mapbox.mapbox-terrain-v2` tiles to heightmap tiles?

Mapbox provides a kindle of map tiles--mapbox.mapbox-terrain-v2 which is stored in pbf format and saved in mvt suffix. The height data is represented by contour (line).
I want to generate terrain with satellite texture and this height data in Unity3D. How could I convert this pbf data to a height map(a pixel for a height value)?
There is an example
https://api.mapbox.com/v4/mapbox.mapbox-terrain-v2/12/1171/1566.jpg?access_token=pk.eyJ1Ijoib2xlb3RpZ2VyIiwiYSI6ImZ2cllZQ3cifQ.2yDE9wUcfO_BLiinccfOKg
And the mvt file
https://api.mapbox.com/v4/mapbox.mapbox-terrain-v2/12/1171/1566.mvt?access_token=pk.eyJ1Ijoib2xlb3RpZ2VyIiwiYSI6ImZ2cllZQ3cifQ.2yDE9wUcfO_BLiinccfOKg
And the document of Mapbox:
https://www.mapbox.com/vector-tiles/mapbox-terrain/
https://www.mapbox.com/vector-tiles/specification/
MapBox have buid a Unity3d package: MapBox-Unity-SDK
SDK here : https://www.mapbox.com/unity/
Just click download.
This is an asset you can open in Unity directly.
Launch Unity3d, goto Menu>Assets>ImportPackage>CustomPackage
and select your downloaded file.
It will unpack some files and the folders, you will find into some exemples scene files to help you.
The current vector terrain layer isn't designed to be turned into a heightmap: we've processed terrain into elevation contours and lines, so turning those back into raw data would be difficult (much like doing the opposite: we do a lot of processing because it would also be difficult to transfer raw data and derive visual data).
A new and improved vector terrain model that supports your usecase is on the way, but we've also introduced RGB terrain, which was actually designed specifically to address cases like Unity - decoding the RGB-encoded elevation tiles tends to be much simpler in software.

Model imported from ZBrush into 3DS Max looks very distorted but only when rendered

I imported a very low poly object into ZBrush, sculpted it, then ZRemeshered and projected the details onto a lower poly object to make the normal map. After that, I exported the lower poly .obj into 3DS Max, where it looked perfect in the viewport but completely distorted when rendered. It doesn't have any materials or anything, this is just the model itself. Screenshots:
https://www.dropbox.com/s/qiswlfwlkf6f7hj/normal.png?dl=0
https://www.dropbox.com/s/cba1schavgl5mm8/distortion.png?dl=0
Thanks a lot!

XNA 4: import FBX problem

I have a problem with importing 3D model from FBX file.
Source model contains 575 objects + 1 camera and looks like this: http://habreffect.ru/files/23d/542fa7f67/source_model.png
In XNA prepared with content pipeline model contains 82 meshes, and 576 bones.
So, when I draw my model, I see only part of source model. Result picture like following:
http://habreffect.ru/files/28a/6e61c0215/Result_view.png
My drawing code:
GraphicsDevice.Clear(Color.CornflowerBlue);
Matrix[] transforms = new Matrix[_model.Bones.Count];
_model.CopyAbsoluteBoneTransformsTo(transforms);
foreach (var mesh in _model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.LightingEnabled = true;
effect.EnableDefaultLighting();
effect.World = transforms[mesh.ParentBone.Index] * _world;
effect.View = _view;
effect.Projection = _proj;
}
mesh.Draw();
}
base.Draw(gameTime);
How can I get all 575 meshes in my Model instance in XNA?
Thanks!
UPD: I tried to import my FBX model to 3ds max, select all meshes and use "Export selected". Result FBX file is 11x bigger. Then I add it as content to XNA project, loaded model contains all 575 meshes, and it rendered correctly.
Unfortunately, this manual converting method don't suit me - I need to render varied fbx models from mutable repository.
So, what FBX file are "good" for XNA content processor (I use XNA 4)?
So, on MSDN I found that FbxImporter designed to work with 2006.11 version of FBX format.
Recently Autodesk released FBX Converter 2012.1, which contains other tools, like FBX Eplorer, FBX Viewer.
FBX explorer can show structure of FBX file, and I compare exported from 3D MAX file, and source FBX file. They have different internal format. I tried to make following conversion: FBX -> Collada -> FBX, and the result FBX file contains similar to exported from MAX data structure.
So, I simply add the result FBX to Content of my XNA app, and it's rendered well :)
Another way to make it work is to use Autodesk FBX SDK to manually read model, and draw it in XNA.
Conclusion:
XNA FbxImporter correct work doesn't depend on version (2006, 2011, etc) and form (binary, ascii) of FBX file. Internal FBX data structure much more important.
To make FBX "readable" for XNA Importer you can use double conversion like FBX -> Collada -> FBX
You also can use FBX SDK to manually load data from FBX
Open the 3d model in latest 3dx max 2012 and export it in .fbx format. This .fbx is loaded properly with the xna model loader. While exporting you can even embed the resources, so you dont have to add textures to it through XNA.
You are using instancing in 3DS MAX. This isn't supported directly by XNA.
You have to draw the mesh for each instance bone yourself.
Ideally you would instead use DirectX instancing to draw each mesh once per bone in a single Draw() call.
But you have to roll your own code to do that, by converting the bones into instance vertices.
By default XNA only supports the most basic operations.

Put a Cinema 4D model and Texture into an iPhone App

Im an iPhone developer and i'm trying to get a 3D model that I create in Cinema 4D into an app im making. I have actually found a way to get the model in (by exporting it as a .dae or obj and using a python script) which works really well however I can't get the textures to come with it. My script actually can only handle 1 texture as well.
Basically I need to ether create and export a UV map in c4d (but I have no idea how to do this) or I figure out a way to read multiple textures into my Open Gl - ES app with a script or PowerVR. (this is probably better)
Sorry for the noob questions but im very new at the 3D world.
Cheers
I would recommend that you use Blender. Export your Cinema-4D model for Blender and use Blender to create UVMaps.
You need to make seams and unwrap the model. After that save a targa template for your texture, apply your texture on that targa. Save it as png or jpg. Apply that texture image to your model in Blender. Now you can export Wavefront OBJ file.
Use OpenGLOBJLoader class to render your model in iPhone.
And one more thing: you should invert (subtract from 1) texture coordinates on y axis in order to get your texture rendered properly.
For example, if you have texture coordinates like this:
vt 0.800008 0.400000
vt 0.800008 0.150000
...
make sure that you have them inverted like this:
vt 0.800008 0.600000
vt 0.800008 0.850000
...