darrenc182
Topic Author
Posts: 6
Joined: 23 May 2015, 04:05

Creating a Storyboard using C++

11 Jun 2015, 01:50

I am new to NoesisGUI and I am trying to create a storyboard using pure C++. I need this storyboard to start animating based on what may occur in-game so I either need to be able to trigger a storyboard defined in XAML or start one created in C++. I have tried to create a storyboard for this purpose in XAML, but I keep getting unhandled exception errors so I am trying to do it in C++ now. The code below also gives me an unhandled exception when I try running it:
Noesis::Gui::DoubleAnimation anim=Noesis::Gui::DoubleAnimation();
anim.SetFrom(1.0f);
anim.SetTo(0.0f);
anim.SetDuration(Noesis::Gui::TimeSpan(0, 0, 0, 0, 500));

Noesis::Storyboard::SetTarget(&anim, m_cCanvas);
Noesis::Storyboard::SetTargetProperty(&anim, &Noesis::Gui::PropertyPath("Opacity"));

Noesis::Gui::Storyboard pStoryboard = Noesis::Gui::Storyboard();
pStoryboard.GetChildren()->Add(&anim);
I get the unhandled exception error on the last line (pStoryboard.GetChildren()->Add(&anim);)

I am using version 1.2.3 (r5440) and have been trying some of the code snippets in the forum, but I believe that the code in those snippets are old with depreciated syntax. Is there something I am doing wrong? Any and all help will be greatly appreciated and I thank you in advance.
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Creating a Storyboard using C++

11 Jun 2015, 10:26

Hi,

In NoesisGUI (almost) all classes follow a ref counted life-cycle and are meant to be used along with smart pointers.

Your code should be written this way:
Noesis::Core::Ptr<Noesis::Gui::DoubleAnimation> anim = *new Noesis::Gui::DoubleAnimation();
anim->SetFrom(1.0f);
anim->SetTo(0.0f);
anim->SetDuration(Noesis::Gui::TimeSpan(0, 0, 0, 0, 500));

Noesis::Storyboard::SetTarget(anim.GetPtr(), m_cCanvas);
Noesis::Core::Ptr<Noesis::Gui::PropertyPath> path = *new Noesis::Gui::PropertyPath("Opacity");
Noesis::Storyboard::SetTargetProperty(anim.GetPtr(), path.GetPtr());

Noesis::Core::Ptr<Noesis::Gui::Storyboard> pStoryboard = *new Noesis::Gui::Storyboard();
pStoryboard->GetChildren()->Add(anim.GetPtr());
 
darrenc182
Topic Author
Posts: 6
Joined: 23 May 2015, 04:05

Re: Creating a Storyboard using C++

11 Jun 2015, 15:57

Thanks for responding to me. I tried the code you presented, but I get the following error when trying to compile it:
error C2661: 'Noesis::Core::BaseObject::operator new' : no overloaded function takes 3 arguments

The syntax error points to this line of code:
Noesis::Core::Ptr<Noesis::Gui::DoubleAnimation> anim = *new Noesis::Gui::DoubleAnimation();

I get the syntax error on these two lines of code as well:
Noesis::Core::Ptr<Noesis::Gui::PropertyPath> path = *new Noesis::Gui::PropertyPath("Opacity");
Noesis::Core::Ptr<Noesis::Gui::Storyboard> pStoryboard = *new Noesis::Gui::Storyboard();

Do you know why I might be getting this error?
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Creating a Storyboard using C++

11 Jun 2015, 20:11

What #includes do you have in your .cpp?

I think it could be a problem of not including the class definitions for DoubleAnimation, PropertyPath and Storyboard;

With version 1.2.3 you can use:
#include <NoesisGUI.h>    
This header file includes all the class definitions of NoesisGUI, so it is best used with precompiled headers.
 
darrenc182
Topic Author
Posts: 6
Joined: 23 May 2015, 04:05

Re: Creating a Storyboard using C++

11 Jun 2015, 22:05

I had both Noesis.h and NoesisGUI.h included. I removed the Noesis.h header file, but I still get the error. I had some memory leak definitions, but I disabled them and now I am not getting those errors. I am getting an unhandled exception at this line:
pStoryboard->GetChildren()->Add(anim.GetPtr());

I am using MFC for this particular project because it is an editor. Below is an update to the code I am using:
m_cCanvas = xaml->FindName<Noesis::Gui::Canvas>("StaminaBars6");

Noesis::Core::Ptr<Noesis::Gui::DoubleAnimation> anim = *new Noesis::Gui::DoubleAnimation();
anim->SetFrom(1.0f);
anim->SetTo(0.0f);
anim->SetDuration(Noesis::Gui::TimeSpan(0, 0, 0, 0, 500));

Noesis::Storyboard::SetTarget(anim.GetPtr(), m_cCanvas);
Noesis::Core::Ptr<Noesis::Gui::PropertyPath> path = *new Noesis::Gui::PropertyPath("Opacity");
Noesis::Storyboard::SetTargetProperty(anim.GetPtr(), path.GetPtr());

Noesis::Core::Ptr<Noesis::Gui::Storyboard> pStoryboard = *new Noesis::Gui::Storyboard();
pStoryboard->GetChildren()->Add(anim.GetPtr());
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Creating a Storyboard using C++

13 Jun 2015, 18:53

Could you please generate a crash dump and attach it here, so we can debug what is happening?
 
darrenc182
Topic Author
Posts: 6
Joined: 23 May 2015, 04:05

Re: Creating a Storyboard using C++

14 Jun 2015, 01:37

How do I generate a crash dump?
 
User avatar
jsantos
Site Admin
Posts: 3925
Joined: 20 Jan 2012, 17:18
Contact:

Re: Creating a Storyboard using C++

15 Jun 2015, 16:14

You can generate a minidump within Visual Studio, on the Debug menu, click Save Dump As. You must do this whenever you get the unhandled exception dialog. Please, file a report and attach the dump there.

Is the error handler you pass to Noesis::GUI::InitDirectX9 being invoked at all? What kind of unhandled exception are you getting? Access violation?

Thanks for your patience.
 
darrenc182
Topic Author
Posts: 6
Joined: 23 May 2015, 04:05

Re: Creating a Storyboard using C++

15 Jun 2015, 18:56

Thanks for getting back to me. I am getting an access violation unhandled exception. I am using OpenGL and the Error Handler is not being called at all. I filed a report and included the dump file.
 
User avatar
jsantos
Site Admin
Posts: 3925
Joined: 20 Jan 2012, 17:18
Contact:

Re: Creating a Storyboard using C++

15 Jun 2015, 20:15

Thanks for the report!

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], jsantos and 44 guests