Archive

Archive for May, 2009

Visual Studio 2010 Beta 1, first experiences

Today I finally had the chance to install Visual Studio 2010 Beta 1 on my PC. I had planned to it yesterday but the download rate got extremely slow yesterday, at the end it was at 7 kb/s and I stopped the download.

But now lets talk about my first experiences with the new Visual Studio 2010.

Visual Studio 2010 Startpage

After installing it, which took some time, I firstly started it. The new Start page is really a lot better than the old one, but the best part is it’s customizable. Have a look at the following links if you are interested in it:

I haven’t had the time myself to customize my startpage. I really firstly wanted to get a look at all the new features in VS2010.

For further testing I created a new Win32 Console Application. Having a look at the Default Settings I thought, lets try to import my setting from Visual Studio 2008. It worked without any problems. The Coding environment changed and everything looked like it had looked in 2008.

After I had restarted Visual Studio, the background color was back to white… This is the first bug I encountered in this Beta. You have to open up the “Colors and Fonts” option menu and just press “OK”, then everything will look normal again.

My IDE, showing my settings.

I already had read that intellisense for c++ had been improved. So i just started typing and directly found the first new feature in C++ intellisense.

#include file will now be checked, and will get a red wavy line under it, if the file couldn’t be opened.

include error line

include without error

One screenshot showing how intellisense looks by default.

intellisense

I made a change to the C++ settings for intellisense. Under “options”, “Text Editor”, “C/C++” i activated “Auto List members”, and “parameter information”. So I don’t have to hit a key to let intellisense show, I always want it to show up.

C++ Text Editor options

Now I wanted to test if anything had changed to the UnitTesting support for C++ projects. I only found a small difference. Under Visual C++ is now a TestProject which can be used directly, everything hasn’t changed and works like it does in Visual studio 2008. If your are interested in Unit Testing have a look at my post about it here.

Intellisense not available, for C++/CLI

Sadly intellisens doesn’t work in the test project.

I also found some changes which make debugging a bit faster. I don’t will talk about the Multithreading additions here I haven’t had the time to play with it. But that’s up next.

When hovering about a variable you get, the normal window showing the values as usual.

clip_image001[20]

But at the right side you can see a small node icon. Below is the icon highlighted in yellow.

clip_image001[22]

If you press this icon a yellow floating window will appear.

clip_image001[24]

clip_image001[26]

clip_image001[28]

This window shows the values of the variable as if you would hover about it. But you don’t have to. This window will update each time the variable updates. A matrix has a lot of values not all can be shown in the small window. But press the small "”+” at the left and all value will appear. Each value now has this small icon node icon at the right. If you press this button the value will be added to the floating window. (As in the window on the right)

All these setting will be saved and the next time you start debugging it will show up exactly with the same setting you left the last time

So that it. These are my experience i wanted to share. I will continue playing with it and write about my experiences.

Categories: Visual Studio

Getting 3D Model data in my engine, Part 2

As told in part1 I’ve written an exporter based on the “Sample Content Exporter” from the DirectX March SDK.

The process of getting the 3D model data into my engine now works as following. My 3D Content gets created in any tool which supports exporting to  .fbx, .3ds, .obj or even .collada. Most tools support one or more formats of these. So the import site of the project is really great and supports major file formats supported by major tools. image

The 3d data now gets imported into the “Sample Content Exporter”. This is using the Autodesk SDK. It was actually written for the FBX SDK 2009.1 but it’s working without any problems using the new 2010.0 version.
The intermediate format used is easy to export, most data is already in game ready form so it just has to be exported.

The export formats supported by the tool, as found in the DirectX SDK, just supports .xatg(used by the XBoxSDK samples) and .sdkmesh(this is used by the windows samples).
So all the infrastructure for exporting meshes is already in place and the code designed for exporting content.

So I started writing an exporter for my own model format, and it really work great. But it’s not perfect yet. The exporting of the actual mesh data is working currently but exporting of textures doesn’t work yet, but I’ll try to add this tomorrow. But as I’m the only one using this exporter in the moment this is not such an big problems. Because my format is designed to be easy editable by hand, so I can fix such problems really quick.

clip_image001

 

This is the test model I used for testing my exporter while developing it. As XNA developer you may noticed it already,  it’s the rocket from the XNA SpaceWar Starter kit. Content that worked in xna, which also uses the FBX SDK for importing, will also work and can be exported to my own custom format.

 

 

In the next post I ‘want to talk a little bit about how the “jenmodel” format is designed, what is supported currently and what makes it different from other formats, already existing.

Categories: 3D, D3D11, Ganbatte Engine

Unit Testing C++ with the Visual Studio Unit Testing Framework

As written in a previous article I was using WinUnit(http://msdn.microsoft.com/en-us/magazine/cc136757.aspx) for my Unit Tests in C++. At this time I was quite happy with the features the framework provided, but as I’m working more and more with it, I was more and more missing the direct integration in the IDE, the Visual Studio Unit Testing Framework provided.
Which is my Unit Testing framework of choice when writing managed code.

The integration in the IDE is really a big plus. Just having to press a key combination [add key combination] and having to run the test again makes a TDD style of programming much more productive and fun. Also debugging the Unit Test involved setting up the test project to use a custom tool for debugging. And than manually having to say “Debug”->”Start new instance” really slowed me down.

So once a day I read a post by Jamie Fristrom from Torpex Games,he had a problem using VSTest for a c++ project. (I sadly couldn’t provide any help). He talked about how easy it is to use unmanaged code with it. I started to try it out myself because, you already know, I like it a lot in managed code.

In the following I want to talk about how to get everything in place to test unmanaged c++ code with VSTest.

Creating a c++ test project

Finding the place where a test project for c++ code can be found, is the first challenge. Normally you would go to “File” –> “New” –> “Project” and there search for “Test Projects”. From here you can create a “Test Project”. But this is just a C# project and there is no way to change it to be a c++ test project.

So what now?

There is a way to create a c++ test project. But it’s a little bit hidden in the menus of Visual Studio.

 image

The only way, I know of, is hidden in the Test Menu of Visual Studio. When you open the Test dropdown menu, you see the option “New Test…”. If you click this you will get the window show below.

clip_image001

In this window you have the possibility to create new Unit Tests. To create a C++ test project you have to open the drop-down menu “Add to Test Project:”
In this menu you have the possibility to add a new test to an existing test project. In my case I have a test project, called “TestProject2”.

But we want to create a new “Visual C++ test project”, so we choose this option. After clicking “OK” we will be asked for a name of the project which will be created.

The project will be created and the UnitTest1.cpp file will be opened. This is our starting point for the newly created project.

The project is ready to be used and will compile. But we have to change the properties for this newly created project a little bit, to make it usable.

Open the properties page for the newly created test project.

image

 

 

 

 

 

 

 

 

 

 

 

Under the general tab, you will find the “Common Language Runtime support” option. This will show, by default, “Safe MSIL Common Language Runtime Support “. This option has to be changed because if this option is set to  “Safe …”, we cannot test any unmanaged code not also compiled with “/clr:safe”.

So change this option to  “Common Language Runtime Support (/clr)”.

Test C++ code

We got the most work done, now it’s finally time to get c++ code tested.

C++ code, cam be compiled in three different forms, as you already know. It can be compiled as .lib, .dll and .exe
All three forms can be tested using VSTest, but a application(.exe) is more limited.

The table below shows the features support for each type, once when compiled with CLR support and once without.

clip_image001[1]

As you can see just a .exe application doesn’t support stepping into the code. I always try to find the reason a test failed without having to debug, but if i really can’t find the problem I have to recompile the file as a lib.

As I’m talking about, there is one thing you have to do when trying to test code in .exe projects. You have to define the members you want to test with __declspec(dllexport). Like you do when compiling a .dll project. This has to be done, so we can link to the .lib file which will be created now.

Having linked the code, testing is easy. The c++ code can now be used like normal. Just look at the small example below.

Calculator calc;                      
int result = calc.AddInteger(5,5);    
Assert::AreEqual(10, result);         

But not everything is that straight forward, when working with c++ strings the hassle begins. If you are using c++ string in your public API’s have a look at http://www.codeproject.com/KB/string/StringConvertor.aspx

I’m new to testing c++ code in VSTest, this article just represents what I have found out and doesn’t have to represent the best way possible to achieve the result. So if you are testing c++ code with VSTest already and you have some tips and improvements I would like to here them.

Categories: UnitTesting, Visual Studio

Getting 3D Model data in my engine, Part 1

After a long time of no progress for my D3D11 Engine, I finally had and will have some time to work on it.

The first feature I focused on implementing was model support. Until now i had to define all vertex and index data manually which works for a test cube, but when it will get more complex this will not be possible anymore.

So I started thinking how I will organize the data. And I decided for the most simple way for now.

clip_image001[8]

This is the way I decided to organize the model support in my engine. As you can see a model just contains an array of meshes. The model doesn’t contain a position or further information because this will  be part of the scene framework. The model class should be as usable as possible and independent of the scene implementation I will choose.

The mesh contains all the information needed to render it. It contains the Vertex- and IndexBuffer, the InputLayout which connects the Vertex Data with the Input Assembler state of the D3D11 rendering pipeline. And finally it contains the material.

The material itself is very simple in the current state. Just contains the shader and the diffuse texture, and the D3D11ShaderRessource View, so it can be bound to the pipeline as well.

The fileformat problem

After all the classes were implemented and a test model was created by hand it was time to think about the fileformat I’m going to choose. This is a hard decision which i haven’t completely solved until now. After looking at a lot of different formats, i decided that I had to write my own format, which is especially developed for easy usability on the importer site. Importing should be fast and be as easy as possible. Without having to triangulate faces, calculating tangents and bitangents, optimizing the vertex count and optimizing the vertex ordering for better use of caching.
All this should be done by the exporter.

Whoa that’s a lot of tasks for the exporter. My own model format also means I have to write this exporter myself. I firstly thought it would be possible for me to write my own exporter for blender. So I started writing this exporter, but had to learn how much work such an exporter is.
In the meantime Autodesk released the Softimage Mod Tool 7.5. Which isn’t crashing as often as the old one, so it’s finally usable for me.

But having a second modeling tool I use, my exporter for blender just will not work. How will I get this into my engine from now on? FBX? not supported for importing in blender. Collada? The importer is currently not further developed in blender. Google Summer of Code 2009 will bring some improvements to the collada support(Google Summer of Code, project page) but I don’t plan on waiting for this to happen.

So I had to choose a different way.

Which is in progress right now. I will write a new exporter, not binding me to specific tool. I will use the Samples Content Exporter, which can be found in the DirectX SDK March 2009, to build my exporter on top of it. This project uses the Autodesk SDK as underlying technology so the importer site is quite powerful. (Autodesk FBX)
So I will just have to write an exporter and let Autodesk handle the importing for me.

So I have some work to-do …

Categories: all