• Create Account

# Nanoha

Member Since 26 Feb 2009
Offline Last Active Today, 04:50 PM

### In Topic: Good Programming Books Without Computer Access

Today, 04:29 PM

I can't say this is a recommendation BUT I'm currently reading (on and off) C++ Concurrency in Action by Anthony Williams. It's certainly filling in a lot of what I don't know about multi-threading and exposing me to a few other features in the STL that I've not used before. Although I do have a multi-threaded app that I've implemented a few of the things I've learned in I don't feel that I needed to code anything at all to get use out of this book.

I'll also add that the publisher has a thing where if you buy a REAL book you also get the ebook version for free which is great. I love having a real book but I'm becoming a fan of ebooks now so good to have both.

### In Topic: Do I Have To Normalize The Direction Vector For D3Dxboxboundprobe?

Yesterday, 03:23 AM

Update2: When I was iterating all the bounding boxes in my octree, there are several simultaneous hits by the same ray. How do I pick the bounding box that is closest to the pivot?

You will probably get much better responses to this question if you post it as a separate topic.

You could store a list of all the boxes that the ray hits, and choose whichever has the shortest distance between the ray's source and the box' centre. If you are doing this hierachially, which I assume you are since it's an octree, then I think the most hits you can get is 3 but don't take my word on that as I am getting very confused trying to work it out in my head. Easiest option would probably be to store only the 'closest so far'.

### In Topic: Billboards Problems

27 July 2016 - 01:38 PM

@Nanoha, do u mean flip the forward and right vectors or flip what the vector is (.x becomes .z)

Sorry for being unclear, I mean (x, y, z) becomes (-x, -y, -z). I guess I should have said mirror the vector. But only for the right and forward vectors.

```	glm::mat4 viewInv = glm::inverse(view);

// You might actually be able to rip this stuff right out of the matrix rather than multiplying
glm::vec4 right = viewInv * glm::vec4(-1, 0, 0, 0);
glm::vec4 up = viewInv * glm::vec4(0, 1, 0, 0);
glm::vec4 forward = viewInv * glm::vec4(0, 0, -1, 0);

glm::mat4 mytest = glm::mat4(right, up, forward, glm::vec4(0, 0, 0, 1));
```

The reason that 'right' is mirrored is because the particles right is your left. Forward is mirrored for similar reasons, particles forward is my backwards. You will have to check forward though because with OpenGL I think forward might actually be (0, 0, -1). It depends on the coordinate system. Up remains the same because the particle's up is also the viewer's up.

Your best bet is to look for a tutorial that is dealing with this stuff.

### In Topic: Billboards Problems

27 July 2016 - 11:06 AM

So like the following?

What you have there is transforming your world axis into view space which isn't quite what you need. I'm not 100% sure about this myself as I've never had to do it but what you want is the first 3 rows of that view matrix (the right, up and forward vectors). I'm not sure what the syntax is to get that with glm so I can't show an example. Once you have those they will be the opposite of what you want, you should be able to flip the 'right' and 'forward' vectors which should work the same as rotating about the 'up' axis by 180 degrees.

Another option might be to do similar to what you are currently doing and define those vectors in view space (so they are looking at the camera, right(-1, 0, 0), up (0, 1, 0), forward (0, 0, -1)) and then transform them back into world space by multiplying them by the inverse of your view matrix.

### In Topic: Billboards Problems

27 July 2016 - 07:41 AM

You could extract modelview matix of your camera amd get screen coord up and right vectors in notime

I saw something similar in the other billboard thread that's floating around. This certainly sounds like a far more efficient solution. With this approach I'm guessing all the billboards/particles will then be perpendicular to the screen (rather than facing the camera position)? This may or may not be an issue but it sounds like it's worth trying and seeing what it looks like as it is far more efficient than all those cross products per particle.

PARTNERS