Meshlab: How to mapping a PLY mesh to planar image? - c#

im new in image processsing and 3D applications.
I have a PLY mesh from Kinect. I want to mapping the whole model to a planar image.
I imagine the result image like a tissue, flaterned in a planar surface from a topograifc surface.
My worry is dont lose the color depth image data or mesures from the original mesh.
Solutions in C# to mapping the mesh are welcome too.
Thanks!
( sorry my english)

Related

Mapping textures to DirectX sphere?

I am writing a virtual globe using DirectX similar to Google Earth. So far, I have completed tessellation, and have tested with a wrapped texture over the entire sphere, which was successful. I have written the texture coordinates to correspond with the latitude and longitude (90lat,-180lon = 0,0 and -90lat,180lon = 1,1).
For this project, I need to layer several image tiles over the sphere. For example, 8 images spanning 90 degrees by 90 degrees. These tiles may dynamically update (i.e. tiles may be added or removed as you pan around). I have thought about using a render target view and drawing the tiles directly to that, but I'm sure there is a better way.
How would I go about doing this? Is there a way to set the texture to only span a specific texture coordinate space? I.e. from (0, 0) to (0.25, 0.5)?
There are three straight-forward solutions (and possibly many more sopisticated ones).
You can create geometry that matches the part of the sphere covered by a tile and draw those subsequently, setting the correct texture before each draw call (if the tiles are laid out in a simple way, you can also generate this geometry using instancing and a single draw call).
You can write a pixel shader that evaluates the texture coordinates and chooses the appropriate texture using transformed texture coordinates.
Render all textures to a big texture and use that to render the sphere. Whenever a tile changes, bind the big texture as a render target and draw the new tile on top of it.

how to create an texture atlas of a 3d object in unity3d

I am working on a 3D game and it has lots of game objects in a scene. So I'm working on reducing draw calls. I'v used mesh combining on my static game objects. But my player is'n static and I can't use mesh combining on it. My player is nothing but combination of some cubes which uses the standard shader and some different color Materials on different parts. So I'm guessing, I can use texture atlasing on my player to reduce darw calls. But I don't know how to do it.
Is my theory of work right? If I'm right please help me with atlasing, and if I'm wrong please point out my fault.
Thanks in advance.
Put all the required images into the same texture. Create a material from that texture. Apply the same material to all of the cubes making up you character. UV map all cubes to the relevant part of the texture (use UV offset in the Unity editor if the UV blocks are quite simple, otherwise you'll need to move the UV elements in your 3D modelling program).

How to augment the live rgba stream with a 3d model?

I am trying to augment the live RGBA stream from Kinect sensor with some 3D models using XNA (i.e. adding 3D models into a live video scene).
I succeeded in augmenting the scene with 2D sprites (e.g. circles) but I cannot add 3D objects (I think the objects are there but they hide because of the video texture). I can see 3D objects if I don't draw the video stream, but as I start applying video stream, objects disappear.
In XNA 2D and 3D rendering calls are handled differently:
2D renderings are executed without using a depth buffer (have a look at this SO post)
3D renderings are executed using a depth buffer by default
So what you want to check is if the z coordinates of the objects you want to render are right:
If the rendered pixels of your 3D model are farther away than your RGBD data, your RGBD video stream overwrites your 3D model's pixel or they are discarded right away if they are rendered after your RGBD data.
Try moving your whole RGBD data away from the camera and see if your 3D model appears. To achieve this just increment the depth values of your data. Otherwise decrement your 3D models z coordinate until you can see it. Watch out as this may result in the 3D model being rendered behind the camera.

XNA Model won't compile?

I'm working on a game in XNA, and i'm loading a model from blender. The model didn't have a texture until now, and when it tries to compile I get this error:
The mesh "", using BasicEffect, contains geometry that is missing texture coordinates for channel 0.
The model loaded before this point. I know I have to add the texture file in the same location as the .x file in my content, and I did that. The .x file contains the segment that references the texture.
Material ShipMat {
0.640000; 0.552144; 0.594688; 1.000000;;
96.078431;
0.500000; 0.500000; 0.500000;;
0.000000; 0.000000; 0.000000;;
TextureFilename {"shipTexture.jpg";}
}
I'm using the add-on DirectX exporter for blender, because when I tried exporting my model as a .fbx it didn't load the texture and it was rotated in an odd direction. Any Ideas? Thanks in advance.
For a texture to work, each model vertex needs texture coordinates.
Sounds like the model did not export from blender with a texture coordinate element for each vertex. Most likely, your model vertices only have position, color, & maybe normal elements only.
Just go back to blender, apply any old texture you want, then re-export it & swap out textures in Xna and you will get what you're expecting now.

Cut holes in a Texture2D

I want to know how to remove part of a Texture from a Texture2D.
I have a simple game in which I want to blow up a planet piece by piece, when a bullet hits it "digs" into the planet.
The physics are already working but I am stuck on how to cut the texture properly.
I need to create a function that takes a Texture2D a position and a radius as input and returns the new Texture2D.
Here is an example of the Texture2D before and after what I want to accomplish.
http://img513.imageshack.us/img513/6749/redplanet512examplesmal.png
Also note that i drew a thin brown border around the crater hole. If this is possible it would be a great bonus.
After doing alot of googling on the subject it seems the best and fastest way to achieve the effect i want is to use pixel shaders.
More specifically a shader method called 'Alpha mapping'. Alpha mapping is done by using the original texture and another greyscale texture that defines what parts are visible or not.
The idea of the shader is to go through each pixel in the original texture and check how black each pixel in the greyscale image is at the same coordinate. The blacker the pixel in the greyscale picture is the higher the alpha value (more visible) the pixel in the original texture becomes. Since all this is done on the GPU it is lightning fast and leaves the CPU ready to do the actual logic for the game.
For my example I will create a black image to use as my greyscale image and then draw white circles on this corresponding to the parts i want to remove.
I've found a MSDN examples with working source code for XNA 4 that does this (the cat example):
http://create.msdn.com/en-US/education/catalog/sample/sprite_effects
EDIT:
I got this to work quite nicely. Created a small tutorial with source code here: http://syntaxwarriors.com/2012/xna-alpha-mapping-with-pixel-shaders/
A good way of doing this is to render a "hole texture" using alphablend on top of your planet texture. Think of it like drawing an invisibility circle over your original texture.
Take a look at this thread for a few nice links worms-style-destructible-terrain.
To achieve your brown edges I'd guess you'd need to take a similar approach. First render the hole to your terrain with say radius 10px. Then you render another circle from the same origin point but with a slightly larger radius, say 12px. You'd then need to set this circle to a blendmode that results in a brown color.
look at my class here:
http://www.codeproject.com/Articles/328894/XNA-Sprite-Class-with-useful-methods
1.Simply create an object of Sprite class for your planet
Sprite PlanetSprite = new Sprite(PlanetTexture2D , new Vector2(//yourPlanet.X, //yourPlanet.Y));
2.when the bullet hits the planet, make a circle texure2d by the center of collision point using "GetCollisionPoint(Sprite b)" method
-you can have a Circle.png with transparent corners
-or you can create a Circle using math(which is better if you want to have bullet power)
3.then create an Sprite object of your circle
4.now use the "GetCollisionArea(Sprite b)" to get the overlapped area
5.now use the "ChangeBatchPixelColor(List pixels, Color color)" where pixels is the overlapped area and color is Color.FromNonPremultiplied(0, 0, 0, 0)
-note you don't need to draw your circle at all, after using it you can destroy it, or leave it for further use

Categories