Jump to content
  • Advertisement
Sign in to follow this  
Nebu

Closing up with project, few questions

This topic is 3805 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In a few days I need to finish my project which is a simple 3d game, and I want to implement a few more stuff so that the game will actually make sense. few questions: 1)I have a bunch of models loaded, just geometry, with a random range of colors. I want to be able to 'mask' the model so that for example, bullets of enemies will appear red,while mine will appear blue. How can I do that without altering the colors defined for the original model? 2)Currently for monsters random movement, I'm using a unit vector which involves one sqrt, is there a better way to do? 3)rand() is not random enough (I did call srand in the begining of the app), monsters random movement is nearly the same direction, is there a simple alternative? 4)I have yet implemented collision for my bullets with objects and I'm looking for sphere box collision routine. I have searched and found axis aligned routine,but the part of axis aligment is something I'm not sure how to implement (it says axis align sphere to box? sphere remains the same when rotated.? ). Please consider I'm not being lazy, I just don't have time to waste I hoped someone could save me some time. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
1)I have a bunch of models loaded, just geometry, with a random range of colors.
I want to be able to 'mask' the model so that for example, bullets of enemies will appear red,while mine will appear blue. How can I do that without altering the colors defined for the original model?

You can set the color as a shader parameter and then have the pixel shader pass through that color, applying any lighting, shadowing, etc.

Quote:
2)Currently for monsters random movement, I'm using a unit vector which involves one sqrt, is there a better way to do?

Probably not without making it more complex than it needs to be. One square root is nothing these days.

Quote:
3)rand() is not random enough (I did call srand in the begining of the app), monsters random movement is nearly the same direction, is there a simple alternative?

There are a number of other PRNG's out there besides what you get with the standard library. This should help you get started looking for one that suits your needs. Mersenne Twister is a bit of a heavy weight for simple projects but I'm personally a fan.

Quote:
4)I have yet implemented collision for my bullets with objects and I'm looking for sphere box collision routine. I have searched and found axis aligned routine,but the part of axis aligment is something I'm not sure how to implement (it says axis align sphere to box? sphere remains the same when rotated.? ).

If you want something simple and functional, then just check the closest point on the bounding box against the sphere. You'll get a little interpenetration if the side of the box is moving right into the sphere, but it should work well enough not to be noticable. After all, a sphere is a fairly conservative approximation anyway.

Share this post


Link to post
Share on other sites
1) I assume you are using DirectX9 in which case I assume you also have some sort of lighting system enabled in your engine. If this is the case, just use different materials for each faction.

2) I don't know how you use the values elsewhere, but you might be able to just use the squares and not sqrt them. For instance if you are collision checking, instead of checking if (sqrt(x^2 + y^2) < 10) you could just do if (x^2 + y^2 < 100). Simple algebra in that case but you may need the actual sqrt values elsewhere so I can't tell you without knowing more about this instance.

3) Are you using different seeds for each monster's rand() call? You may need to srand() for each monster instead of just once.

4) Not sure what you're talking about here. You're probably better off just using spheres for both objects in collision detection. Mixing boundary types is always a lot of work.

Share this post


Link to post
Share on other sites
Thanks for the replies.
I probably should have mentioned I'm using SDL, not using OpenGL or DirectX9, and currently have no light system. Thats why I'm randomising colors over a range for models on initiation, to fake a decent look. And as I said, its just geometry with random colors(no materials), so any ideas how can I still 'mask' my models?

as for movement, mine is constricted to xz plane so I use:

x=rand(-1,1);
z=sqrt(1-x*x);
(circle with radius of 1).
for randomizing a unit vector, anyway I guess one sqrt isn't too bad.

as for rand I'll try different seed values, If that won't work I'll use a lib.

Thanks in advance!!

Share this post


Link to post
Share on other sites
Quote:
Original post by Nebu
4)I have yet implemented collision for my bullets with objects and I'm looking for sphere box collision routine. I have searched and found axis aligned routine,but the part of axis aligment is something I'm not sure how to implement (it says axis align sphere to box? sphere remains the same when rotated.? ).



http://en.wikipedia.org/wiki/Axis-aligned_bounding_box Look at the differences between the AABB and OBB.

intersection tests: http://www.realtimerendering.com/int/

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!