ELI5 Step-by-step explanation of the code used to render a 3D model - xna

I've read books and web pages on rendering a 3D model in XNA, and I've got the code to render a simple model with textures, but can somebody explain to me what each line of code does, step by step? There are loads of vaguely named methods and I think it's best for me if I actually understand what the code does as well as memorising the code.

Related

Swift OpenGL ES app template?

I've been looking at a lot of tutorials trying to find a way to make an OpenGL app written in Swift, but I can't seem to find a good template to use.
Most tutorials suggest using a blank one, but then I have to write a ton of files (such as AppDelegate) all from scratch, which I have no clue how to do.
I tried all the links on this, but the first one doesn't even work and the second one is in Objective-C.
Anyone have anything that might help me?
I ended up figuring it out myself by using GLKit and smashing together old tutorials. Since OpenGL is just a bunch of functions, all you really need to do is find the right parameters for your programming language.
For anyone else trying to do this, there's some fairly useful resources here and here, and it's also useful to shove in some ported code from Ray Wenderlich if you get stuck. Good luck!

WebGL Constructive Solid Geometry to Static Vertices

I'm super new to 3D graphics (I've been trying to learn actual WebGL instead of using a framework) and I'm now in the constructive solid geometry phase. I know sites like tinkercad.com use CSG with WebGL, but they have things set so that your design is calculated every time you load the page instead of doing the subtraction, addition and intersection of primitive objects once and then storing those end design vertices for later use. I'm curious if anybody knows why they're doing things that way (maybe just to conserve resources on the server?) and if there isn't some straightforward way of extracting those vertices right before the draw call? Maybe a built in function of WebGL? Haven't found anything so far, when I try logging the object data from gl.bufferData() I'm getting multiple Float32Arrays (one for each object that was unionized together) instead of one complete set of vertices.
By the way, the only github I've found with CSG for WebGL is this https://github.com/evanw/csg.js/ and it's pretty straightforward, however it uses a framework and was curious if you know of any other CSG WebGL code out there that doesn't rely on a framework. I'd like to write it myself either way, but just being able to see what others have done would be nice.

where is the actual code for the XNA "game loop"?

I am beginner trying to learn C# and XNA. I am trying to get a deeper understanding of the XNA game loop.
Although there are plenty of articles explaining what the game loop is, I can't seem to find the actual loop implementation anywhere.
The closest I think I have gone to finding the loop is this member of the game class in the MSDN documentation:
public void Tick ()
If this is the correct one, where can I find the inner implementation of this method to see how it calls the Update and Draw methods, or is that not possible?
Monogame is an open source replica of XNA based on modern rendering pipelines, and SharpDX.Toolkit implements a very XNA-Like interface for DX11 (Monogame actually uses SharpDX under the hood for DirectX integration)... you can probably find the game loop in the source code from either of those projects and it will likely be be close to if not identical to what MS XNA actually uses.
That being said, the game loop actually doesn't do much for simple demo applications (they tend to pile up everything in a single method to update/render a simple scene), though in full games with component based scene graphs it can get a little complicated. For single threaded engines, the general idea is to:
1. update the state of any inputs,
2. process any physics simulation if needed,
3. call update on all the updatable objects in
your scene graph (the engine I'm working on
uses interfaces to avoid making wasteful calls
on empty stub methods),
4. clear the working viewport/depth buffers,
5. call render on each renderable object to actually
get the GPU drawing on the back buffer.
6. swap the render buffers putting everything just
drawn to the back buffer up on screen, and making
the old viewport buffer the new back buffer to be
cleared and drawn on the next rendering pass.
7. start over at step 1 :)
That pretty much covers the basics and should generally apply no matter what underlying API or engine you are working with.
Since XNA is closed-sourced, it is not possible to see the code for the game loop, as defined in the Game class. The Tick() you have referenced is not exposed nor referenced in any XNA documentation(Although, it may be used behind the scenes, I do not know).
As #Ascendion has pointed out, MonoGame has an equivalent class named Game see here. While, this may not reflect the XNA code exactly, it is the best compatible source (all tests performed between the two, they return the same values), that we the public, have available.
The main side effect to the MonoGame implementation is the platform independent code, which may be hard to comprehend, since some of the implementation code is located in additional files. It is not hard to trace the sources back to the expected platform source code.
This post is to serve as a clarification to all who may stumble upon this later.

Showing visual Data in Ruby on Rails

Screen shot below, reads data from some database - I think I can get my head around reading data from DB with some RubyOnRails tutorial I am following - but then how should I be able to represent that data in a pretty shape that they want like this picture below?
What tools, frameworks, etc. should I get myself familiar with very quick to be able to represent the data like this?
Since I am should focus on Rails, it would be great if what you suggest is in something that integrate well with Rails too...
Screen shot2: for this one I "think" somehow I can use "Google Charts" but still good to have your suggestions too.
To make charts you use javascript. There is a lot of libraries out there.
Those small charts in the first picture are called sparklelines. They can be made with this jquery plugin
jQuery Sparklines
And this pure javascript tool
sparklines.js
For other charts I think the best free one is the d3 library and spesially the nvd3 library witch is built on top of the d3 library.
There are also some solutions with the Raphaël—JavaScript Library.
One is gRaphaël.
I personally do not like this one, but have a look.
Charting libraries often use SVG's (Scalable Vector Graphics. Go here to learn about SVG and CSS ) to display the charts. And you feed the data from Rails trough JSON.
Rails can render JSON from the controllers and you can use jbuilder "Jbuilder gives you a simple DSL for declaring JSON structures that beats massaging giant hash structures."
I usually end up with a custom class in the lib directory, because charting usually requires a lot of complex queries and handling of data from the database before you can send it to the chart.
You should see these railscasts. railscasts#223 railscasts#223revised
The first uses highcharts (Not free) and the last use morris.js. Morris is rather simple, but in some chases sufficient.
The last one is the best, but I guess you have to get a subscription to see it.
There is a lot to learn here, and that is fun!

Creating 3D model using set of 2D images on Windows

I want to create a 3D model using set of 2D images on windows which can be send through webservice to iphone to display on it.
I know it can be done through Opengl but don't know how to start and also if I succeeded in creating it,is it compatible with iphone as iphone uses opengl es.
Thanks in advance.
What kind of transformation do you have in mind to create the 3D models? I once worked on an application using such a concept to create a model from three images of an object. It didn't really work well. The models that could be created were very limited.
OpenGL does not have a built in functionality to do such stuff. Are there any reasosns why you do not want to use a real 3D-model? It sounds as if you are looking for a fast solution for your problem. But I'm afraid if you do not have any OpenGL experience, you should prepare prepare for lots of stuff to learn.
If you want to create 3D models automatically from 2D photos, you're going to have a fair bit of work to do. AFAIK, this is not something where you can get a cheap pre-packaged solution. Autodesk charge a small fortune for ImageModeler.
MeshLab may be a good starting point, but even that can't automatically convert photos to a 3D model AFAIK.
Take a look at David Lowes site. I found the "Distinctive image features from scale-invariant keypoints" paper quite interesting, though I haven't re-read it in a while. If nothing else, this should give you some idea why this is far from a trivial problem.

Resources