# Zerd

Member

76

122 Neutral

• Rank
Member
1. ## Unexperienced guy - collision detection, help needed :)

I think I would try it like this: Perform a* pathfinding to get the shortest path to your estimated position. Usually a* would try another path if an obstacle was found or the square is not walkable. In your case you would strictly follow the path as if there was no obstacle, but store the information which square is the first obstacle in your path. With that way you could also differ between an obstacle and "walkable" squares. Maybe this idea helps you... There might be a better solution, but this was the first which came to mind Cheers Zerd
2. ## Rotate Object To Unit Vector Direction

Thx for your fast respond! I found an answer to my question. Sorry that I didn't find a solution before, but I had trouble finding the right search parameter, I'm not nativ english speaking. For the record, this seems like a good solution for this needs: http://www.gamedev.net/topic/177004-following-high-polygon-terrain/page__view__findpost__p__2300386 Thanks again! Zerd
3. ## Rotate Object To Unit Vector Direction

Good evening! I am trying to rotate an object so it gets the alignment of the ground triangle. What I've got is the position of my object, the normal of the triangle and a direction vector of my object. I thought it might be a good idea to get the xyz rotation angles of the normal (vec1). I tried this by setting the x value of the normal to zero (vec2). by calculating the dot product of original normal vec1 and the vec2 (with x = 0) I thought I might get the corresponding rotation. After doing this I thought I'd have the xyz rotation which I just could apply to my object. Well obviously it doesn't work this way (at least not in my tests ) Can somebody give me a hint where I'm thinking wrong or whats the usual way of doing this? Thanks! Zerd
4. ## Relative position calculation

Thx for your reply! I'd like to finish the raytest-attempt before trying another collision test method, but than you for your tips!! I allready asumed that I can use the matrix to transform the initial positions to the rotated positions, but I can't figure out how... Would I use the the rotation values of the matrix and perform a multiplication with the initial positions? Which calculation do I need to perform (and why)? I read a couple of articles in several books about vector and matrix calculations, but I just can't apply it to my problem.. :(
5. ## Relative position calculation

Hi! I'm pretty new to 3D programming, so my problem might be easy for you to solve, but I don't really have any more ideas how I can solve it. I have a flat boxed object which I move around on a surface (bound to a environment collision). Now I want to add several raytests to the box model to check for collision with the environment. I have access to the Object-translation (a 3x4 matrix). Now I thought a good idea would be to make ray-based collisiontests on each border of the object (so 8 tests in total) I calculate these positions using the center of my box object and adding / subtracting length or depth from this position. e.g. v3CenterPos(0.0, 0.0, 0.0) length = 10.0 depth = 5.0 testing positions: v3TopLeft = v3CenterPos.x - (length / 2.0), v3CenterPos.y, v3CenterPos.z - (depth / 2.0) v3TopCenter = v3CenterPos.x, v3CenterPos.y, v3CenterPos.z - (depth / 2.0) v3TopRight = v3CenterPos.x + (length / 2.0), v3CenterPos.y, v3CenterPos.z - (depth / 2.0) v3CenterLeft = v3CenterPos.x - (length / 2.0), v3CenterPos.y, v3CenterPos.z v3CenterRight = v3CenterPos.x + (length / 2.0), v3CenterPos.y, v3CenterPos.z v3BottomLeft = v3CenterPos.x - (length / 2.0), v3CenterPos.y, v3CenterPos.z + (depth / 2.0) v3BottomCenter = v3CenterPos.x, v3CenterPos.y, v3CenterPos.z + (depth / 2.0) v3BottomRight = v3CenterPos.x + (length / 2.0), v3CenterPos.y, v3CenterPos.z + (depth / 2.0) In the image the red dots are the positions calculated the way described above. This works fine when the box object is not rotated (here is my problem) How do I calculate the test positions (marked as blue dots in the image) when the object itself is rotated by an unknown angle? (I know this angle should be accessable from the 3x4 matrix, but I don't know how to use it to calculate the proper vector positions. I hope my writing does make any sence ;) Thx for your help! -Zerd
6. ## Own Key type for std::map

Thats a bloody good question... I guess that was a too obvious solution... -.- Thx, thats just what I needed...
7. ## Own Key type for std::map

Hi! I was trying to create my own Key type, which stores additional information. struct OwnKey { std::String strKey; void* addData; }; I want to use it like this: std::map<OwnKey key, T* value> m_map; I figured out I have to write my own compare class to be able to compare them: struct classcomp { bool operator() (const OwnKey& lhs, const OwnKey& rhs) const {return lhs.strName.compare(rhs.strName) < 0;} }; Now the problem is, I can't use the map member find("string") to access the map. (yes, I want to access the map using only the string, but be able to access the void* as well). So I guess I might have a flaw in my thinking... Is there a way to do this kind of stuff? You might ask yourself why I don't put the necessary information in the value T* object. But thats the problem, I'd need to subclass a lot of classes if I wanted to do that, so I thought maybe there is a way to store the other information in the key type. Do you have an idea how I could solve this problem? (with the use of the map container?) Thx, Zerd
8. ## std::stringstream and DLL linking problem

Hi! I have discovered a very odd problem while working on a dll plugin system. The dll and the main project is compiling and linking just fine, until I insert a stringstream call into the dll's sourcecode (which is used by a Logger class). Quote:error LNK2001: unresolved external symbol "public: class std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall dA::Logger::Get(enum dA::eLogLevel)" (?Get@Logger@dA@@QAEAAV?$basic_stringstream@DU?$char_traits@D@std@@V?\$allocator@D@2@@std@@W4eLogLevel@2@@Z) This is the error I get. By searching the web I found someone who said dll's are having trouble with templates and since stringstream is a templateclass this might be the answer. But I can't figure out a way to avoid this error. (Except not using stringstream) Does anyone have a clue what I could do to get rid of this problem?
9. ## QT and vs2005

Did you run qmake within your Visual Studio 2005 Command Prompt? (Start -> Programs -> Visual Studio 2005 -> Tools -> Visual Studio 2005 Command Prompt) I think I had a similar error once, it was because I used the normal windows command prompt and not the one which is bound to the VS.
10. ## WaveIn level range to low?

Thank you two for your replys! It's working now, after I casted it to short* (again). I don't even know what I did wrong the first time I did that... However, now I feel kind of ashamed that I bothered you with this "problem" ;) Thx again!! Cheers Zerd
11. ## WaveIn level range to low?

Quote:Original post by Kylotan Are you saying that it doesn't work? You've not really explained what you've tried and the results you get. What is the error, if there is one? There isn't really an error: Quote:Original post by Zerd The captured data has a value range between -127 and 128, which makes sence after a look at the WAVHDR struct (lpData is a char*). However, I have to figure out if the received data is a real tone or just background noise. How can I figure that out? Since the value range is so small, I can't distinguish if it's noise or a real tone. Is there any way to change the value range of the incoming data?There is no real error, its just not a reasonable result. When I capture sound over the microphone, and save it as a wave file using the windows recorder, the level of the pcm data (amplitude) of the wave file is much higher than the level I get when I'm using the waveIn functions. The curious thing is this value range between -127 and 128 of the recorded data even if I setup the waveformat to 16 bit. Quote:Original post by Adam_42I think you'll need to cast that data pointer to an appropriate type before using it to read samples (which is short* if it's actually 16-bit PCM data) I've tried that too, but it didn't change the outcome, thats why I thought I might do something wrong...
12. ## WaveIn level range to low?

Quote:The first thing, is to get your wave in capturing in 16 bit rather than 8 bit resolution! That will go a long way to fixing your problem of the resolution being too low to easily distinguish noise from a quiet tone. When you set up the recording, this should be an option available to you, depending on your hardware. I believe this means passing an appropriate WAVEFORMATEX structure to waveInOpen(), perhaps based on the results of waveInGetDevCaps(). Thank you for your reply! I fill the WAVEFORMATEX structure like that: waveFormat.wFormatTag = WAVE_FORMAT_PCM; waveFormat.nChannels = 1; waveFormat.nSamplesPerSec = 44100; waveFormat.wBitsPerSample = 16; waveFormat.nBlockAlign = waveFormat.nChannels * (waveFormat.wBitsPerSample/8); waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign; waveFormat.cbSize = 0; // some more stuff err = waveInOpen(&waveInHandle, WAVE_MAPPER, &waveFormat, (DWORD)err, 0, CALLBACK_THREAD); I thought this should setup the resolution to 16 bit. It's kind of curious that my WAVEFORMATEX setup doesn't work since recording with the windows audiorecorder datalevel changes when speaking into the microphone (just as I would expect). Currently I'm not using waveInGetDevCaps, this function just returns an struct with deviceinformation right? how could that help with my problem? since the recording with the audiorecorder (16 bit and 2 channel) works I'd suppose my soundcard supports 16bit audio recording.
13. ## WaveIn level range to low?

Hi, currently I'm working with the wavein functions to capture and analyze tones via microphone. Now I ran into a problem. The captured data has a value range between -127 and 128, which makes sence after a look at the WAVHDR struct (lpData is a char*). However, I have to figure out if the received data is a real tone or just background noise. How can I figure that out? Since the value range is so small, I can't distinguish if it's noise or a real tone. Is there any way to change the value range of the incoming data? In my understanding, the level of the data should rise when a tone is captured by the microphone, or did I get that wrong? Here is my callback function which handles the waveIn Databuffer, is there anything wrong?: DWORD WINAPI CRecorder::waveInProc(LPVOID arg) { MSG msg; CRecorder *reference = (CRecorder *)arg; /* Wait for a message sent to me by the audio driver */ while (GetMessage(&msg, 0, 0, 0) == 1) { switch (msg.message) { case MM_WIM_DATA: if (((WAVEHDR *)msg.lParam)->dwBytesRecorded) { int bytesRecorded = ((WAVEHDR *)msg.lParam)->dwBytesRecorded; double *fftData = new double[((WAVEHDR *)msg.lParam)->dwBytesRecorded]; for(int i=0; i< ((WAVEHDR *)msg.lParam)->dwBytesRecorded; i++) { fftData = ((WAVEHDR *)msg.lParam)->lpData; } // FFT and some other stuff // ..... // ..... if (reference->getIsRecording()) { waveInAddBuffer(reference->getWaveInHandle(), (WAVEHDR *)msg.lParam, sizeof(WAVEHDR)); } else { ++(*reference->getDoneAll()); } continue; case MM_WIM_OPEN: continue; case MM_WIM_CLOSE: break; } } return(0); } Thank you! Cheers Zerd P.S: I'm not sure if this was the right forum... It also might fit into the General Programming forum... Sorry if this is the wrong one ;)
14. ## Keyboard input

Mh.. In this case, what is the best way to pass the messages to the GUI system? I have a class GUI which handles all GuiElements. In the main-loop gui.renderAll() is called to display everything which is registered to the GUI. Right now GUI is no global variable. So if I would work with the Windows message pump I'd have to define the GUI-instance global to be able to access it from the WindowProc right? (Sorry I'm new to IMGUI... Until now I thought there should be NO message-routing between the elements...)
15. ## Keyboard input

Since I'm implementing the "Immediate Mode Graphical User Interface"-idea I don't use the Windows Message pumps... I didn't have any trouble implementing the other elements of the GUI, the inputBox is the first serious problem...