Search the Community
Showing results for tags 'ObjectMesh'.
-
Hi, I'm creating an application where I wish to create a mesh based on dynamic camera data that is provided by a depth sensor. I have created a similar application in Unity/Ogre/DirectX using the following process: 1) Create a Mesh of size depthImageWidth x depthImageHeight * 6 (a triangle mesh where each each depth pixel represents a triangle quad). 2) Pass DepthImage into a custom vertex/geometry shader that updates location of vertices. The shader requires all the intrinsic/extrinsic (4x4 KRt optics) to be passed into the shader (which has to be broken down into smaller vec4s or floatArrays) while continuously passing in the depthImage (via setProceduralImageTexture I assume) to update the vertices/geometry of the mesh I create in step 1. So in essence, I just need to create a mesh once that is of the correct size which will get updated by the shader based on the depth sensor data. I've hit a bit of a snag on the first step. I can create a mesh programmatically, but when the mesh becomes too large (e.g., 32768 in the below simple sample), Unigine seems to slow to a halt. Here's a simple example (a little messy from testing) I've been using for testing: Unigine::MeshPtr baseMesh = Unigine::Mesh::create(); int surfaceId = baseMesh->addSurface("baseMeshSurface"); int surfaceTarget = 0; int index = 0; for (int i = 0; i < 32768; i++) { baseMesh->addVertex(Unigine::vec3(0, 0, 0), surfaceId); baseMesh->addVertex(Unigine::vec3(index++, 0, 0), surfaceId); baseMesh->addVertex(Unigine::vec3(0, index++, 0), surfaceId); } int tIndex = 0; for (int i = 0; i < 32768; i++) { baseMesh->addTIndex(tIndex, surfaceTarget); tIndex++; baseMesh->addTIndex(tIndex, surfaceTarget); tIndex++; baseMesh->addTIndex(tIndex, surfaceTarget); tIndex++; } int ret = baseMesh->createIndices(surfaceId); baseMesh->createBounds(); baseMesh->createNormals(); baseMesh->createIntersection(); baseMesh->createTangents(); staticMesh = Unigine::ObjectMeshStatic::create("Static Base Mesh", 0); staticMesh->setMesh(baseMesh); Unigine::mat4 staticMeshTForm; staticMeshTForm.setIdentity(); staticMesh->setWorldTransform(staticMeshTForm); staticMesh->setMaterial("mesh_base", "*"); staticMesh->setProperty("surface_base", "*"); Unigine::MaterialPtr meshMaterial = staticMesh->getMaterial(0); meshMaterial->setTwoSided(1); I've switched out the mesh type with every option I can find in the c++ API: dynamicMesh = Unigine::ObjectMeshDynamic::create(1); dynamicMesh->setMesh(baseMesh); Unigine::mat4 dynamicMeshTForm; dynamicMeshTForm.setIdentity(); dynamicMesh->setWorldTransform(dynamicMeshTForm); dynamicMesh->setMaterial("mesh_base", "*"); dynamicMesh->setProperty("surface_base", "*"); along with alternate versions of the create/createMesh functions. Saving out a mesh to a fbx file and loading it into Unigine with the fbx importer seems to have no problem displaying a large mesh. Any thoughts?
- 1 reply
-
- Mesh
- ObjectMesh
-
(and 1 more)
Tagged with:
-
Hello, I have added few ObjectMesh using add_editor(new ObjectMesh("*.mesh")); after this I set transformation matirx & set material & property for all the mesh objects. Now I am trying to get access to the names of each of these meshes using ObjectMesh.getName(), but I am getting null values to all. Can anyone tell me at which stage the names will be assigned to dynamically add objectmesh, so that I can access them after it. Thanks
-
Hi all, I need build a widget windows to search target ObjectMesh and highlight it in scene, I referenced at sample selection_00: ------------------------ void update_scene() { Object object = NULL; while(1) { Vec3 p0,p1; Unigine::getPlayerMouseDirection(p0,p1); int ret[0]; Object o = engine.world.getIntersection(p0,p1,~0,ret); --------------------- I need a sample how to set data to specific ObjectMesh instead of getPlayerMouseDirection. Because my code doesn't work.... Anyone has any suggestion? Thanks a lot...