- Home /
Pre-Normalized cube model?
I need a normalized cube model/prefab that has been pre-generated, rather than normalized in code.
Edit: If people could stop telling me about Unity's primitive cubes, that would be great. :P This is a cube that has had it's vertices normalized, as is what I'm looking for:
Anyone know where I can find one?
What about the basic prefab cube?
If not, make one in Blender.
tbh all I see is a mesh. There is no indication of 'normalised' there. To me, normalised means that the face is set to be outwardly perpendicular. There are no faces on that cube. $$anonymous$$aybe you should explain what you mean by normalised...in words.
Edit: If people could stop telling mr about Unity's primitive cubes, that would be great. :P This is a cube that has had it's vertices normalized, as is what I'm looking for:
And if you didn't want this maybe you should have specified?
Umm... that normalises a vector to have magnitude 1. That can't be directly applied to a cube. Explain what you mean by "normalised".
I'm finding you quite offensive Jazzer008. Try to be civil ins$$anonymous$$d of throwing around comments. I'm here trying to help you and you are being quite rude about it. Frankly if I hadn't bothered your question probably would have disappeared in to the realms of UA unanswered...
The reason no-one understands is because you haven't made much sense - the "normalised cube" you're talking about isn't standard ter$$anonymous$$ology, and since that's the only thing you said, of course no-one knows what you're talking about. Try saying something along the lines of: "I want to normalise the position vectors of all the vertices of a cube such that it approximates a sphere", which is a more accurate description of what you want, and highlights why a standard Unity cube won't work (as only has 8 vertices).
As for how to do it, there is a free script hanging around somewhere that lets you export a mesh from Unity. If you first create a cube with enough vertices in a separate modelling program, you can then import it into Unity, run a script to deform the mesh, and then export it using the aforementioned script, you can use the exported model for what you need.
Answer by meat5000 · Sep 07, 2013 at 08:03 PM
Here is the answer and you won't like it.
Make a new project and scene. Use code to modify your cube, then Save the results into a separate object or prefab. Use that object/prefab in your other project. Look up Procedural Examples, everything you need should be in it.
Answer by karl_ · Sep 07, 2013 at 05:49 PM
I think you may have some terms confused. Normalization is used to clamp values to a specific range (0-1) with relative differences remaining intact (see http://en.wikipedia.org/wiki/Normalized_vector). Saying 'normalize a cube' does not make much sense, unless you're specifically referring to vertex normals.
The image you've linked to shows a subdivided cube rendering as a wireframe. Unity has a MeshTopology enum that can be used to build meshes using (among other things) lines. Here is a quick example showing the use of this class. It creates a new menu item
GameObject->Create Other->Create Wireframe Cube
that builds a wireframe cube.
using UnityEngine;
using UnityEditor;
using System.Collections;
public class CreateWireframeCube : Editor {
[MenuItem("GameObject/Create Other/Wireframe Cube")]
public static void InitWireCube()
{
float scale = .5f;
Mesh m = new Mesh();
m.vertices = new Vector3[8]
{
new Vector3(-1f, -1f, 1f) * scale,
new Vector3(1f, -1f, 1f) * scale,
new Vector3(-1f, -1f, -1f) * scale,
new Vector3(1f, -1f, -1f) * scale,
new Vector3(-1f, 1f, 1f) * scale,
new Vector3(1f, 1f, 1f) * scale,
new Vector3(-1f, 1f, -1f) * scale,
new Vector3(1f, 1f, -1f) * scale
};
m.subMeshCount = 1;
m.uv = new Vector2[]
{
Vector2.zero,
Vector2.zero,
Vector2.zero,
Vector2.zero,
Vector2.zero,
Vector2.zero,
Vector2.zero,
Vector2.zero
};
m.SetIndices(
new int[]
{
0, 1,
1, 3,
3, 2,
2, 0,
0, 4,
1, 5,
2, 6,
3, 7,
4, 5,
5, 7,
7, 6,
6, 4
},
MeshTopology.Lines,
0
);
GameObject go = new GameObject();
go.AddComponent<MeshFilter>().sharedMesh = m;
go.AddComponent<MeshRenderer>();//.sharedMaterial.color = Color.green;
}
}
See also:
http://docs.unity3d.com/Documentation/ScriptReference/Mesh.html http://docs.unity3d.com/Documentation/ScriptReference/Mesh.SetIndices.html http://docs.unity3d.com/Documentation/ScriptReference/MeshTopology.html
Thanks for the help but I'm looking to find a model cube that has had it's vertices Normalized.
You can see the difference between a normal cube and a cube that has had it's vertices normalized in the animated image I posted.
Answer by _dns_ · Sep 07, 2013 at 05:54 PM
I think what is called a "normalized cube" is this "spherized" cube we see next to the regular cube. It could be done by code easily, in Unity script or by a script in Blender for example. Maybe this kind of primitive already exists in Blender.
I guess some people may called it 'spherized', but it's accomplished by passing the vertices through the normalize function. And yes I can easily do it in code, but my issue is that I don't want to spend any runtime generating the normalized cube, I want to have it pre-generated. :P
I've already checked blender, unfortunately either nothing exists or I've yet to find it, even function or modifier wise.
Your answer
Follow this Question
Related Questions
Generate colliders on a prefab 0 Answers
Custom prefabed spawner 2 Answers
can you make a prefab but without a model? 3 Answers
Only instantiate if clear space beside prefab 1 Answer
New prefab system problem 1 Answer