I used to use getBoundingBox() to get surface nodes if outside surface is flat. Now if the surface is not flat, what alternative method I can use to select nodes on the outside surface?? Thanks a lot
bottom_face=modelInstane.nodes.getByBoundingBox(xMin=X_tolernce*-1,xMax=Model_Width_I+X_tolernce,
yMin=Y_tolernce*-1,yMax=Model_Width_J+Y_tolernce,zMin=ZBot_Under-Z_tolernce,zMax=ZBot_Under+Z_tolernce)
If a mesh surface already exists in the model, then you can use:
# Considering "mesh_surf" is the mesh surface name.
inst = mdb.models['Model-1'].rootAssembly.instances['Part-1-1']
surf = inst.surfaces['mesh_surf']
surf_nodes = surf.nodes
Mesh surface is a surface associated with the mesh and NOT the geometry.
Mesh surface is created using element faces internally and geometry surface created using geometry faces.
Related
I am doing a project which need to measure volume or H x W x T of an object (in ex: A box).I have some level of understanding in applying filters and finding contours in openCV and managed to calibrate and get depth of an image by using Intel RealSense camera.
So i have few questions in my mind.
How to find edges and coordinate of the box only within the virtually designated area? I have tried to perform canny & hough but i couldn't think of how to get only the lines of the box? Should i do apply masking or should i put a reference plane (say.. a plywood bigger than the object to be measured?)
Will viewing from this angle and distance will be successful? Should cv2 Affinity work in this method?
Please let me know if you need more questions.
I have a 3D model for a coffee mug which is in .dae format. Now what I need is - to place a logo (a png image) in on it. How can I achieve this?
This isn’t really a Scenekit or IOS question. To apply a texture to a 3D model the model needs UV coordinates per vertex. The process of mapping a 3d model to a 2d texture is known as UV mapping ( https://en.m.wikipedia.org/wiki/UV_mapping ) and is done in 3d software like Blender, 3D studio max and similar packages, before the assets (model and textures) are used in Scenekit.
That said, in this case, because a mug is largely a cylinder, you could perhaps get away with using a SCNCylinder (which automatically comes with UV coords) and using the image with the logo, with a transparent background, as a texture for the cylinder. And then scale and position the cylinder over the mug and add it as a child node of the mug.
If you have your model in a node, yo can access the material trough the geometry like this
node.geometry?.firstMaterial?.diffuse.contents = <put your image here>
with this you will replace the texture of your geometry, don't really know if thats you want.
I am working on an Android application that slims or fatten faces by detecting it. Currently, I have achieved that by using the Thin-plate spline algorithm.
http://ipwithopencv.blogspot.com.tr/2010/01/thin-plate-spline-example.html
The problem is that the algorithm is not fast enough for me so I decided to change it to OpenGL. After some research, I see that the lookup table texture is the best option for this. I have a set of control points for source image and new positions of them for warp effect.
How should I create lookup table texture to get warp effect?
Are you really sure you need a lookup texture?
Seems that it`d be better if you had a textured rectangular mesh (or a non-rectangular mesh, of course, as the face detection algorithm you have most likely returns a face-like mesh) and warped it according to the algorithm:
Not only you`d be able to do that in a vertex shader, thus processing each mesh node in parallel, but also it`s less values to process compared to dynamic texture generation.
The most compatible method to achieve that is to give each mesh point a Y coordinate of 0 and X coordinate where the mesh index would be stored, and then pass a texture (maybe even a buffer texture if target devices support it) to the vertex shader, where at the needed index the R and G channels contain the desired X and Y coordinates.
Inside the vertex shader, the coordinates are to be loaded from the texture.
This approach allows for dynamic warping without reloading geometry, if the target data texture is properly updated — for example, inside a pixel shader.
How to draw each a vertex of a mesh as a circle?
You can do it using geometry shaders to create billboarding geometry from each vertex on the GPU. You can then either create the circles as geometry, or create quads and use a circle texture to draw them (I recommend the later). But geometry shaders are not extensively supported yet, even less in iOS. If you know for sure that that computer in which you'll run this supports it, go for it.
If geometry shading isn't an option, your two best options are:
Use a Particle System, that already handles mesh creation and billboarding. To create a particle at each vertex position use ParticleSystem.Emit. Your system's simulation space should be Local. If the vertices move, use SetParticles to update them.
Creating a procedural Mesh that already contains the geometry you need. If the camera and points don't move you can get away with creating the mesh in a fixed shape. Otherwise you will need to animate the billboarding, either on the procedural mesh, or by shader.
Update: 5,000,000 points is a lot. Although Particle Systems can work with big numbers by creating lots of internal meshes, the vast amount of processing really eats up the CPU. And even if the points are static in space, a procedural mesh with no special shaders must be updated each frame for billboading effects.
My advice is creating many meshes (a single mesh cannot handle that amount of geometry). The meshes will cointain a quad per point (or triangles if you dare, to make it faster), but the four vertices will be located in the same point. You then use the texture coordinates during the vertex program to expand it into a billboarding quad.
Assuming you are talking about 2D mesh:
Create a circle game object (or a game object with a circle shaped texture), and export it as a prefab:
var meshFilter = GetComponent(typeof(MeshFilter)) as MeshFilter;
var mesh = meshFilter.mesh;
foreach(var v in mesh.vertices)
{
var obj= Instantiate(circlePrefab, v, Quaternion.identity);
}
XNA contains a BoundingFrustum class which defines a frustum and facilitates collisions with Rays and other objects. However, the Frustum can only be constructed with a Matrix. I have a certain object which is created in a frustum shape using 8 vertices; what kind of Matrix should I create from these vertices in order to create a Frustum to represent it?
The object in question is a chunk of a sphere-- 4 points on the sphere's surface in the form of a square, extending downward into the origin of the sphere.
Normally to use a BoundingFrustum you pass it a Matrix that is a view matrix multiplied by a projection matrix:
BoundingFrustum frustum = new BoundingFrustum(this.viewMatrix * this.projectionMatrix);
There is no easy way to use that class to do what you describe unless you're particularly skilled in creating a Matrix by hand that combines what would normally be in a view matrix and projection matrix into something that represents your 8 corners.
What I would recommend is writing an algorithm to solve your problem.
// Do something like this for all 8 sides of the frustum, if the sphere lies outside
// of any of the 8 sides then it isn't in the frustum.
// Each plane will have a normal direction (the direction the inside is facing)
Vector3 normal = Vector3.UnitY;
// Creates a plane
Plane plane = new Plane(normal, 20.0f);
BoundingSphere sphere = new BoundingSphere(Vector3.Zero, 10.0f);
// This type is an enum that will tell you which side the intersection is on
PlaneIntersectionType type = sphere.Intersects(plane);
Thanks to Nic's inspiration and the help of a friend, I was able to write this class which represents a region defined by 8 points which has flat sides, such as a frustum or cube.
Here is the class.
It's important to note that, when passing in the constructor parameters, you choose a vantage point from which to view your region and stick with it.
Hope this helps anyone else who may run into this (obscure) problem to solve.