How to flip a VRML file (.wrl), or flip the VR model in Matlab - matlab

I have a fairly complex VRML model of a prosthetic right hand in a .wrl file (3 Megabytes) which I am manipulating (animating according to commands) in Matlab. I'd like to make a mirror image (horizontal flip) of the file (to be a left hand). I do not mind whether I use a free program to process the file (which I imagine should just involve mirroring all the horizontal co-ordinates) or if there is a Matlab command that can flip a VR model, but I haven't been able to find a solution. There's nothing else in the "world" so everything within the file can be flipped.
There are named transforms in the file and I need them to keep their names, because those joints get animated, but it's not a problem if I have to change the sign of the rotations to get things moving in the correct mirrored direction.
I'm just looking for a simple and free solution.
Thanks!

I wouldn't suggest to do this manually. The easiest solution would be to export your model to a .max or any other file that you can open with a 3D modeling program (3dsmax, DeepExploration, Maya, etc.) Once you have the new file, that you can open with any of these programs, I think it's much easier to do your job. Usually you can do it using the interface by dragging or clicking buttons, not manually going through the coordinate values :)

Related

Extracting 2D surface from 3D STEP model

I'm trying to figure out a good way to programmatically generate contours describing a 2D surface, from a 3D STEP model. Application is generating NC code for a laser-cutting program from a 3D model.
Note: it's easy enough to do this in a wide variety of CAD systems. I am writing software that needs to do it automatically.
For example, this (a STEP model):
Needs to become this (a vector file, like an SVG or a DXF):
Perhaps the most obvious way of tackling the problem is to parse the STEP model and run some kind of algorithm to detect planes and select the largest as the cut surface, then generate the contour. Not a simple task!
I've also considered using a pre-existing SDK to render the model using an orthographic camera, capture a high-res image, and then operating on it to generate the appropriate contours. This method would work, but it will be CPU-heavy, and its accuracy will be limited to the pixel resolution of the rendered image - not ideal.
This is perhaps a long shot, but does anyone have thoughts about this? Cheers!
I would use a CAD library to load the STEP file (not a CAD API), look for the planar face with the higher number of edge curves in the face loop and transpose them on the XY plane. Afterward, finding 2D geometry min/max for centering etc. would be pretty easy.
Depending on the programming language you are using I would search for "CAD control" or "CAD component" on Google combining it with "STEP import".

How can I make dynamically generated terrain segments fit together Unity

I'm creating my game with dynamicly generated terrain. It is very simple idea. There are always three parts of terrain: segment on which stands a player and two next to it. When the player is moving(always forward) to the next segment new one is generated and the last one is cut off. It works wit flat planes, but i don't know how to do it with more complex terrain. Should I just make it have the same edge from both sides(for creating assets I'm using blender)? Or is there any other option? Please note that I'm starting to make games with unity.
It depends on what you would like your terrain to look like. If you want to create the terrain pieces in something external, like Blender, then yes all those pieces will have to fit together seamlessly. But that is a lot of work as you will have to create a lot of pieces that fit together for the landscape to remain interesting.
I would suggest that you rather generate the terrain dynamically in Unity. You can create your own mesh using code. You start by creating an object (in code), and then generating vertex and triangle arrays to assign to the object, for it to have a visible and sensible mesh. You first create vertices at specific positions and then add triangles that consist of 3 vertices at a time. If you want a smooth look instead of a low poly look, you will reuse some vertices for the next triangle, which is a little trickier.
Once you have created your block's mesh, you can begin to change your code to specify how the height of the vertices could be changed, to give you interesting terrain. As long as the first vertices on your new block are at the same height (say y position) as the last vertices on your current block (assuming they have the same x and z positions), they will line up. That said, you could make it even simpler by not using separate blocks, but by rather updating your object mesh to add new vertices and triangles, so that you are creating a terrain that is just one part that changes, rather than have separate blocks.
There are many ways to create interesting terrain. One of the most often used functions to generate semi-random and interesting terrain, is Perlin Noise. Another is his more recent Simplex noise. Like most random generator functions, it has a seed value, which you can keep track of so that you can create interesting terrain AND get your block edges to line up, should you still want to use separate blocks rather than a single mesh which dynamically expands.
I am sure there are many tutorials online about noise functions for procedural landscape generation. Amit Patel's tutorials are good visual and interactive explanations, here is one of his tutorials about noise-based landscapes. Take a look at his other great tutorials as well. There will be many tutorials on dynamic mesh generation as well, just do a google search -- a quick look tells me that CatLikeCoding's Procedural Grid tutorial will probably be all you need.

Geodesic on Matlab PLY Surface Mesh

I have a CT scan for an heart and I am designing a device that rests on top of it. As such, getting the right lengths for certain attributes is important. The CT scan was segmented in MeshLab and my advisor gave me code that uses PLY_IO to read the ply file exported from MeshLab. From this, I have a map of the surface. surf(Map.X, Map.Y,Map.Z) outputs the 3D model. Now, what I would ideally want is to be able to select points graphically via the figure window and have Matlab either tell me what the points are or allow me to draw a geodesic line to determine its length. Question: Does anyone have any idea of how I could do this in a simple way?
Ultimately, just drawing on the figure might be ok too if I can just get it in the right orientation. Ideally, though, I would select the start and end point and then Matlab would graphically show a geodesic on the surface that I can later find the length of. I'm willing to do some programming for this, but hopefully there's something out there you guys might already know about.
One way to interactively extract points on a surface is to use datacursormode. Here's a simple example of how to get two points:
surf(peaks);
dcm_obj = datacursormode(gcf);
set(dcm_obj,'DisplayStyle','datatip',...
'SnapToDataVertex','off','Enable','on')
disp('Select first point then press any key')
pause
c_info{1} = getCursorInfo(dcm_obj);
disp('Select second point then press any key')
pause
c_info{2} = getCursorInfo(dcm_obj);
Note that if you (or the user) changes mode (e.g. by clicking the rotate button) in order to select the point, you will have to switch back to datacursor mode to move the datacursor again:
You should now have c_info{1}.position and c_info{2}.position which are two points on the surface. Calculating the geodesic is another matter - have a look on the File Exchange, see if there's anything around already that will do the job for the type of data you have already.

Automated placement of points/landmarks on shape outline using MATLAB

I'm just beginning with Image analysis in MATLAB.
My goal is to do an automated image segmention on images of plant leaves.
I have had reasonable success here thanks to multiple online resources.
The current objective, the reason why I'm placing this question here, is to able to place 25 equidistant points along each half of the margin/outline of leaf, like described in following image:
For the script to be able to recognize each half of the leaf, user can put two points within the GUI. One of these user-defined points will be on the base of leaf and the other on tip of leaf. It would be even better if a script would be able to automatically recognize these two features of the leaf.
For the output, I would like a plain text format file containing image coordinate of each point.
I'm not asking for a ready made script here, but looking for a starting point.
One way I think this can be done is by linearizing/open up the outline in such a way that it becomes a straight line. This can be done by treating any of user placed point/landmark as breakpoint. Once a linear outline is obtained it can again be broken into two halves at other user defined point and now points can be placed. One point to bear in mind here is that the placement of points for each half should start from the end that corresponds to the same breakpoint/user-defined point in each half. Now these straight lines can be superimposed on original image for reconstruction.
Thank you very much.
Parashar

CorelDraw's CDR to Fireworks?

I have the layout of a website in CorelDraw X4 and I need to move it to Fireworks CS5 (for many reasons). The thing is that, apparently, the only method I was able to find on the Internet doesn't work very well. What I do is to export the file from Draw to AI (Adobe Illustrator) format. Then I import the file in fireworks, but there, strange things happen. The first thing is that borders are thicker after this process (1 to 4) but the real problem comes with some objects thar are converted to bitmaps (or so I think). When I delete all the bitmaps, only a few objects remain and that's obviously undesired. In my original file I use transparencies and gradients applied to many different objects.
Do you know why this happens and/or a possible solution? Thanks!
Edit: I think I'm getting closer! Apparently AI format doesn't support transparencies, so... I get all trasparencies out before exporting (not very nice, but what can I do, right?) or I ungroup all objects once imported into Fireworks and then carefully delete the bitmaps (which seem to be the approximation of transparencies for AI). All this is just about testing, if someone knows what happens or of another solutions, please, thow light. Thanks...
Ok, as nobody else answered my question I suppose I can consider myself capable to provide more information than anybody else, ha!
I've been studing the case and reached to a semi-solution. Apparently, AI is the only format supporting vectors that can be exported and imported by both editors. The problem with this is that AI doesn't support transparencies nor shadows. So... If you really want to do this, be prepared to work a bit.
What I did was to copy all the shapes without effects using this export/import method (surprisingly, line thickness was preserved correctly this time), then I examined shape by shape in Corel and applied the same (or its best aproximation) effects in Fireworks. This wasn't easy because the way both programs apply shadows and transparencies is a bit different. Yeah, it's not easy, but it's all we got...
Little tip: In my case I had some shapes with transparencies AND shadows. In Corel these shadows where strong as if the object was solid (not transparent). In fireworks, the shadow disappears with the object when the transparency is applied (as logically expected). What I did to solve this was to copy the object and apply a Gaussian blur to the object in the back, acting as a full shadow even when the object in the front was fading to transparent.