Integrate UWP XAML with D3D11 Renderer - c++

As a little side project, I thought I'd take a look at creating a simple 3D application. I'm reasonably comfortable creating WPF applications, so the Visual Studio 'DirectX 11 and XAML App (UWP)' caught my eye. It should be mentioned that I am slowly working my way through the canonical book on D3D11, '3D Game Programming with with DirectX 11' by Frank Luna.
Thus, my comfort zone with D3D11 is quite narrow, but I felt confident enough to tackle a simple task. I fell at the first hurdle. What I was trying to do is take the Visual Studio template, add simple UI of a few text boxes to view and edit the model transform.
I came unstuck with how to connect my ViewModel for the UI with my C++/CX object that contains the 3d model, and thus the model transform. My class that defines the property of the 3dmodel is a standard C++ class. I don't seem to to be able to grasp how to marry the two together.
All the tutorials out there that I've come across leave out the most important part of XAML/D3D11 integration and that is data binding to the game/scene objects themselves.
So, the question: How do I tackle the task of bridging the gulf between my C++/CX ViewModel and C++ game objects?

It is just typical that after I post the question that I find direction towards an answer.
Microsoft in their Windows Universal Samples, has a sample 'Simple3DGameXaml'. It does use Xaml, but doesn't use controls and bind to them to game objects.
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/Simple3DGameXaml
However, it does show an alternative layout of the application that completely removes the confusion I had with connecting two seemingly different parts of the application.
Thanks.

Related

How to make a Block builder \drag and drop layout program?

Im new to GUI programming and i want to create a program that has modules and enables its user to connect these modules together by draging and dropping them then connecting them together visually in order to create a structure for simulation.
Example software already in market :
Proteus , EV3 lego software , matlab simulink
Im planning to use glade with gtkmm although all I found on the subject is the drag and drop tutorial which isnt that usefull
I really just need guide lines and where to start on learning how to make my project
Thank you
I don't know of any GTK+ or gtkmm API that will help much, though I wish something suitably high-level existed. I have implemented something fairly similar, for designing database table diagrams:
http://www.murrayc.com/permalink/2007/02/17/glom-relationships-overview/
and for designing print layouts for database records.
I used GooCanvas via goocanvasmm, but had to implement several classes to provide generic functionality such as drag-to-move, drag-corner-to-resize, snap-to-grid, snap-to-lines, etc. My code works but I'm not very proud of it:
https://git.gnome.org/browse/glom/tree/glom/utility_widgets/canvas
Glade won't help you much with this. It's for laying out normal widgets, not for implementing specialized UIs such as this.

Creating GUIs in Win32 C++

I'm developing my first Windows desktop application and I'm trying to figure out what the best approach would be to create the program's GUI.
I know, I know... I feel stupid for asking considering the amount of data on the subject on SO. However most answers seem outdated and I'm not sure if they fit my specific project. Also tutorials for Windows 8 'metro apps' are clogging my Google search results, which is NOT what I'm looking for.
I use Visual Studio. I've followed tutorials. I have basic knowledge of C and Java and extensive experience with PHP. I'm excited to learn C++, so I'm not looking for GUIs to create a GUI (like WinForms). I also don't care about managed code and portability for now, especially since I'm trying to avoid dependencies (i.e. users having to install .NET). As long as it runs smoothly on Vista and up, I'm happy.
The application
The software will teach basic physics to kids. I'd like to create a main area and a sidebar. The main area will feature a physics animation, say a bouncing ball, along with some Q&A. Users can zoom in to the animation to measure some stuff and answer the question. Users can track their progress in the sidebar. That's pretty much it.
What I've found so far
I'm getting a bit frustrated with MSDN. Most of their examples are given in four different languages (C#, C++, etc). I can't seem to get more than a bit of Hello World code from them.
I found a GDI API on MSDN and it seems like a good start for me. However I've read quite a few answers on SO saying creating layouts in pure C++ is really hard, that we're better of using frameworks like ATL and WTL. Since I'm also going to create (somewhat interactive) animations, I've wondered whether I should use gaming-targeted APIs like Direct2D.
Since all of this is new to me, and there are a lot of options, I don't know where to start for my particular application. Any tips would be greatly appreciated!
Using the raw Win32 API (no additional downloads or third-party helpers):
Here's a good primer (introduces dialog boxes, text boxes, buttons, etc): theForger's Win32 API Tutorial
And here's where you go from there (numeric up-downs, list boxes, combo boxes, tooltips, and more): Common Controls on MSDN. Most of these require you to #include <commctrl.h>.
I also found this to be a good resource that covered what the other two didn't: Win32 Developer - Window Assets
But the Win32 API doesn't seem like it does exactly what you want. A physics app for kids should have a more visual GUI than the API can provide. Good luck, though!
If you're ok with adding additional Frameworks, I'd suggest looking at Qt.
It allows to create the GUI from code only, has a good structure, and has an Interface for 2D drawing, if required.
If you are concerned about dependencies, you only have to include the Qt DLLs to your executables; no installation is required for the user.
To get started, see my (old) tutorial "Lessons in Windows API Programming".
But you really need a good book, such as edition 5 or earlier of Charles Petzold's classic "Programming Windows".
The problem with latest edition is that it's for C# and .NET, with Charles grabbing the tail of the "new way" at just the wrong timeā€¦
Disclaimer: I haven't checked the details of edition numbers.
Using the Windows API is the simplest, but producing advanced GUIs can take a very long time. Microsoft Foundation Class is a way to make the Windows API more user friendly and OOP. Does anyone have any experience with MFC?
Why not use some 2D C++ game engine, like HGE: http://hge.relishgames.com/overview.html.

Model View Presenter for Qt C++ development

Can somebody point me to a good tutorial or sample project where MVP pattern has been implemented using Qt C++. I'm new to Qt as I come from VB.NET background. MVP is pretty common in VB.NET. Doing a Google search was not so fruitful either. Please somebody show me some real world example. Like in VB.NET we create complex model with IList of some base model. All these things are important. And what relevant data structures should be used where we used the Collection class for example.
To learn MVP, I suggest reading Michael Feather's article "The Humble Dialog Box":
webarchive link
(This is one specific form of MVP, there are other variants possible.)
The examples in that article are made with C++. There are not made with Qt, but more or less independent of the GUI framework. MVP is about the separation of your code into a framework dependent part and a framework-independent part, which can be learned by using almost any GUI framework.

Choosing a 3D game engine [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I want to start this as a hobby in developing a desktop game. I have found several engines, but I am not sure whether it does the initial job I am looking at.
Initially I want to do the following:
Create a figure (avatar), and let the user dress the avatar
Load the avatar in the game
In later stages, I want to develop this as a multi-player game.
What should I do?
I also recommend Ogre. Ogre can do this, it provides everything needed in regards of mesh and animation support, but not as a drop-in solution. You have to write lots of code for this to be done.
For our project we implemented something like you do. The main character and any other character can be dressed with different weapons and armor and the visuals of the character avatar change accordingly.
As a start hint for how to go about this: In your modeling tool (Blender, Maya, 3ds max, etc.) you model your avatar and all its clothes you need and rig them to the same skeleton. Then export everything individually to Ogre's mesh format.
At runtime you can then attach the clothing meshes the user chooses to the skeleton instance so that they together form the avatar. This is not hard to do via Ogre-API, but for even easier access to this you can use MeshMagick Ogre extension's meshmerge tool. It has been developed for exactly this purpose.
If you want to change other characteristics like facial features, this is possible too, as Ogre supports vertex pose animations out of the box, so you can prepare pathes for certain characteristics of the face and let the user change the face by sliders or somthing like this. (e.g like in Oblivion)
One thing to be aware regarding Ogre: It is a 3d graphics engine, not a game engine. So you can draw stuff to the screen with it and animate and light and in any way change the visuals, but it doesn't do input or physics or sound. For this you have to use other libs and integrate them. Several pre-bundled game engines based on Ogre are available though.
If you are good with C++ you should use Ogre, it's the best open-source engine, continuously been updated by it's creators, with a lot of tutorials and a very helpful community.
http://www.ogre3d.org/
It's more of a GFX engine, but it has all the prerequisites you desire.
Good luck!
No engine is likely to do this for you. What they do is generally allow you to load and render 3d models. But combining them, the way you'd need to do to "dress them" is up to you. And creating them, or letting the user do so, is ultimately up to you. The engine might offer a number of tools to make the task easier (for example, rendering the model while the user is designing it), but a game engine is not a magic "make a game" box where you just have to press a button, and your custom game comes out.
A couple of people have said Ogre3D, I'll offer up Irrlicht as an alternative.
You might want to take a look at http://www.crystalspace3d.org/ - I have to admit it was more of an exploratory matter for me, but it seemed like a pretty nice engine - with physics and scripting included. They have an project which shows the avatar walking in the spacestation-like building with very smooth camera effects.
OTOH: depending on how far you want to push this, you might find yourself recreating the SecondLife(tm)-like kind of environment. If that's a fair assumption, then you might take a look at OpenSimulator and the associated opensource viewer projects and see if this may be of interest to you - and work there with the existing team to develop the code further, rather than working on your own.
If you good with C++, I suggest the C4 Engine. From my experiences, existing game engines are either too rigid or just nothing more than a collection of libraries.
Ogre is a good way to go if you are just interested in getting something to show. As some have already stated here, Ogre is a rendering engine. There are lots of add-ons and functions to complete common tasks like Audio, Input and whatnot. This is perfectly fine if your just aiming at playing around or creating a prototype.
Should you want to start a long-term project that will be developed over a longer period of time (which would be pretty likely considering you probably being the only developer and games being complex applications), you should really start thinking about what it is that you want to do. Then, based on you're goals, look for several engines that can tackle your needs (there's always some API to accomplish XYZ). Then it's up to you how you manage your game and where you use existing libraries - you'd basically tie up your own engine according to your needs.
It get's a bit more difficult if you start looking for a real game engine in terms of "engine for all my game-dev needs". Check out the nice list of 3d game engines at devmasters (http://www.devmaster.net/engines/), you'll find lots of alpha status game engines trying to accomplish this, although you should keep in mind that support and documentation usually isn't first class in those cases.
I personally never used it, but I evaluated the open source engine Delta3D (delta3d.org) for my project and was impressed by it's cool architecture. It encapsulates a whole bunch of other quality open source frameworks for stuff like graphics (OpenSceneGraph: openscenegraph.org) or physics (ODE: ode.org). That's probably as close as you'll get to a free and flexible game engine as far as I know. It was developed at an air force university, and due to it's academic background comes with lots of detailed documentation.
If you're good with C++ you can write your own engine :P
Ogre is the best of Irrlicht and Crystalspace, and the reasoning behind that is simple - Ogre has actually been used in a production pipeline by the game industry. It actually has a lot of weight behind it, whereas Irrlicht and Crystalspace are more or less applications that don't do a lot out of the box. Crystalspace however has a branch project that implements a game engine right into Blender 3d allowing the artist to play the role of programmer without leaving the actual software.
I'm not very big on Irrlicht - there is a lot of sneakiness behind its motives. For an open source project it branches out into many different derivatives that are either complete game engines or WYSWYG editors and they find ways to lock you into paying somehow.
Ogre excels at being a graphics engine rather than a library, and it has to be compiled to individual needs. The tradeoff is you can implement Ogre into any design work flow or even create a new one. Where it takes the load off your shoulders is having to write graphics code of any kind thus making it a very slick rapid prototyping engine in its basic form.
One engine that you could try is the Torque 3D game engine www.garagegames.com which, although not being freeware, allows for out of the box usability. While the functionality that you seek in terms of being able to fully customise the character is not instantly available within the engine, if you are willing to create the models yourself it should not be too hard to add them into the game and the utilise the game engine to change the 'skins' of the avatar. One thing that I feel will set this apart from the other engines is the fact that it comes with networking functionality pre-installed (from what you have described in your question I am guessing that you are attempting to either make an RTS or MMO, and if so I wish you good luck).
While it may seem strange that the engine is based around a shooting game, there are guides witin the Torque forums that allow you to add the coding for sword based combat and other things associated with a fantasy based game (if, that is, what you are planing on making).
But anyway... good luck with your project. If you are attempting what I think you are attempting it is no easy feat. But I'm sure you know what you are doing =)
Hope this helped
If you are interested in using the Irrlicht 3D engine, you can find a number of tutorials that step you through the process of creating simple 3D applications here.
I also suggest Irrlicht. It's easier to begin with, but it does not have half of the Ogre3D support though.

Lets draw a spider

I am new to c# and VS, but I am getting it. The application is this: A program in which the end result will draw a spider from options in which the user will define. Lets say there are 100s of options: size and number of body parts, color, connections points to the body, etc.
First question: Should I try to use the library included with VS 2005? Or, is there another environment in which I could "tap into" to get good results (flash, java, etc.)?
Second Question: Could you direct me to information corresponding to your answer from the first question?
Thanks so much, the kids I teach will love it!
Jennifer
Hmm.
This is truly a rough question, not because I don't know how to do it, but because it can often be so ridiculously daunting for beginners. If you use the "standard" Windows Forms C# method of doing it, you'll end up asking yourself, "What the #*(&! is WM_PAINT?" or "Why does my program totally get messed up when I move a window over my picture?!"
There are basically two main technologies that you can use to do drawing in .NET : Windows Forms (what MusiGenesis suggested) and WPF, or Windows Presentation Foundation, which ships with the 3.0 version of Visual Studio. That means that if you download the .NET 3.5 SDK or use Visual Studio 2008, WPF comes with it.
I'd recommend using WPF instead of Windows forms if you're just starting off, because the dirty details of drawing and repainting are largely abstracted. You can also define a lot of your picture as markup, just like a web page, and then manipulate it in code. Good luck and have fun!
Here is a link to some examples of how to draw things with C#:
http://www.geekpedia.com/tutorial50_Drawing-with-Csharp.html
This example uses just the built-in graphics methods of .NET, so you won't need any other libraries.