PDA

View Full Version : animation problem (run automatically )



rimie23
10th June 2012, 08:49
Hi
i make animation but it run automatically (when i run my programme it run )

that's the function of animation


bool OgreWidget::frameRenderingQueued(const Ogre::FrameEvent &evt){
if (mDirection == Ogre::Vector3::ZERO)
{
if (nextLocation())
{

}
}
else
{
Ogre::Real move = mWalkSpeed * evt.timeSinceLastFrame;
animat(move);

}
return true;

}
void OgreWidget::animat(Ogre::Real move)
{
mDistance -= move;
if (mDistance <= 0.0f)
{
mNode->setPosition(mDestination);
mDirection = Ogre::Vector3::ZERO;
// Set animation based on if the robot has another point to walk to.
if (! nextLocation())
{

}
else
{
// Rotation Code will go here later
}
}
else
{
mNode->translate(mDirection * move);
} // else
} // if



i make animat as slot
and in my maniwondow i make like that


repo_cam = new QToolButton(this);
Move->setObjectName(QString::fromUtf8("Move"));
Move->setGeometry(QRect(150, 10, 51, 31));
connect(Move, SIGNAL(clicked()), mOgreWidget, SLOT( animat(Ogre::Real move)));


But with this code when i clic on the button the animation do not run and run automatically

amleto
10th June 2012, 10:50
Is your question really 'why doesn't my slot get called?' Haven't we been over providing simple compilable examples for BASIC problems like signal/slot connection?

I think I have previously informed you (http://www.qtforum.org/post/118788/button-signal-slot.html#post118788) that you cannot connect signals to slots where the slot has more arguments. If you had bothered to debug your own code, you would have seen error message when trying to do this
connect(Move, SIGNAL(clicked()), mOgreWidget, SLOT( animat(Ogre::Real move)));

Why don't you get used to the debugger and start trying to put the smallest of effort into solving your problems before asking for help at every opportunity?

As an aside, does your code really look like this?


bool OgreWidget::frameRenderingQueued(const Ogre::FrameEvent &evt){
if (mDirection == Ogre::Vector3::ZERO)
{
if (nextLocation())
{

}
}
else
{
Ogre::Real move = mWalkSpeed * evt.timeSinceLastFrame;
animat(move);

}
return true;

}


Why aren't you indenting consistently? Why are you indenting so much?

rimie23
10th June 2012, 12:26
bool OgreWidget::frameRenderingQueued(const Ogre::FrameEvent &evt){
if (mDirection == Ogre::Vector3::ZERO)
{
if (nextLocation())
{

}
}
else
{
Ogre::Real move = mWalkSpeed * evt.timeSinceLastFrame;
animat(move);

}
return true;

}

yes it is like that , i make simple animation if it work i will add code in the


if (nextLocation())
{

}

that's it

i make now like that

connect(Move, SIGNAL(clicked()), mOgreWidget, SLOT( animat()));



bool OgreWidget::frameRenderingQueued(const Ogre::FrameEvent &evt){
if (mDirection == Ogre::Vector3::ZERO)
{
if (nextLocation())
{

}
}
else
{
move = mWalkSpeed * evt.timeSinceLastFrame;
animat();

}
return true;

}
void OgreWidget::animat()
{
mDistance -= move;
if (mDistance <= 0.0f)
{
mNode->setPosition(mDestination);
mDirection = Ogre::Vector3::ZERO;
// Set animation based on if the robot has another point to walk to.
if (! nextLocation())
{

}
else
{
// Rotation Code will go here later
}
}
else
{
mNode->translate(mDirection * move);
} // else
} // if



But it still work automatically

amleto
10th June 2012, 13:06
"But it still work automatically"
please explain more.


And why did you take all formatting out of your code?
The code tags are to make reading code easier. Therefore it doesnt help if you post code like where brace indentation doesnt match, or where there is no indentation at all.

rimie23
10th June 2012, 13:18
"But it still work automatically"
please explain more.
the animation still run when i run my application not when i clic on the buttons

And why did you take all formatting out of your code?
i explained to you why it is empty code in "if", "else"
i do not put any code even in my application her (i cut past the code of the fuction "void QOgreWidget::animat()" )
i want just make simple animation if it work i will add code in "if" test (i do not just delete those test to not forget what i must to do)

you can understand now why the code of animat () is like that ?

amleto
10th June 2012, 13:23
"And why did you take all formatting out of your code?"
I asked why you removed *formatting*, not why you have empty code blocks.

If you want to know why your code is being run, just USE YOUR DEBUGGER and look at call stack.


Do you know how to use your debugger? Because it seems you don't like to use it very much...

rimie23
10th June 2012, 13:28
I asked why you removed *formatting*, not why you have empty code blocks.
i do not put any code to remove it i just add the "if" to do not forget that i must put this test when i will make animation more complex
ok?

amleto
10th June 2012, 13:45
please look up the definition of 'formatting'

rimie23
10th June 2012, 13:48
when i debug it do not said to me any thing (like i have problem in the slot or somthing seem like error)
it just run animat automatically

amleto
10th June 2012, 15:18
Like I said,

If you want to know why your code is being run, just USE YOUR DEBUGGER and look at call stack.

rimie23
10th June 2012, 18:52
Hi,
you mean that i make preakpoint in "animat()" and see how it run ?
if you mean that
when i debug with (f10)
i do not see anything strange

what i must to see ?

amleto
10th June 2012, 18:59
1) You said you *want* it to happen when you press button.
2) You said it *does* happen automatically. (What do you even mean by 'automatically'?)

So you can find out the *reason* for 2) by using your debugger.

rimie23
10th June 2012, 19:26
look at this video
to know what i mean by automatically

http://www.2shared.com/file/rmXc6Fs-/animvid.html

wysota
10th June 2012, 22:02
Look rimie, dreamvig or whoever you are. If you want to develop software, there is this little thing you need to do -- you need to learn. Amleto seems to be very patient with you however I'm sure his patience has its limits. You were told many times to do this or that and from my personal impression it seems you completely ignore most of the things you are told. I don't know why you do that but if you continue to behave this way, eventually nobody will want to help you anymore. You need to start investing your time in your self-improvement instead of just focusing on the functionality of your application.

rimie23
10th June 2012, 22:09
You were told many times to do this or that and from my personal impression it seems you completely ignore most of the things you are told.
like what ?
he told to me to change the parameter of the slot i change it
he told to me to debug my program i debug it and i put the video

wysota
10th June 2012, 22:15
I'm really not going to argue with you about it. Take my friendly advice or not, that's your choice. Your discussion with me about using layouts is a perfect example of what I mean.

rimie23
11th June 2012, 00:27
Ok thanks for the advice

Added after 1 57 minutes:

i change my code littel like that
now i can make animation only when i clic on the button
i make like that


connect(repo_cam, SIGNAL(clicked()), this, SLOT( makeanim()));
void Coordinate3dWidget::makeanim()
{
bool istrue=true;
emit newbool(istrue);
}

and

connect(page_14, SIGNAL(newbool(bool)), mQOgreWidget , SLOT(animat(bool)));
and in animat


void QOgreWidget::animat(bool istrue)
{
while(istrue)
{
mDistance -= move;
if (mDistance <= 0.0f)
{
mNode->setPosition(mDestination);
mDirection = Ogre::Vector3::ZERO;
istrue=false;
// Set animation based on if the robot has another point to walk to.
if (! nextLocation())
{
// Set Idle animation
/* mAnimationState = mEntity->getAnimationState("Idle");
mAnimationState->setLoop(true);
mAnimationState->setEnabled(true);*/
}
else
{
// Rotation Code will go here later
}
}
else
{
mNode->translate(mDirection * move);
}

}

}