Search the Community
Showing results for tags 'ObjectMeshDynamic'.
-
[SOLVED] how to use addColor() function work of ObjectMeshDynamic class
jiaxin posted a topic in Rendering
Hello, I use unigine sim 2.0, when i use addColor() function of ObjectMeshDynamic class it can not work,the code like below: int init() { ObjectMeshDynamic mesh = new ObjectMeshDynamic(); // Create a dynamic mesh and add it into the editor. engine.editor.addNode(node_remove(mesh)); mesh.setWorldTransform(translate(Vec3(0.0f,0.0f,2.0f))); mesh.setMaterial("mesh_base","*"); mesh.setProperty("surface_base","*"); mesh.addTriangleQuads(1); // Allocate space in a vertex buffer and create vertex indices. mesh.addVertex(vec3(-1.0f,-1.0f,0.0f)); // Add vertices and assign texture coordinates, if necessary. mesh.addColor(vec4(1,0,0,1)); mesh.addVertex(vec3(1.0f,-1.0f,0.0f)); mesh.addColor(vec4(1,1,0,1)); mesh.addVertex(vec3(1.0f,1.0f,0.0f)); mesh.addColor(vec4(1,1,1,1)); mesh.addVertex(vec3(-1.0f,1.0f,0.0f)); mesh.addColor(vec4(0,0,0,1)); mesh.updateTangents(); // Calculate tangent vectors. mesh.updateIndices(); // Optimize vertex and index buffers, if necessary. mesh.updateBounds(); // Calculate a mesh bounding box. return 1;} How can i use it for work? Thanks. -
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:
-
[SOLVED] Modifying ObjectMeshDynamic with multiple surfaces.
sergey.shandar posted a topic in UnigineScript
Hi, Is there a way to change surface begin/end in ObjectMeshDynamic? Currently, I can only read begin/end of surfaces using getSurfaceBegin/getSurfaceEnd functions. -
Hi, I was hoping to use a skinned dynamic mesh object. This would enable us to morph a mesh to our chosen shape while maintaining support for bone based animation. Do you have something which we can use? It seems that the ObjectMeshSkinned class only acts a modifiable ObjectMesh. If you do not have one, what work around could you suggest if any? Thanks.
- 1 reply
-
- ObjectMeshDynamic
- ObjectMeshSkinned
-
(and 1 more)
Tagged with: