XNA C# object texture - xna

I have a question about xna. I got a sample fbx file from MSDN (the ship with texture) when i put it in my code ( i followed it on MSDN) it works fine also with texture, but then when i put my own model (cube with minecraft dirtblock texture) it only shows the cube, not the texture. The program doesn't give me any error.

Related

Projecting a 3D model in Unity to a raw Image texture

I currently have a WebCamera that captures video and recognizes the surface of a book and estimates the homography with OpenCV.
(I followed the tutorial at https://bitesofcode.wordpress.com/2017/09/12/augmented-reality-with-python-and-opencv-part-1/
and I rewrote the first part for Unity).
Now I'm wondering how would I go about projecting a 3D model in Unity to the raw image?
I am a total newbie in Unity.
You need to have a Camera (that obviously is directed to your object) which is rendered onto a RenderTexture.
Then add a RawImage to your UI and set the reference to your RenderTexture

Drawing a sphere with quads

I need to draw a large sphere composed of small quads. I am very new to Stage3D so I need some advices. How can I create a sphere with hundreds (maybe thousands) of quads?
I haven't worked with Stage3D, but I do know that moosefetcher is wrong. It is entirely possible to create spheres out of quads. Here is a modelling tips video, in it you can see there is a sphere made entirely out of quads.
video
Because I haven't worked with Stage3D I don't know anything about it. Though I'm sure you could look at tutorials for creating quad spheres in 3DSMAX, Maya and Cinema 4D. The steps should be very roughly similar.
However, if they are not similar. I'm pretty sure you can download a model of a quad sphere and load it up in Stage3D and then examine it and try to replicate it. Heres a link to download one:
download
It's not avaliabe in Stage3D, so I did a bit of research and theres a few programs that allow you to convert .blend files to stage 3d files and .obj files to stage 3d files.
You cannot cover the entire surface of a sphere using just quads. At least SOME triangles will be required.

opengles display human face in iphone

I need to make a human 2D face to 3D face.
I used this link to load an ".obj" file and map the textures. This example is only for cube and pyramid. I loaded a human face ".obj" file.
This loads the .obj file and can get the human face properly as below.
But my problem here is I need to display different human faces without changing the ".obj" file. just by texture mapping.
But the texture is not getting mapped properly, as the obj file is of different model. I just tried changing the ".png" file which is used as texture and the below is the result, where the texture is mapped but not exactly what I expected, as shown below.
The below are my few questions on it :
1) I need to load texture on same model( with same .obj file ) with different images. Is it possible in opengles?
2) If the solution for above problem is "shape matching", how can I do it with opengles?
3) And finally a basic question, I need to display the image in large area, how to make the display area bigger?
mtl2opengl is actually my project, so thanks for using it!
1) The only way you can achieve perfect texture swapping without distortion is if both textures are mapped onto the UV vertices in exactly the same way. Have a look at the images below:
Model A: Blonde Girl
Model B: Ashley Head
As you can see, textures are made to fit the model. So any swapping to a different geometry target will result in distortion. Simplified, human heads/faces have two components: Interior (Bone/Geometry) and Exterior (Skin/Texture). The interior aspect obviously defines the exterior, so perfect texture swapping on the same .obj file will not work unless you change the geometry of the model with the swap.
2) This is possible with a technique called displacement mapping that can be implemented in OpenGL ES, although with anticipated difficulty for multiple heads/faces. This would require your target .obj geometry to start with a pretty generic model, like a mannequin, and then use each texture to shift the position of the model vertices. I think you need to be very comfortable with Modeling, Graphics, Shaders, and Math to pull this one off!
Via Wikipedia
3) I will add more transform options (scale & translate) in the next update. The Xcode project was actually made to show off the PERL script, not as a primer for OpenGL ES on iOS. For now, find the modelViewMatrix and fiddle with this little bit:
GLKMatrix4Scale(_modelViewMatrix, 0.30, 0.33, 0.30);
Hope that answers all your questions!

Flipping OpenGL ES Texture Obtained Through CVOpenGLESTexture

In the past day of my foray into OpenGL ES 2.0, while attempting to apply two projective textures -- one sprite animation and one video file texture -- to a skybox, I started simply pounding my hands on the keyboard like stubs, and miraculously it all started working.
However, the texture created from the video file is flipped upside-down. In other words, the texture coordinates for (0,0) seem to be mapping to (0,1), and vice-versa.
The function which creates the video file texture from a CVImageBufferRef, CVOpenGLESTextureCacheCreateTextureFromImage(), includes a parameter "CFDictionaryRef textureAttributes."
CVOpenGLESTextureCache.h helpfully explains: "A CFDictionaryRef containing attributes to be used for creating the CVOpenGLESTexture objects. May be NULL."
I immediately thought of GLKTextureLoader, which allows you to pass in an options dictionary, with one of the available options being used to flip the texture around.
So, I'm a bit confused on two points:
Will passing in a CFDictionaryRef of attributes allow me to easily change things about the texture, like rotation? Or does it somehow mean 'attribute' in the shader-sense? (I don't think it very likely means the shader-sense, but I also think it's odd that it calls them attributes and not options.)
Is there a list somewhere of the key/value pairs that will tell it to do useful things?
I wanted to look into this before finding some other way to flip it around, since if it's possible to do it here, it seems like it would be the most straightforward way, if the procedure is indeed parallel to GLKTextureLoader's options.
After reading through apple's RosyWriter sample code again, I've realized that after creating the texture with CVOpenGLESTextureCacheCreateTextureFromImage(), they flip the texture around by modifying the texture coordinates for the vertices.
Since I'm projecting the texture and computing the texture coordinates in the vertex shader, I think the simplest solution for me will be to flip the actual movie file asset around before I drop it into xcode. So that's probably what I'll do for each movie. Just realized what a simple solution that is. That way I don't need to fork my vertex shader code for projections that need to be rotated & don't need to be rotated.
I'd still really appreciate clarification on the attributes argument though, if anybody has info on that.

Render texture in 3d space with XNA

I have made an augmented reality app in XNA that displays a 3d model over an SLAR marker (Silverlight Augmented Reality-toolkit).
I would like to display an rectangle floating over the 3d model showing a texture, but I'm not sure what object to use.
Texture2D doesn't have any 3d space rendering capabilties I know of, is there anything else I can use?
The texture I would like to show is generated using the SetData method so it needs to be a Texture2D or an object with simular SetData method.
One solution is to render Textured Quad.
This basically means you're drawing a rectangle in 3d space, and texturing it with whatever texture you'd like.
The link i supplied covers the basics of doing this.
Notice that the link involved XNA 4.0 (not sure if there are any changes from previous releases), but the sample also exists for earlier versions of XNA.

Resources