• Create Account

We're offering banner ads on our site from just \$5!

# hupsilardee

Member Since 20 Oct 2010
Offline Last Active Nov 18 2014 07:51 AM

### Visual C++ Express: Custom "Object Type"

16 December 2013 - 09:57 AM

Hi all. I've been using item templates with a custom build tool and it's working fine. However, the item template only gets applied if I select "Create New Item". Ideally I want to be able to use "Add Existing Item", and customise the object type rather than using custom build tool and manually setting the properties. Is there a way to do this with VC++ 2012 Express? (I might upgrade to 2013 if required)

### Tangents for heightmap from limited information

11 December 2013 - 08:28 AM

(solved)

Hi all, I'm working on normal mapping for my terrain. My terrain system calculates a normal map on the fly when a heightmap is loaded (or generated), which means I can use per-pixel normals. This makes distant terrain look a lot nicer. However, I am wondering if there is a clever way to calculate the tangent space for normal mapping, given some extra information

1. You are given the normal for a pixel, and this is already normalized

2. The first tangent is guaranteed to have X component = 0, because it's just a straightforward texture-splattedgrid geometry

3. Similarly, the second tangent has Z component = 0

4. Tangent space should be orthonormal

How can I fill in the unknowns in the most performance-friendly way possible?

Normal: (nx, ny, nz)

Tangent: (0, ?, ?)

Bitangent (?, ?, 0)

EDIT: Solved it.

```// tangent known to be perpendicular to normal
dot(n, t) = 0
nx*tx + ny*ty + nz*tz = 0

// x component is 0
ny*ty + nz*tz = 0

// length of tangent is 1
ty*ty + tz*tz = 1

```

Now I have 2 equations for 2 unknowns which gives the z component as solution to a quadratic, where I'll take the positive answer! and I can work out the bitangent similarly, or use a cross product

### Few questions about DXGI formats

08 October 2013 - 03:25 PM

I've been looking through the DXGI_FORMAT so I can familiarise myself with everything D3D11 has to offer. Now I have a few questions about some of the formats I didn't understand...

1. What the hell does XR_BIAS mean? There was a wealth of Google results, none of which I could even begin to understand. Could someone explain this in small words?

2. Why are there no formats with 16 or 8 bits per channel (BPC) and 3 channels? Eg, R32G32B32_FLOAT exists but R16G16B16 does not.

Seems like they'd be very useful for G-buffer organisation alone.

3. Why do some formats have 2 identical components? Eg R8G8_B8G8?

4. Some formats have a lot of wasted space marked as X - what's the point of this?

I think I know the answer to question 4 though. The X32 or X24 formats accompany the depth formats, so you can create a Texture2D with the R24G8_TYPELESS format, then create a DSV for it with D24UNORM_S8UINT to use as a depth buffer, and a SRV with R24UNORM_X8_TYPELESS to read the depth back in another shader (eg SSAO shader), am I right?

### VC++ 2012 - Custom build tools and item templates

11 June 2013 - 09:25 AM

Hi all. I'm very happy with the way Visual C++ 2012 Express can auto-compile your shaders at build time to save loading time, so I'm looking at doing the same with other game assets. At the moment I'm making a custom build tool for sprite fonts, using the DirectXTK MakeSpriteFont command line. I got the custom build tool working for one file, with the Custom Build Tool property page looking like this:

```Command Line:    "\$(OutDir)FontTool.exe" "%(Filename)%(Extension)"
Description:          FontTool is compiling a font...
Outputs:               \$(OutDir)\\$(Filename).csf
Treat Output as Content
```

FontTool is a quick command tool I whipped up in a separate project that reads the font attributes from a lua script in the text file and calls MakeSpriteFont based on those.

The problem is, when I tried to make an item template out of this file, new files made with the template don't have the custom build tool specified, they have reverted to "Doesn't participate in build". How can I include the same custom build in the item template?

### Object handle getting released; causing a null pointer error?

06 May 2013 - 12:37 PM

Hi all, I've been using Angelscript in my project with great success so far, except this one weird bug.

I have bound my MeshSceneNode class to the scripting engine for scripting. It can only be created/destroyed by using the Scene interface (which appears as a singleton to the script)

```// C++
assert(0 <= engine->RegisterObjectType("MeshSceneNode", sizeof(MeshSceneNode), asOBJ_REF | asOBJ_NOCOUNT));
assert(0 <= engine->RegisterObjectMethod("CScene", "MeshSceneNode@ CreateMesh(const string &in)", asMETHOD(Scene, AddMesh), asCALL_THISCALL));
assert(0 <= engine->RegisterObjectMethod("CScene", "void DestroyMesh(MeshSceneNode@)", asMETHOD(Scene, DestroyMesh), asCALL_THISCALL));
```

I made a Character class in script, and made an Avatar subclass to handle graphical representation of it (thus fulfilling ORP), like so

```// Angelscript
class Avatar
{
Character@ Char;
MeshSceneNode@ armour;
MeshSceneNode@ helmet;

Avatar(Character@ char)
{
@Char = char;
helmet = Scene.CreateMesh("helmet_steel.obj");
armour = Scene.CreateMesh("armour_steel.obj");
}
~Avatar()
{
Scene.DestroyMesh(helmet);
Scene.DestroyMesh(armour);
}
}
class Character
{
Avatar@ avatar;

}
```

Now the problem is, when the game shuts down the player is obviously destroyed, but when Scene::DestroyMesh is called, it complains that the meshes passed in are null pointers. Why?

PARTNERS