Friday, April 20, 2012

Qt, OpenGL and VS2010 How To

Resources:
My guide:

First, install [1]. Next install [2]. After that, you can notice a new Qt button at the top of your VS2010 toolbar. I haven't had to use the button for anything yet but know that it's there.

Development for me using Qt and VS2010 involves using VS to program my widgets and QtDesigner to create the UI layout.

You can open up your file.ui for designing by:
  • Double clicking it in your VS2010 Solution Explorer.
  • Or by opening QtDesigner directly, finding the file.ui of your project in Explorer, and using the designers opening dialog to go to that path and open it.
I normally use the 2nd longer direct approach.

While following the Zhao Wuluo walkthrough something to look out for is the mainwidget.cpp constructor:

MainWidget::MainWidget(QWidget *parent, Qt::WFlags flags)
 : QWidget(parent, flags),
 ui(new Ui::mainwidgetClass)
{
 ui->setupUi(this);
}


That's what my constructor looks like. The auto-generated class file lacked the ui(new Ui::mainwidgetClass) constructor call and this caused my GLWidget to throw an access violation error when being constructed itself. So don't do that, construct your ui.

Thoughts on beginning Qt:

It's nice. It can seem very overwhelming at first but I believe it's a matter of how you look at it. Let go of the idea of the GUI writing itself completely through the designer. Accept the idea that the entire endeavor is regular code and brackets programming with a nice designer tool to help where it can. Also, be sure to check out the "Qt Examples and Demos" app that comes installed with your SDK because running them and checking out their documentation in the QtAssistant has helped me a lot.

I will post more as I learn more. I hope this was helpful.

Sunday, April 1, 2012

Havok Tutorial: A way to detect bullet collisions

Hey. This will be less of a tutorial and more of a "here's a way to do something".

One way you can detect your bullets hitting objects in Havok is through the use of Phantoms. These are aabb's that exist simply to report what collides with them (and to apply events to those colliding objects if you'd like). This makes Phantoms great for things like triggering events based on a player's location, and bullets.

Check out the demo at: Demo\Demos\Physics\Api\Dynamics\Phantoms\PhantomObject for example code on using Phantoms.

So for example, you can draw your bullets as particles, and maintain a phantom for each of these bullets. When a bullet phantom's collision list contains an enemy you can say doBulletHitEnemy() or whatever.