Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by pooyax · Apr 18, 2011 at 06:53 PM · objectdynamic

RealTime Dynamic Modeling

Hi All I am working on a scientific application to show bacterias activities in a real-time 3D viewer. I am pretty good in C# but i don't have any idea about 3D viewing. I have a big 3D matrix which is changing per millisecond and I want to create an object based on that matrix on Unity. I was wondering if you guide me to to create a dynamic 3D object on unity in real-time.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Apr 18, 2011 at 10:00 PM 0
Share

Sounds very interesting, but can you go a bit more in detail? how big is your matrix (and what dimention count) and what do you want to render actually? just a "sprite" for each bacteria? what information do you need to display? does each cell have a fix position (in 3D space)? in other words do you want to display your matrix as plane or cube rasterized? Another thing: you said you update your matrix (once) per millisec.? In Unity you're bound to the actual (drawing) frame rate. You can use seperate threads but the whole Unity api isn't thread safe, so it won't help much.

6 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by kennypu · Apr 18, 2011 at 07:58 PM

you basicly edit the mesh data of an object( http://unity3d.com/support/documentation/ScriptReference/Mesh.html ).

You can check out examples in the procedural programming examples here: http://unity3d.com/support/resources/example-projects/procedural-examples.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Mortennobel · Apr 18, 2011 at 08:06 PM

What use are asking is if Unity supports volumetric rendering (of your data stored in a 3D matrix).

The short answer is no. At least there is no simple way to do it.

You could try to visualize your data as procedural generated voxels - but this may be too slow for large data sets.

A more advanced approach is to do ray-tracing in the Cg shader. This is indeed possible - but requires that you know how to program Cg shaders in Unity.

More info about volumetric rendering: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch30.html

Also checkout the wikipedia about volume rendering: http://en.wikipedia.org/wiki/Volume_rendering#External_links

A way to get started with procedural mesh generation in Unity can be found on my blog: http://blog.nobel-joergensen.com/2010/12/25/procedural-generated-mesh-in-unity/

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pooyax · Apr 18, 2011 at 08:52 PM 0
Share

I have read "procedural mesh generation in Unity" it was awesome, but my raw data is a bulk of points in a 3D world. special device scans each millisecond and returns 10,000 points like (x,y,z). Do you think that this way is feasible?

avatar image Mortennobel · Apr 18, 2011 at 09:12 PM 0
Share

No. I don't think Unity is the best tool for this problem.

avatar image
0

Answer by DaveA · Apr 18, 2011 at 09:11 PM

You can generate this scene, either at Startup or in an Editor script, something like:

var dataPoint : Transform; // assign this to something in the Inspector var dataPoints : Transform[]; // this could be a multi-dim array but I forget exact syntax offhand

 function Start()
 {
   dataPoints = new Transform[33*33*33]; // holds our new datapoint objects
   for (var x = 0; x < 33; x++)
    for (var y = 0; y < 33; y++)
     for (var z = 0; z < 33; z++)
      dataPoints[x+y*33+z*33*33] = Instantiate (dataPoint, new Vector3(x,y,z),Quaternion.identity);

 }

Then you have an array of your points. The thing you assign to dataPoint could be like a particle or cube or something very simple. Billboarded triangle would be cool and fast, but billboarding 10000 objects might be slow, unless your view never changes (boring). Tetrahedron is the next simplest object. Anyway, you'd grab your objects and set them something like:

Update()
{
   for (whatever changed, get index to the object)
     dataPoints[x+y*33+z*33*33].GetComponent(Renderer).material.color = new Color (somethng based on the data);
}

But you'd also need like 10000 separate materials, so read this: http://unity3d.com/support/documentation/ScriptReference/Renderer-material.html

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DaveA · Apr 18, 2011 at 09:15 PM 0
Share

That said, I'd also look into a shader for that ;-)

avatar image Bunny83 · Apr 18, 2011 at 09:50 PM 0
Share

You actually don't need to create 10000 materials ;) Every mesh rederer owns his own material instance that get copied from the shared$$anonymous$$aterial which have been assigned to the renderer in the editor. I also wouldn't use seperate gameobjects objects for that amount. I would use a logical object (like the particleEmitter do) and use just a few renderer. Just to have it mentioned: your examples are in JS ;)

avatar image DaveA · Apr 18, 2011 at 10:11 PM 0
Share

Thanks Bunny83. Yeah, my examples are also psuedo-code! Good points all. He could also try sub-meshes fwiw. If there are a limited number of representations (I was assu$$anonymous$$g color, but it could be anything), then there could be one mesh per appearance, and just assign things as needed, but Combine$$anonymous$$eshes would be too slow for his cycle time. Very interesting problem.

avatar image pooyax · Apr 19, 2011 at 11:55 AM 0
Share

Thanks for your attention to my problem, I am working on it and i will let you know my result.

avatar image
0

Answer by pooyax · Apr 19, 2011 at 07:02 PM

Dear Bunny83 the result of scan comes up each 30 millisecond. this device scans the surface of bacterias and returns bunch of points in 3D world. in this case, Z axis determines our depth. regardless of shape of that, i wanna model it on a 3D viewer.The number of matrix element is constant (10,000) and i also know that some of them are not changed.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Jordane Almeida · Jul 31, 2012 at 08:40 PM

I've got a problem, not yet assimilated how to make the UVs of a cube here is the code can someone help me?

using UnityEngine; using System.Collections;

[RequireComponent (typeof (MeshCollider))] [RequireComponent (typeof (MeshFilter))] [RequireComponent (typeof (MeshRenderer))]

public class Create_Cube : MonoBehaviour {

public Color ColorBloc; public Texture2D Textura;

// Use this for initialization void Start () {

 Mesh mesh  = new Mesh ();
 mesh=GetComponent<MeshFilter>().mesh;
 

Vector3 p0 = new Vector3(0,0,0); Vector3 p1 = new Vector3(1,0,0); Vector3 p2 = new Vector3(0,1,0); Vector3 p3 = new Vector3(0,0,1); Vector3 p4 = new Vector3(1,0,1); Vector3 p5 = new Vector3(1,1,0); Vector3 p6 = new Vector3(0,1,1); Vector3 p7 = new Vector3(1,1,1);

 mesh.vertices = new Vector3[]{p0,p1,p2,p3,p4,p5,p6,p7};

mesh.triangles = new int[]{ 0,2,1, 1,2,5, //face 1 3,0,1, 1,4,3, //face 2 0,3,2, 2,3,6, //face 3 1,5,4, 5,7,4, //face 4 6,3,4, 6,4,7, //face 5 6,5,2, 7,5,6 //face 6 };

//mesh.uv = new Vector2[]{new Vector2(0.0f,0.0f),new Vector2(1.0f,0.0f),new Vector2(0.0f,1.0f),new Vector2(0.0f,0.0f),new Vector2(1.0f,0.0f),new Vector2(1.0f,1.0f),new Vector2(0.0f,1.0f),new Vector2(1.0f,1.0f)};

 mesh.uv = new Vector2[]{
                        new Vector2(0,0), new Vector2(0,1),

                        new Vector2(1,0),new Vector2(0,1),

                        new Vector2(1,1), new Vector2(0,0), 

                        new Vector2(0,0), new Vector2(1,0)
                        };
      

 renderer.material = new Material(Shader.Find("Diffuse"));

renderer.material.mainTexture = Textura; renderer.material.color = ColorBloc;

mesh.RecalculateNormals(); mesh.RecalculateBounds (); mesh.Optimize();

} // Update is called once per frame void Update () {

} }

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Dynamically get variable from gameobject script 1 Answer

Dynamically Adding Objects 1 Answer

Cannot access class array in dynamically created object 1 Answer

How to access the data in a list that save any class inside 1 Answer

Need some help with dynamic object fracture 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges