• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
mike4

heading to position transform angle in C++

30 posts in this topic

Hi
how to transform a normal heading angle in degrees:


0
|
360


to what I want:

180
| |
0
| |
-180


Something alike:
if angle > 180
...
but I cannot figure it. I need to avoid the gap between 0 to 360 for a smooth 3D sound.
Many thanks
Michael
-1

Share this post


Link to post
Share on other sites
i get values from 0 - 360 but want to have a second value following that: 0 - 180 - 0 - -180

But maybe I should try fmod and omit 0 returns, for my sound listener positions?
-1

Share this post


Link to post
Share on other sites
[code]double convert_0_360_angle_to_m180_180(double angle) {
return angle < 180 ? angle : angle - 360;
}[/code]

But now you have a gap at 180. If you were to really explain what your problem is, I am sure we could find a solution (which probably doesn't even involve using angles).
0

Share this post


Link to post
Share on other sites
That's exactly what I try to avoid. This is the sound source position, hence having a gap, for ex. 0 - 360 disrupts sound. No more nice fading in or out depending on listener position.
I've to use/manipulate a degrees 0-360 for the sound source. I've two sounds, one in front and one behind. the one behind is close to 360 hence not usable resulting in sound disruption.
alSource3f(Sources[2], AL_POSITION, heading/10, lY/10, lZ/10);
heading is the value which changes 0-360 as the sound object rotates.
Many thanks
PS: a gap at 180 might be ok, I'll try that now and report back. Edited by mike4
0

Share this post


Link to post
Share on other sites
No luck, I've already tried something similar.

I have values camera: y,z,y and heading
and for sound source the same. Both change depending on viewer or source location/heading. Probably
I'm doing something completely wrong?
0

Share this post


Link to post
Share on other sites
What exactly do you do with those headings? Ultimately, the only things that should matter are the sine and cosine of those angles, and those don't have any discontinuities.
0

Share this post


Link to post
Share on other sites
Yes, for now I only do alike also for the listener:
alListener3f(AL_POSITION, cH/10,cY/10,(lZ/10)+disX);
cH is the heading degree and disX the distance.

Could you tell me how to use sine/cosine with those values?
Many thanks indeed.
0

Share this post


Link to post
Share on other sites
Wait, you are dividing the heading by 10? Of course that will have trouble with discontinuities!

But, why are you setting the coordinates of AL_POSITION to some angle? That makes no sense at all. Edited by alvaro
0

Share this post


Link to post
Share on other sites
I did that a long time ago. As far as I remember, only setting x,y,z is not taking in account the airplane movement, hence I did that ugly handicraft. I'll try tomorrow and
get back.
-1

Share this post


Link to post
Share on other sites
Yes seems so. Could you tell me how to use cos or sin with the heading value?
Many thanks
0

Share this post


Link to post
Share on other sites
Hmm, if I would know it much better I'd not need to ask. Narrowed down the problem to, as I said, Sound is not hearable when heading jumps from 360 to 0 degrees.
So I need a way to avoid this gap and get 360-359-358 etc. The solution is probably something very simple...
-1

Share this post


Link to post
Share on other sites
If you are just trying to transform [0, 360] to [180, -180] then just:

newAngle = 180 - angle;

But what would really help us help you is some context. We can sort of see that you are having a problem with OpenAL, but other than just saying 'Not hearable at certain angles' we have no idea what you are doing vs. what the result is you are trying to achieve. Maybe even draw us some pictures to illustrate the problem?

Spend some time explaining the situation and we can spend more time trying to help. The more information you give us, the more we have to work with.
1

Share this post


Link to post
Share on other sites
Thanks but it seems that I need 0-360-0 in other words: ... 359 - 360 - 359 - 358 ...
Currently I get ... 359 - 360 - 0 - 1 ...which I cannot use.
So if 0 +=359, if 1 +=357, if 2 +=355, if 3 += 353 etc. while < 180
Any forumula for that?
Many thanks
0

Share this post


Link to post
Share on other sites
In the first post, your question was to map the range 0 to 360 to the range 180 to 0 to -180. In your second post, you now mention the mapping from the range 0 to 360 to the range 0 to 180 to 0 to -180 instead. And now you've mentioned the mapping to the range 0 to 360 to 0 as well.

It sounds very much like you don't know what you want, becuase your question has changed for every answer and follow-up question. Take alvaro's advice and don't ask how to map numbers from one range to another. Instead, describe the problem so that we know what it is you want in the first place. Edited by Brother Bob
0

Share this post


Link to post
Share on other sites
So what...apparently 0-180- doesn't work, hence I need a solution as posted above.

I tried to change both listener and source to:
newAngle = 180 - angle;
and I don't know why it's not working for now. I still get sound interruptions. Back to:
So if 0 +=359, if 1 +=357, if 2 +=355, if 3 += 353 etc. while < 180
Any forumula for that?
-1

Share this post


Link to post
Share on other sites
Do you mean you have the angle of the sound (0-360) relative to the camera, but you want to convert it to how many degrees it is from the "directly in front" direction? so if its 90 degrees, it could be 90 degrees to the left or right?

Or what?
-1

Share this post


Link to post
Share on other sites
You are in too deep with your current implementation, and it makes luttle sense to someone who isn't in your headspace right now.

Forget about angles for a minute. Talk about the high level goal first, then start talking about how you are currently implementing it.

Talk about concrete domain objects first. So you might have a player, who is a beekeeper, and you have some bees buzzing around, and you want the sound to reflect where the bees are. Then start telling this how you're making angles or whatnot, and we can (probably) tell you a way to do this without angles. Edited by rip-off
0

Share this post


Link to post
Share on other sites
waterlimon. I've given from the gameengine the listener and source positions (x,y,z) and headings in degrees as I said before. Now I only give those positions to listener and sound source and only change the source heading. One in front and one behind. All fine and working only when source heading flips from 360 - 0 sound no longer nicely in-/decreases depending on the listener but is suddenly gone.
Listener and airplane are moving in all directions, hence it's probably the cheapest solution to close the gap 360 - 0 as above. But maybe it can be done much nicer? This
is an old hack which even myself am hard to understand it's logic. I'll go through the code tomorrow again. The listener heading is always towards the airplane, only the airplane rotates.
0

Share this post


Link to post
Share on other sites
Errr ...
[quote name='mike4' timestamp='1336988479' post='4940008']
Yes, for now I only do alike also for the listener:
alListener3f(AL_POSITION, cH/10,cY/10,(lZ/10)+disX);
cH is the heading degree and disX the distance.
[/quote]

You are setting an angle as the value of a position component! That means that your listener wanders around and suddenly jumps in space in dependence on an orientation. That is definitely a mistake.

Set the AL_POSITION like the camera's position (or like the object's position in case of the source), and set the AL_ORIENTATION using sine and cosine on the heading to compute a direction vector from the angle(s).

(If you want an attenuation effect that is not given by the normal operation of AL then try some volume computation but don't try to misuse the position for that because it will not work properly.) Edited by haegarr
1

Share this post


Link to post
Share on other sites
Four days ago, in post #9 of this thread, I already told him that using angles as values for AL_POSITION makes no sense, but I think he ignored me.
0

Share this post


Link to post
Share on other sites
Thanks. How would that look using sin/cos of the heading degrees?

// Orientation of the listener. (first 3 elements are "at", 3 are "up")
ALfloat ListenerOri[] = { 0.0, 0.0, 1.0, 0.0, 1.0, 0.0 };
-1

Share this post


Link to post
Share on other sites
Reread rip-off's comment #19 in this thread until it makes sense. Then please don't ask again until you can give us the kind of description of the situation that is required.
0

Share this post


Link to post
Share on other sites
No again, I cannot change given things. I can only use x,y,z and heading for source and listener.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0