|
prasad_som wrote: p.s - Could you fix your post. It is breaking forum.
Yes! Master
Thanks
Thanks to give me the spirit to do myself, i have done it! i think you might not forget me i was told you are my master and really you are!!!
Amit
-- modified at 1:46 Wednesday 21st February, 2007
|
|
|
|
|
I've a Gaming project devolped in VC++(MFC) using NetImmerse Engine. If I execute this project a window will open. If select Menu File->Open a tree of objects(VPF Files) is displayed. If I select a particular object, I can move or rotate using menus or tools provided in the window. My problem is related to controlling the move speed. Movement is taking place when we move the mouse. Code for moving the object is written using ON_WM_MOUSEMOVE() Message handler.
The code for Horizontal move speed is:
float m_kHorz = (float) (point.x - m_kScreenCenter[0]);
if (fabs(m_kHorz) <= HORIZONTAL_DEAD_ZONE)
m_kHorz = 0.0f;
else
{
if (m_kHorz < 0.0f)
m_kHorz += (float)HORIZONTAL_DEAD_ZONE;
else
m_kHorz -= (float)HORIZONTAL_DEAD_ZONE;
}
I'll give the definitions:
m_kHorz is the horizontal distance the object is moving from the centre.
HORIZONTAL_DEAD_ZONE is a constant it's value is 25.
Let me tell my problem. The object is moving but the move speed is not constant. When I move the object very much away from the centre(i.e m_kScreenCenter[0]), the speed starts decreasing. I want a uniform move speed.
How can I do this?
|
|
|
|
|
For a start naming a local variable m_kHorz is not a very good idea. The "m_" prefix is usually used to indicate a member variable and so using it on a local variable is just silly and asking for trouble. Rename it kHorz .
Steve
|
|
|
|
|
I've a Gaming project devolped in VC++(MFC) using NetImmerse Engine. If I execute this project a window will open. If select Menu File->Open a tree of objects(VPF Files) is displayed. If I select a particular object, I can move or rotate using menus or tools provided in the window. My problem is related to controlling the move speed. Movement is taking place when we move the mouse. Code for moving the object is written using ON_WM_MOUSEMOVE() Message handler.
The code for Horizontal move speed is:
float kHorz = (float) (point.x - m_kScreenCenter[0]);
if (fabs(kHorz) <= HORIZONTAL_DEAD_ZONE)
kHorz = 0.0f;
else
{
if (kHorz < 0.0f)
kHorz += (float)HORIZONTAL_DEAD_ZONE;
else
kHorz -= (float)HORIZONTAL_DEAD_ZONE;
}
I'll give the definitions:
kHorz is the horizontal distance the object is moving from the centre.
HORIZONTAL_DEAD_ZONE is a constant it's value is 25.
Let me tell my problem. The object is moving but the move speed is not constant. When I move the object very much away from the centre(i.e m_kScreenCenter[0]), the speed starts decreasing. I want a uniform move speed.
How can I do this?
|
|
|
|
|
Is this code in a class? If it is, is there a member variable called m_kHorz ? On a wild guess I suspect the answers to these two questions is yes. I so perhaps this:
if (kHorz < 0.0f)
kHorz += (float)HORIZONTAL_DEAD_ZONE;
else
kHorz -= (float)HORIZONTAL_DEAD_ZONE;
Should look like this:
if (kHorz < 0.0f)
m_kHorz += (float)HORIZONTAL_DEAD_ZONE;
else
m_kHorz -= (float)HORIZONTAL_DEAD_ZONE;
Steve
|
|
|
|
|
m_kHorz is in a class only. I've changed it according to your instruction. The new code is below.
I've a Gaming project devolped in VC++(MFC) using NetImmerse Engine. If I execute this project a window will open. If select Menu File->Open a tree of objects(VPF Files) is displayed. If I select a particular object, I can move or rotate using menus or tools provided in the window. My problem is related to controlling the move speed. Movement is taking place when we move the mouse. Code for moving the object is written using ON_WM_MOUSEMOVE() Message handler.
The code for Horizontal move speed is:
float m_kHorz = (float) (point.x - m_kScreenCenter[0]);
if (fabs(m_kHorz) <= HORIZONTAL_DEAD_ZONE)
m_kHorz = 0.0f;
else
{
if (m_kHorz < 0.0f)
m_kHorz += (float)HORIZONTAL_DEAD_ZONE;
else
m_kHorz -= (float)HORIZONTAL_DEAD_ZONE;
}
I'll give the definitions:
m_kHorz is the horizontal distance the object is moving from the centre.
HORIZONTAL_DEAD_ZONE is a constant it's value is 25.
Let me tell my problem. The object is moving but the move speed is not constant. When I move the object very much away from the centre(i.e m_kScreenCenter[0]), the speed starts decreasing. I want a uniform move speed.
How can I do this?
|
|
|
|
|
No, that is not what I meant. A local variable should should ***NEVER*** be prefixed with "m_". Here's what I meant:
float kHorz = (float) (point.x - m_kScreenCenter[0]);
if (fabs(kHorz) > HORIZONTAL_DEAD_ZONE)
{
if (kHorz < 0.0f)
m_kHorz += (float)HORIZONTAL_DEAD_ZONE;
else
m_kHorz -= (float)HORIZONTAL_DEAD_ZONE;
}
I'm only guessing however; you haven't given enough information for me to be sure.
Steve
|
|
|
|
|
It's a member variable only. It's declared in a class called PerspectiveView which is derived from CView Class. Once again I'm giving the full details.
I've a Gaming project devolped in VC++(MFC) using NetImmerse Engine. If I execute this project a window will open. If select Menu File->Open a tree of objects(VPF Files) is displayed. If I select a particular object, I can move or rotate using menus or tools provided in the window. My problem is related to controlling the move speed. Movement is taking place when we move the mouse. Code for moving the object is written using ON_WM_MOUSEMOVE() Message handler.
The code for Horizontal move speed is:
float m_kHorz = (float) (point.x - m_kScreenCenter[0]);
if (fabs(m_kHorz) <= HORIZONTAL_DEAD_ZONE)
m_kHorz = 0.0f;
else
{
if (m_kHorz < 0.0f)
m_kHorz += (float)HORIZONTAL_DEAD_ZONE;
else
m_kHorz -= (float)HORIZONTAL_DEAD_ZONE;
}
I'll give the definitions:
m_kHorz is the horizontal distance the object is moving from the centre.
HORIZONTAL_DEAD_ZONE is a constant it's value is 25.
Let me tell my problem. The object is moving but the move speed is not constant. When I move the object very much away from the centre(i.e m_kScreenCenter[0]), the speed starts decreasing. I want a uniform move speed.
How can I do this?
|
|
|
|
|
is it possible to add scroll bar for dialog based application as in SDI.
the purpose is i have lot of controls in my dialog and i have add all the controls in one dialog which is half of the screen size, so i have to include a scroll bar for the dialog to view all the controls, but how do i do it?
any suggestions are appreciated.
|
|
|
|
|
Super Hornet wrote: is it possible to add scroll bar for dialog based application as in SDI.
the purpose is i have lot of controls in my dialog and i have add all the controls in one dialog which is half of the screen size, so i have to include a scroll bar for the dialog to view all the controls, but how do i do it?
any suggestions are appreciated.
Add the style WS_VSCROLL and handle WM_VSCROLL .
Override the function OnVScroll to handle vertical scroll events.
Call ScrollWindow to scroll the window.
|
|
|
|
|
in the property window of dialog you can insert vertical and horizontal scrollbar
|
|
|
|
|
i was wondering if any one know how i can detect a color ( like red color) in a bitmap file using C++ code???
Thanks Ricky
|
|
|
|
|
You can use of GetRValue for red, GetGValue for green,GetBValue for blue
|
|
|
|
|
These functions are used to get R,G,B value given COLORREF .
|
|
|
|
|
Perhaps you're after the GetPixel API.
Steve
|
|
|
|
|
In a bitmap file type BMP?
Documentation of the layout of a BMP file is here[^].
The format of each "pixel" of image data varies, depending on bits-per-pixel, planes, etc.
Do you have a certain type of bitmap or does it need to work on any bitmap?
Mark
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
any bitmap image i guess it a picture take from a webcam that is save a a bitmap.
|
|
|
|
|
Same answer as my first reply.
Basically you need to
1) load the bitmap file into memory
2) get a pointer to the pixel bits
3) scan the pixel bits for the attributes you are looking for
All three of these steps vary depending on file type and image bits format.
Have you tried anything so far?
Mark
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
how would u do the pixel bits i not sure of how to do that??
|
|
|
|
|
Depends on the pixel format.
Assuming you are working with RGB data (24-bit/32-bit):
Are you looking for an exact color or fairly close to a color? Using red as an example...
The easiest method is to look for an exact color. Say you want to find bright red - just look
for pixels with value RGB(0xFF,0x00,0x00).
Somewhere in the middle of complexity would be to look for pixels with the red component a
certain percentage higher than the green and blue components. For example, a pixel with value
of RGB(0xFF,0x21,0x32) would be considered red but one with value RGB(0xFF,0x84,0xA8) wouldn't.
This method kind of finds the "redest" pixels.
Then you can get complex with images that are similar but maybe vary in intensity (microscope
slides stained with a certain color comes immediately to mind ). You could create a histogram
using all the pixels in the image and use the result to help automagically detect the proper
percentage mentioned in method 2.
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
Anyone know how to create a application that can intercept output from another application? Any help is appreciated.
|
|
|
|
|
What kind of output to you wish to intercept? Perhaps this[^] will help.
Steve
|
|
|
|
|
shatterstar6457 wrote:
Anyone know how to create a application that can intercept output from another application? Any help is appreciated.
console or UI based app
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
I am using Visual C++ 6.0 MFC. I downloaded the Universal Progress Dialog Demo/Source project from the article written by P. GopalaKrishna. I tried to compile the project on my machine and received an "error C2664: 'DialogBoxParamA' : cannot convert parameter 4 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned i
nt,long)'
None of the functions with this name in scope match the target type"
Does anyone recognize what I am missing in order to compile and execute this demo?
Thanks,
Buck
Buck
|
|
|
|
|
It would be helpful if you showed the actual code that generated this message! It looks like a calling convention mismatch to me.
Steve
|
|
|
|