[SoC 2009 - Accepted] Unified Samples Framework & Browser

Threads related to Google Summer of Code
Post Reply
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by sinbad »

Just one thing too madmarx, I don't think I have a contributor license agreement for you, we'll just need one of those for your changes to go into SVN.

User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1670
Joined: Mon Jan 21, 2008 10:26 pm
x 49

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by madmarx »

@Sinbad
Sorry for the licence agreement, I thought I had already submitted it. I will have a look at it again.

@Omniter
Here is the facial animation sample.
I suppressed 2 poses (compared to the previous sample) in order to make it fit correctly with 640*480.

I am not sure for the top check box. Maybe a menu could be better, or even a button? Anyway I am not sure it is very understandable, because the switching button is maybe not very visible (another color could be great). In the ancient demo, it was possible to 'grey' the slider when they were not available. Is a "hide/show" possible ? Should we destroy and recreate Trays dynamically at each switching?

Concerning the sample, I ran through another error. In the sample I create an Animation on a mesh. If I stop & restart the plugin (or reconfigure), I got an error because the animation already exists. So I wrote the 'cleanupScene' function, but it does not seem to be called at all. What function should I inherit to clean the scene (suppress entities, erase animation, unload the mesh), and stop the error from being called? (of course I could check if the animation already exist, but this postpone only the question to another sample).

FacialAnimation.h

Code: Select all

#ifndef __FACIALANIMATION_H__
#define __FACIALANIMATION_H__
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
    (Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/

Copyright (c) 2000-2006 Torus Knot Software Ltd
Also see acknowledgements in Readme.html

You may use this sample code for anything you like, it is not covered by the
LGPL like the rest of the engine.
-----------------------------------------------------------------------------
*/

/**
    \file 
        FacialAnimation.h
    \brief
        Demonstration of facial animation features, using Pose animation
*/

#include "SdkSample.h"
#include <vector>

using namespace Ogre;
using namespace OgreBites;

class FacialAnimation : public SdkSample
{

private:
	
	AnimationState* mSpeakAnimState;
	AnimationState* mManualAnimState;
	VertexPoseKeyFrame* mManualKeyFrame;
	bool mPlayAnimation;

public:

	FacialAnimation():SdkSample(),
		mSpeakAnimState(NULL),
		mManualAnimState(NULL),
		mManualKeyFrame(NULL),
		mPlayAnimation(false)
	{
		mInfo["Title"] = "Facial Animation";
		mInfo["Description"] = "Demonstration of facial animation features, using Pose animation";
		mInfo["Thumbnail"] = "thumb_FacialAnimation.png";
		mInfo["Category"] = "Animation";
		std::stringstream help;
		help<<"Demonstration of facial animation features, using Pose animation.\n";
		help<<"This is also known as \"blendshape\" in some modeling software,";
		help<<" or \"morpher\" in some other, thougth it is different from Ogre3D morph";
		help<<" animations.\n\n";
		help<<"In this sample, a premade animation is read on the mesh. You can switch";
		help<<" it off, by checking the box at the top, at the left of 'Manual Animation'.";
		help<<" Then, you will gain control over some of the poses of the mesh through the";
		help<<" sliders on the left and the right of the screen.";
		mInfo["Help"] = help.str();
	}

	~FacialAnimation()
	{
		mSpeakAnimState = NULL;
		mManualAnimState = NULL;
		mManualKeyFrame = NULL;
	}

	bool frameRenderingQueued(const FrameEvent& evt)
	{
		if(mPlayAnimation)
		{
			mSpeakAnimState->addTime(evt.timeSinceLastFrame);
		}
		return SdkSample::frameRenderingQueued(evt);  // don't forget the parent class updates!
	}
	void setupScene(void)
	{
		mTrayMgr->showCursor();

		 // Set ambient light
        mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));

        // Create a light
        Light* l = mSceneMgr->createLight("MainLight");
        // Accept default settings: point light, white diffuse, just set position
        // NB I could attach the light to a SceneNode if I wanted it to move automatically with
        //  other objects, but I don't
        l->setPosition(20,80,50);
		l->setDiffuseColour(1.0, 1.0, 1.0);

		// Create a light
		l = mSceneMgr->createLight("MainLight2");
		// Accept default settings: point light, white diffuse, just set position
		// NB I could attach the light to a SceneNode if I wanted it to move automatically with
		//  other objects, but I don't
		l->setPosition(-120,-80,-50);
		l->setDiffuseColour(0.7, 0.7, 0.6);
		
		// at the beginning, animation will be running.
		mPlayAnimation = true;

		// create a selector to enable switching from recorded animation to manual animation.
		mTrayMgr->createLabel(OgreBites::TL_TOP,"Label Animation Type","Kind of Animation");
		OgreBites::CheckBox * lCheckBox = mTrayMgr->createCheckBox(OgreBites::TL_TOP,"selectManual","Manual Animation");
		lCheckBox->setChecked(!mPlayAnimation,false);
		mTrayMgr->createLabel(OgreBites::TL_TOPLEFT,"Label Expression","Expressions");
		mTrayMgr->createLabel(OgreBites::TL_TOPRIGHT,"Label ","Mouth Shapes");

		// Pre-load the mesh so that we can tweak it with a manual animation
		MeshPtr mesh = MeshManager::getSingleton().load("facial.mesh", "Popular");
		Animation* anim = mesh->createAnimation("manual", 0);
		VertexAnimationTrack* track = anim->createVertexTrack(4, VAT_POSE);
		mManualKeyFrame = track->createVertexPoseKeyFrame(0);
		
		Ogre::Mesh::PoseIterator poseIterator = mesh->getPoseIterator();
		// create pose references, initially zero
		uint poseIndex = 1;
		for(;poseIterator.hasMoreElements()&& poseIndex<15;)
		{
			Ogre::Pose* pose = poseIterator.getNext();
			mManualKeyFrame->addPoseReference(poseIndex, 0.0f);

			// creation of sliders for manual tweaking
			String poseName = pose->getName();
			TrayLocation sliderLocation;
			String labelOnSlider;
			int sliderWidth;
			if(poseName.find("Expression")!=std::string::npos)
			{
				labelOnSlider = poseName.substr(11);
				sliderLocation = OgreBites::TL_TOPLEFT;
				sliderWidth = 200;
			}else{
				labelOnSlider = poseName.substr(0,1);
				sliderLocation = OgreBites::TL_TOPRIGHT;
				sliderWidth = 160;
			}
				
			mTrayMgr->createLongSlider(sliderLocation,pose->getName(),labelOnSlider,sliderWidth,80,48,0.0,1.0,101);
			
			++poseIndex;
		}

        Entity* head = mSceneMgr->createEntity("TheFacialHead","facial.mesh");
		
		mSpeakAnimState = head->getAnimationState("Speak");
		mSpeakAnimState->setEnabled(mPlayAnimation);
		mManualAnimState = head->getAnimationState("manual");
		mManualAnimState->setEnabled(!mPlayAnimation);
		mManualAnimState->setTimePosition(0);
        SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
		headNode->attachObject(head);
		SceneNode* topHeadNode = headNode->createChildSceneNode(Ogre::Vector3::UNIT_Y * 40);
	   
		mCameraMan->setStyle(OgreBites::CS_ORBIT);
		mCameraMan->setTarget(topHeadNode);
		mCameraMan->setTargetOffset(Ogre::Radian(0.0),Ogre::Radian(0.0),130);
	}

	void cleanupScene()
	{
		mSceneMgr->clearScene();
		MeshManager& lMeshManager = MeshManager::getSingleton();
		MeshPtr mesh = lMeshManager.getByName("facial.mesh", "Popular");
		if(!mesh.isNull())
		{
			mesh->removeAnimation("manual");
			lMeshManager.unload(mesh->getHandle());
		}
		mSpeakAnimState = NULL;
		mManualAnimState = NULL;
		mManualKeyFrame = NULL;
	}

	void boxChecked(OgreBites::CheckBox * checkBox)
	{
		mPlayAnimation = false;
		mSpeakAnimState->setEnabled(mPlayAnimation);
		mManualAnimState->setEnabled(!mPlayAnimation);
	}
	void boxUnchecked(OgreBites::CheckBox * checkBox)
	{
		mPlayAnimation = true;
		mSpeakAnimState->setEnabled(mPlayAnimation);
		mManualAnimState->setEnabled(!mPlayAnimation);
	}

	void sliderMoved(OgreBites::Slider * slider)
	{
		if(!mPlayAnimation && slider)
		{
			// here is just an example of the use of the poselist.
			Ogre::MeshPtr lMesh = mSceneMgr->getEntity("TheFacialHead")->getMesh();
			const Ogre::PoseList& lPoseList = lMesh->getPoseList();
			bool found = false;
			for(unsigned short i = 0; !found && i<lPoseList.size(); ++i)
			{
				if(lPoseList[i]->getName() == slider->getName())
				{
					mManualKeyFrame->updatePoseReference(i, slider->getValue());
					// Dirty animation state since we're fudging this manually
					mManualAnimState->getParent()->_notifyDirty();
					found = true;
				}
			}
		}
	}
};

#endif
and the FacialAnimation.cpp

Code: Select all

/*
-----------------------------------------------------------------------------
This source file is part of OGRE
    (Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/

Copyright (c) 2000-2006 Torus Knot Software Ltd
Also see acknowledgements in Readme.html

You may use this sample code for anything you like, it is not covered by the
LGPL like the rest of the engine.
-----------------------------------------------------------------------------
*/
#include "SamplePlugin.h"
#include "FacialAnimation.h"

using namespace Ogre;
using namespace OgreBites;

SamplePlugin* gsp;
Sample* gs;

extern "C" __declspec(dllexport) void dllStartPlugin()
{
	gs = new FacialAnimation;
	gsp = OGRE_NEW SamplePlugin(gs->getInfo()["Title"] + " Sample");
	gsp->addSample(gs);
	Root::getSingleton().installPlugin(gsp);
}

extern "C" __declspec(dllexport) void dllStopPlugin()
{
	Root::getSingleton().uninstallPlugin(gsp); 
	OGRE_DELETE gsp;
	delete gs;
	gs = NULL;
}
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0

User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by omniter »

Once again, madmarx, I regret to say that I do not experience the same problem here. I tried your sample, and it works fine. The cleanupScene method is called. Also, a reconfiguration in essence destroys and recreates everything, so there should be nothing "left behind" at all. Are you sure you're working with the right binaries? Also, make sure your drivers are up to date.

Don't worry too much about the widget layout. As long as it works, we could easily move stuff around later. I'll figure something out for it. You've done a good conversion.

To show/hide a widget, usually it's faster to destroy/recreate it. But you can also do this:

Code: Select all

// to hide a widget...
mTrayMgr->removeWidgetFromTray(myWidget);
myWidget->hide();
// to show it again...
mTrayMgr->moveWidgetToTray(myWidget, TL_TOP);
myWidget->show();
If you ONLY remove the widget from a tray, it gets moved to TL_NONE, which allows you to manually position the widget. This makes sure the widget doesn't occupy a space in a tray, but it doesn't actually hide the widget. If you ONLY hide the widget, it won't show up, but it will still use up an empty space in a tray. So to achieve the effect you want, you gotta do both. Hope this helps.

One more thing: boxChecked and boxUnchecked have been replaced with checkBoxToggled. You can use CheckBox::isChecked to see if the see the box's state.

User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1670
Joined: Mon Jan 21, 2008 10:26 pm
x 49

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by madmarx »

Ok, thanks. You were right, the latest svn solved the issues.
I have also updated my licence agreement.

On a side note, I lost 2 times my changes because in vs2008, when I clean/generate a sample I got :"1>Building Custom Rule C:/MonOrdinateur/Programmation/Ogre/Soc2009/Samples/SkeletalAnimation/CMakeLists.txt", and then Cmake erase/replace my resources files with an old config :cry: . Ok nothing tragic, but this is one thing that could be done better next time you work with someone ^^. So the cmake files are not up to date, but in that case, I would like to know how to stop the Cmake script to erase my things each time I regenerate a plugin :wink: ?

Anyway, here is the code for the facial animation with 'hideable' Widgets.
facialAnimation.h

Code: Select all

#ifndef __FACIALANIMATION_H__
#define __FACIALANIMATION_H__
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
    (Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/

Copyright (c) 2000-2009 Torus Knot Software Ltd
Also see acknowledgements in Readme.html

You may use this sample code for anything you like, it is not covered by the
LGPL like the rest of the engine.
-----------------------------------------------------------------------------
*/

/**
    \file 
        FacialAnimation.h
    \brief
        Demonstration of facial animation features, using Pose animation
*/

#include "SdkSample.h"
#include <vector>

using namespace Ogre;
using namespace OgreBites;


class FacialAnimationSample : public SdkSample
{

private:
	AnimationState* mSpeakAnimState;
	AnimationState* mManualAnimState;
	VertexPoseKeyFrame* mManualKeyFrame;

	// just create a little struct that will allow to show/hide widgets
	class WidgetAndPosition
	{
	private:
		Widget* mWidget;
		TrayLocation mLocation;
	public:
		// constructor (for implicit conversion)
		WidgetAndPosition(Widget* pWidget):mWidget(pWidget),mLocation()
		{
			if(pWidget) mLocation = pWidget->getTrayLocation();
		}

		// default constructor
		WidgetAndPosition():mWidget(NULL),mLocation(){}
		
		// destructor
		~WidgetAndPosition(){mWidget = NULL;}
		
		// operator = 
		WidgetAndPosition& operator=(const WidgetAndPosition& pOther)
		{
			if(this!=&pOther)
			{
				mWidget = pOther.mWidget;
				mLocation = pOther.mLocation;
			}
			return *this;
		}

		// copy constructor
		WidgetAndPosition(const WidgetAndPosition& pOther):
			mWidget(pOther.mWidget),mLocation(pOther.mLocation){}

		// show the widget
		void show(OgreBites::SdkTrayManager * lManager)
		{
			lManager->moveWidgetToTray(mWidget,mLocation);
			mWidget->show();
		}
		// hide the widget
		void hide(OgreBites::SdkTrayManager * lManager)
		{
			mWidget->hide();
			lManager->removeWidgetFromTray(mWidget);
		}
	};

	typedef std::vector<WidgetAndPosition> Widgets;
	Widgets mSwitchableWidgets;
	bool mPlayAnimation;

public:

	FacialAnimationSample():SdkSample(),
		mSpeakAnimState(NULL),
		mManualAnimState(NULL),
		mManualKeyFrame(NULL),
		mPlayAnimation(false),
		mSwitchableWidgets()
	{
		mInfo["Title"] = "Facial Animation";
		mInfo["Description"] = "Demonstration of facial animation features, using Pose animation";
		mInfo["Thumbnail"] = "thumb_FacialAnimation.png";
		mInfo["Category"] = "Animation";
		std::stringstream help;
		help<<"Demonstration of facial animation features, using Pose animation.\n";
		help<<"This is also known as \"blendshape\" in some modeling software,";
		help<<" or \"morpher\" in some other, thougth it is different from Ogre3D morph";
		help<<" animations.\n\n";
		help<<"In this sample, a premade animation is read on the mesh. You can switch";
		help<<" it off, by checking the box at the top, at the left of 'Manual Animation'.";
		help<<" Then, you will gain control over some of the poses of the mesh through the";
		help<<" sliders on the left and the right of the screen.";
		mInfo["Help"] = help.str();
	}

	~FacialAnimationSample()
	{
		mSpeakAnimState = NULL;
		mManualAnimState = NULL;
		mManualKeyFrame = NULL;
	}

	bool frameRenderingQueued(const FrameEvent& evt)
	{
		if(mPlayAnimation)
		{
			mSpeakAnimState->addTime(evt.timeSinceLastFrame);
		}
		return SdkSample::frameRenderingQueued(evt);  // don't forget the parent class updates!
	}
	void setupScene(void)
	{
		mTrayMgr->showCursor();

		 // Set ambient light
        mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));

        // Create a light
        Light* l = mSceneMgr->createLight("MainLight");
        // Accept default settings: point light, white diffuse, just set position
        // NB I could attach the light to a SceneNode if I wanted it to move automatically with
        //  other objects, but I don't
        l->setPosition(20,80,50);
		l->setDiffuseColour(1.0, 1.0, 1.0);

		// Create a light
		l = mSceneMgr->createLight("MainLight2");
		// Accept default settings: point light, white diffuse, just set position
		l->setPosition(-120,-80,-50);
		l->setDiffuseColour(0.7, 0.7, 0.6);
		
		// at the beginning, animation will be running.
		mPlayAnimation = true;

		// create a selector to enable switching from recorded animation to manual animation.
		mTrayMgr->createLabel(OgreBites::TL_TOP,"Label Animation Type","Kind of Animation");
		OgreBites::CheckBox * lCheckBox = mTrayMgr->createCheckBox(OgreBites::TL_TOP,"selectManual","Manual Animation");
		lCheckBox->setChecked(!mPlayAnimation,false);
		
		OgreBites::Label * lblExpressions = mTrayMgr->createLabel(OgreBites::TL_TOPLEFT,"Label Expression","Expressions");
		mSwitchableWidgets.push_back(lblExpressions);
		OgreBites::Label * lblMouthShapes = mTrayMgr->createLabel(OgreBites::TL_TOPRIGHT,"Label ","Mouth Shapes");
		mSwitchableWidgets.push_back(lblMouthShapes);

		// Pre-load the mesh so that we can tweak it with a manual animation
		MeshPtr mesh = MeshManager::getSingleton().load("facial.mesh", "Popular");
		Animation* anim = mesh->createAnimation("manual", 0);
		VertexAnimationTrack* track = anim->createVertexTrack(4, VAT_POSE);
		mManualKeyFrame = track->createVertexPoseKeyFrame(0);
		
		Ogre::Mesh::PoseIterator poseIterator = mesh->getPoseIterator();
		// create pose references, initially zero
		uint poseIndex = 1;
		for(;poseIterator.hasMoreElements()&& poseIndex<15;)
		{
			Ogre::Pose* pose = poseIterator.getNext();
			mManualKeyFrame->addPoseReference(poseIndex, 0.0f);

			// creation of sliders for manual tweaking
			String poseName = pose->getName();
			TrayLocation sliderLocation;
			String labelOnSlider;
			int sliderWidth;
			if(poseName.find("Expression")!=std::string::npos)
			{
				labelOnSlider = poseName.substr(11);
				sliderLocation = OgreBites::TL_TOPLEFT;
				sliderWidth = 200;
			}else{
				labelOnSlider = poseName.substr(0,1);
				sliderLocation = OgreBites::TL_TOPRIGHT;
				sliderWidth = 160;
			}
				
			Widget* lSlider = mTrayMgr->createLongSlider(sliderLocation,pose->getName(),labelOnSlider,sliderWidth,80,48,0.0,1.0,101);
			mSwitchableWidgets.push_back(lSlider);
			
			++poseIndex;
		}

        Entity* head = mSceneMgr->createEntity("TheFacialHead","facial.mesh");
		
		mSpeakAnimState = head->getAnimationState("Speak");
		mSpeakAnimState->setEnabled(mPlayAnimation);
		mManualAnimState = head->getAnimationState("manual");
		mManualAnimState->setEnabled(!mPlayAnimation);
		mManualAnimState->setTimePosition(0);
        SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
		headNode->attachObject(head);
		SceneNode* topHeadNode = headNode->createChildSceneNode(Ogre::Vector3::UNIT_Y * 40);
	   
		mCameraMan->setStyle(OgreBites::CS_ORBIT);
		mCameraMan->setTarget(topHeadNode);
		mCameraMan->setTargetOffset(Ogre::Radian(0.0),Ogre::Radian(0.0),130);

		// hide the widgets.
		setWidgetVisibility(false);
	}

	void setWidgetVisibility(bool pVisible)
	{
		Widgets::iterator lIterWidgets = mSwitchableWidgets.begin();
		Widgets::iterator lIterWidgetsEnd = mSwitchableWidgets.end();
		for(;lIterWidgets!=lIterWidgetsEnd;++lIterWidgets)
		{
			WidgetAndPosition & lWidget = (*lIterWidgets);
			if(pVisible)
			{
				lWidget.show(mTrayMgr);
			}
			else
			{
				lWidget.hide(mTrayMgr);
			}
		}
	}
	void cleanupScene()
	{
		mSwitchableWidgets.clear();
		mSceneMgr->clearScene();
		MeshManager& lMeshManager = MeshManager::getSingleton();
		MeshPtr mesh = lMeshManager.getByName("facial.mesh", "Popular");
		if(!mesh.isNull())
		{
			mesh->removeAnimation("manual");
			lMeshManager.unload(mesh->getHandle());
		}
		mSpeakAnimState = NULL;
		mManualAnimState = NULL;
		mManualKeyFrame = NULL;
	}
	void checkBoxToggled(OgreBites::CheckBox * checkBox)
	{
		mPlayAnimation = !checkBox->isChecked();
		mSpeakAnimState->setEnabled(mPlayAnimation);
		mManualAnimState->setEnabled(!mPlayAnimation);
		setWidgetVisibility(!mPlayAnimation);
	}

	void sliderMoved(OgreBites::Slider * slider)
	{
		if(!mPlayAnimation && slider)
		{
			// here is just an example of the use of the poselist.
			Ogre::MeshPtr lMesh = mSceneMgr->getEntity("TheFacialHead")->getMesh();
			const Ogre::PoseList& lPoseList = lMesh->getPoseList();
			bool found = false;
			for(unsigned short i = 0; !found && i<lPoseList.size(); ++i)
			{
				if(lPoseList[i]->getName() == slider->getName())
				{
					mManualKeyFrame->updatePoseReference(i, slider->getValue());
					// Dirty animation state since we're fudging this manually
					mManualAnimState->getParent()->_notifyDirty();
					found = true;
				}
			}
		}
	}
};

#endif

facialanimation.cpp (updated too, since I changed the name of the class to make it fit yours).

Code: Select all

/*
-----------------------------------------------------------------------------
This source file is part of OGRE
    (Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/

Copyright (c) 2000-2009 Torus Knot Software Ltd
Also see acknowledgements in Readme.html

You may use this sample code for anything you like, it is not covered by the
LGPL like the rest of the engine.
-----------------------------------------------------------------------------
*/
#include "SamplePlugin.h"
#include "FacialAnimation.h"

using namespace Ogre;
using namespace OgreBites;

SamplePlugin* gsp;
Sample* gs;

extern "C" __declspec(dllexport) void dllStartPlugin()
{
	gs = new FacialAnimationSample;
	gsp = OGRE_NEW SamplePlugin(gs->getInfo()["Title"] + " Sample");
	gsp->addSample(gs);
	Root::getSingleton().installPlugin(gsp);
}

extern "C" __declspec(dllexport) void dllStopPlugin()
{
	Root::getSingleton().uninstallPlugin(gsp); 
	OGRE_DELETE gsp;
	delete gs;
	gs = NULL;
}
And for Skeletal animation, also update for position of camera + remove some tests.
The cpp:

Code: Select all

/*
-----------------------------------------------------------------------------
This source file is part of OGRE
    (Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/

Copyright (c) 2000-2009 Torus Knot Software Ltd
Also see acknowledgements in Readme.html

You may use this sample code for anything you like, it is not covered by the
LGPL like the rest of the engine.
-----------------------------------------------------------------------------
*/

#include "SamplePlugin.h"
#include "SkeletalAnimation.h"

using namespace Ogre;
using namespace OgreBites;

SamplePlugin* gsp;
Sample* gs;

extern "C" __declspec(dllexport) void dllStartPlugin()
{
	gs = new SkeletalAnimationSample;
	gsp = OGRE_NEW SamplePlugin(gs->getInfo()["Title"] + " Sample");
	gsp->addSample(gs);
	Root::getSingleton().installPlugin(gsp);
}

extern "C" __declspec(dllexport) void dllStopPlugin()
{
	Root::getSingleton().uninstallPlugin(gsp); 
	OGRE_DELETE gsp;
	delete gs;
	gs = NULL;
}

the .h:

Code: Select all

/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/

Copyright (c) 2000-2009 Torus Knot Software Ltd
Also see acknowledgements in Readme.html

You may use this sample code for anything you like, it is not covered by the
LGPL like the rest of the engine.
-----------------------------------------------------------------------------
*/
/*
-----------------------------------------------------------------------------
Filename:    SkeletalAnimation.h
Description: a demonstration plugin to show the skeletal animation feature, 
including spline animation.
-----------------------------------------------------------------------------
*/

#ifndef __SKELETALANIMATION_H__
#define __SKELETALANIMATION_H__

#include "SdkSample.h"
#include <vector>

using namespace Ogre;
using namespace OgreBites;

class SkeletalAnimationSample : public SdkSample
{
public:

	typedef std::vector<AnimationState*> AnimationStateList;
	typedef std::vector<Vector3> Vector3List;
	typedef std::vector<Quaternion> QuaternionList;
	typedef std::vector<Ogre::Real> RealList;
	typedef std::vector<Ogre::SceneNode*> SceneNodeList;

	SkeletalAnimationSample():SdkSample(),
		mPeopleNumber(6),
		mAnimState(mPeopleNumber,NULL),
		mAnimationSpeed(mPeopleNumber),
		mSneakStartOffset(),
		mSneakEndOffset(),
		mOrientations(mPeopleNumber),
		mBasePositions(mPeopleNumber),
		mSceneNode(mPeopleNumber),
		mAnimationRotation(-60.0f),
		mAnimChop(7.96666f),
		mAnimChopBlend(0.3f)
	{
		mInfo["Title"] = "Skeletal Animation";
		mInfo["Description"] = "A demo of the skeletal animation feature, including spline animation and also hardware skinning if available.";
		mInfo["Thumbnail"] = "thumb_SkeletalAnimation.png";
		mInfo["Category"] = "Animation";
		mInfo["Help"] = "A demo of the skeletal animation feature, including spline animation and also hardware skinning if available.";
	}

	bool frameRenderingQueued(const FrameEvent& evt)
	{
		for (int i = 0; i < mPeopleNumber; ++i)
		{
			Real inc = evt.timeSinceLastFrame * mAnimationSpeed[i];
			if ((mAnimState[i]->getTimePosition() + inc) >= mAnimChop)
			{
				// Loop
				// Need to reposition the scene node origin since animation includes translation
				// Calculate as an offset to the end position, rotated by the
				// amount the animation turns the character
				Quaternion rot(mAnimationRotation, Vector3::UNIT_Y);
				Vector3 startoffset = mSceneNode[i]->getOrientation() * -mSneakStartOffset;
				Vector3 endoffset = mSneakEndOffset;
				Vector3 offset = rot * startoffset;
				Vector3 currEnd = mSceneNode[i]->getOrientation() * endoffset + mSceneNode[i]->getPosition();
				mSceneNode[i]->setPosition(currEnd + offset);
				mSceneNode[i]->rotate(rot);

				mAnimState[i]->setTimePosition((mAnimState[i]->getTimePosition() + inc) - mAnimChop);
			}
			else
			{
				mAnimState[i]->addTime(inc);
			}
		}
		return SdkSample::frameRenderingQueued(evt);  // don't forget the parent class updates!
	}

	void setupScene(void)
	{
		mCameraMan->setStyle(OgreBites::CS_FREELOOK);
		mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE);
		mSceneMgr->setShadowTextureSize(512);
		mSceneMgr->setShadowColour(ColourValue(0.6, 0.6, 0.6));

		// Setup animation default
		Animation::setDefaultInterpolationMode(Animation::IM_LINEAR);
		Animation::setDefaultRotationInterpolationMode(Animation::RIM_LINEAR);

		// Set ambient light
		mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));

		// The jaiqua sneak animation doesn't loop properly, so lets hack it so it does
		// We want to copy the initial keyframes of all bones, but alter the Spineroot
		// to give it an offset of where the animation ends
		SkeletonPtr skel = SkeletonManager::getSingleton().load("jaiqua.skeleton", "Popular");
		Animation* anim = skel->getAnimation("Sneak");
		Animation::NodeTrackIterator trackIter = anim->getNodeTrackIterator();
		while (trackIter.hasMoreElements())
		{
			NodeAnimationTrack* track = trackIter.getNext();

			TransformKeyFrame oldKf(0, 0);
			track->getInterpolatedKeyFrame(mAnimChop, &oldKf);

			// Drop all keyframes after the chop
			while (track->getKeyFrame(track->getNumKeyFrames()-1)->getTime() >= mAnimChop - mAnimChopBlend)
				track->removeKeyFrame(track->getNumKeyFrames()-1);

			TransformKeyFrame* newKf = track->createNodeKeyFrame(mAnimChop);
			TransformKeyFrame* startKf = track->getNodeKeyFrame(0);

			Bone* bone = skel->getBone(track->getHandle());
			// "Spineroot" is not the real root of the skeleton in the scene
			if (bone->getName() == "Spineroot")
			{
				mSneakStartOffset = startKf->getTranslate() + bone->getInitialPosition();
				mSneakEndOffset = oldKf.getTranslate() + bone->getInitialPosition();
				mSneakStartOffset.y = mSneakEndOffset.y;
				// Adjust spine root relative to new location
				newKf->setRotation(oldKf.getRotation());
				newKf->setTranslate(oldKf.getTranslate());
				newKf->setScale(oldKf.getScale());
			}
			else
			{
				newKf->setRotation(startKf->getRotation());
				newKf->setTranslate(startKf->getTranslate());
				newKf->setScale(startKf->getScale());
			}
		}

		Real rotInc = Math::TWO_PI / (float)mPeopleNumber;
		Real rot = 0.0f;
		Entity *lEntity = NULL;

		for (int i = 0; i < mPeopleNumber; ++i)
		{
			Quaternion q;
			q.FromAngleAxis(Radian(rot), Vector3::UNIT_Y);

			mOrientations[i] = q;
			mBasePositions[i] = q * Vector3(0,0,-20);

			Entity *ent = mSceneMgr->createEntity("jaiqua" + StringConverter::toString(i), "jaiqua.mesh");
			// Add entity to the scene node
			SceneNode* lSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
			mSceneNode[i] = lSceneNode;
			lSceneNode->attachObject(ent);
			lSceneNode->rotate(q);
			lSceneNode->translate(mBasePositions[i]);

			AnimationState * lAnimationState = ent->getAnimationState("Sneak");
			mAnimState[i] = lAnimationState;
			lAnimationState->setEnabled(true);
			lAnimationState->setLoop(false); // manual loop since translation involved
			mAnimationSpeed[i] = Math::RangeRandom(0.5, 1.5);

			// the first entity will be used later, out of the loop
			if(i==0)
			{
				lEntity = ent;
			}
			rot += rotInc;
		}

		// Report whether hardware skinning is enabled or not
		if(lEntity!=NULL)
		{
			MaterialPtr material = lEntity->getSubEntity(0)->getMaterial();
			material->load();
			Technique * t = material->getBestTechnique();
			if(t!=NULL)
			{
				Pass* p = t->getPass(0);
				Ogre::String skinningInfos;
				if (p->hasVertexProgram() && p->getVertexProgram()->isSkeletalAnimationIncluded())
					skinningInfos = "Hardware skinning is enabled";
				else
					skinningInfos = "Software skinning is enabled";
				mTrayMgr->createLabel(OgreBites::TL_TOP,"information label",skinningInfos,300);
			}
		}

		// Give it a little ambience with lights
		Light* l;
		l = mSceneMgr->createLight("BlueLight");
		l->setType(Light::LT_SPOTLIGHT);
		l->setPosition(-200,150,-100);
		Vector3 dir(-l->getPosition());
		dir.normalise();
		l->setDirection(dir);
		l->setDiffuseColour(0.5, 0.5, 1.0);

		l = mSceneMgr->createLight("GreenLight");
		l->setType(Light::LT_SPOTLIGHT);
		l->setPosition(0,150,-100);
		dir = -l->getPosition();
		dir.normalise();
		l->setDirection(dir);
		l->setDiffuseColour(0.5, 1.0, 0.5);

		// Position the camera
		mCamera->setPosition(100,20,0);
		mCamera->yaw(Ogre::Radian(Ogre::Math::PI*0.5));

		Plane plane;
		plane.normal = Vector3::UNIT_Y;
		plane.d = 100;
		MeshManager::getSingleton().createPlane("Myplane",
			"Popular", plane,
			1500,1500,20,20,true,1,60,60,Vector3::UNIT_Z);
		Entity* pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" );
		pPlaneEnt->setMaterialName("Examples/Rockwall");
		pPlaneEnt->setCastShadows(false);
		mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(0,99,0))->attachObject(pPlaneEnt);
	}

private:
	// attributes
	int mPeopleNumber;				// number of meshes 'jaiqua'
	AnimationStateList mAnimState;
	RealList mAnimationSpeed;
	Vector3 mSneakStartOffset;
	Vector3 mSneakEndOffset;

	QuaternionList mOrientations;
	Vector3List mBasePositions;
	SceneNodeList mSceneNode;
	Degree mAnimationRotation;
	Real mAnimChop;
	Real mAnimChopBlend;
};
#endif
Ok so that's all. I hope it will fit your needs omniter. I will keep reading this thread anyway (to understand cmake :lol: ).
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0

User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by omniter »

Thanks, madmarx. You've been a great help. :) Unfortunately, I'm not at all familiar with cmake, so I can't really help you there. There are definitely changes to be made to the cmake scripts. I'm gonna need to pick up the pace now (haven't had much time to work this week). Thanks again!

CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 57
Contact:

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by CABAListic »

Well, if you want me to work on the CMake integration, just say the word. It's part of my job, anyway :)

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by sinbad »

CMake is super-easy if you're just copying & pasting from other projects to set up a new one. The sample plugins make it a bit more complicated but it shouldn't be that bad. Probably best to start doing this now rather than fighting with manual hacks.

I've added the base browser to CMake to get you started but you'll effectively need a new project for each of the sample plugins too - they'll look much the same as the other Ogre plugins though so it'll be mostly a copy/paste job.

[edit].. or just let CABAListic do it, he's the expert anyway ;)

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by Assaf Raman »

Can you explain the steps needed in order to compile your branch? If the cmake is broken – how can I compile the project?
Watch out for my OGRE related tweets here.

User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by omniter »

Hey Assaf Raman,

I'm not sure about other platforms, but on Windows, it's quite simple: There's basically two parts to build - the browser, and the samples. All of these require "Samples/Common/include" as an include directory, and OgreMain.lib and OIS.lib must be linked.
  • The code for the browser is in "Samples/Browser/src" and "Samples/Browser/include". Compile the browser to an exe.
  • The code for each sample X is "Samples/X/src" and "Samples/X/include". Compile each sample to a dll.
  • The final output directory needs everything that is inside "Samples/Common/bin/Release" or "Samples/Common/bin/Debug", in addition to the usual dlls (OgreMain.dll, RenderSystem_Direct3D9.dll, etc.). You won't need the CEGUI dlls anymore though.
  • Put your browser exe into this directory, and put all your sample dlls into the "samples" folder. Make sure the media folder is in the same location as specified in resources.cfg, run the browser, and you're good to go. When you run the browser for the first time, there will be a config dialog.
In short, it's pretty much exactly the same as building the old framework with the exception of having a browser, the samples being dlls instead of exes, and putting samples inside the "samples" folder.

CABAListic, I hate to trouble you, but it would be great if you could work on the CMake integration. Thanks!

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by Assaf Raman »

Can you post the visual studio proj file for the project you are using?
Watch out for my OGRE related tweets here.

CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 57
Contact:

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by CABAListic »

Can you post versions of the config files necessary to get the Browser running? I could probably work it out (or even find something in this thread), but it's probably quicker if you could just post them. :) Specifically, I think I need resources.cfg and samples.cfg.

User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by omniter »

Assaf Raman, here's the vcproj for the sample browser:

Code: Select all

<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
	ProjectType="Visual C++"
	Version="9.00"
	Name="SampleBrowser"
	ProjectGUID="{E84F4924-781A-45AB-9D7C-8C67CE17BD4D}"
	Keyword="Win32Proj"
	TargetFrameworkVersion="196613"
	>
	<Platforms>
		<Platform
			Name="Win32"
		/>
	</Platforms>
	<ToolFiles>
	</ToolFiles>
	<Configurations>
		<Configuration
			Name="Debug|Win32"
			OutputDirectory="bin\$(ConfigurationName)"
			IntermediateDirectory="intermediate"
			ConfigurationType="1"
			CharacterSet="1"
			>
			<Tool
				Name="VCPreBuildEventTool"
			/>
			<Tool
				Name="VCCustomBuildTool"
			/>
			<Tool
				Name="VCXMLDataGeneratorTool"
			/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"
			/>
			<Tool
				Name="VCMIDLTool"
			/>
			<Tool
				Name="VCCLCompilerTool"
				Optimization="0"
				AdditionalIncludeDirectories="include"
				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
				MinimalRebuild="true"
				BasicRuntimeChecks="3"
				RuntimeLibrary="3"
				UsePrecompiledHeader="0"
				WarningLevel="3"
				DebugInformationFormat="4"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
			/>
			<Tool
				Name="VCPreLinkEventTool"
			/>
			<Tool
				Name="VCLinkerTool"
				AdditionalDependencies="OgreMain_d.lib OIS_d.lib"
				LinkIncremental="2"
				GenerateDebugInformation="true"
				SubSystem="2"
				TargetMachine="1"
			/>
			<Tool
				Name="VCALinkTool"
			/>
			<Tool
				Name="VCManifestTool"
			/>
			<Tool
				Name="VCXDCMakeTool"
			/>
			<Tool
				Name="VCBscMakeTool"
			/>
			<Tool
				Name="VCFxCopTool"
			/>
			<Tool
				Name="VCAppVerifierTool"
			/>
			<Tool
				Name="VCPostBuildEventTool"
			/>
		</Configuration>
		<Configuration
			Name="Release|Win32"
			OutputDirectory="bin\$(ConfigurationName)"
			IntermediateDirectory="intermediate"
			ConfigurationType="1"
			CharacterSet="1"
			WholeProgramOptimization="1"
			>
			<Tool
				Name="VCPreBuildEventTool"
			/>
			<Tool
				Name="VCCustomBuildTool"
			/>
			<Tool
				Name="VCXMLDataGeneratorTool"
			/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"
			/>
			<Tool
				Name="VCMIDLTool"
			/>
			<Tool
				Name="VCCLCompilerTool"
				Optimization="2"
				EnableIntrinsicFunctions="true"
				AdditionalIncludeDirectories="include"
				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
				RuntimeLibrary="2"
				EnableFunctionLevelLinking="true"
				UsePrecompiledHeader="0"
				WarningLevel="3"
				DebugInformationFormat="3"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
			/>
			<Tool
				Name="VCPreLinkEventTool"
			/>
			<Tool
				Name="VCLinkerTool"
				AdditionalDependencies="OgreMain.lib OIS.lib"
				LinkIncremental="1"
				GenerateDebugInformation="true"
				SubSystem="2"
				OptimizeReferences="2"
				EnableCOMDATFolding="2"
				TargetMachine="1"
			/>
			<Tool
				Name="VCALinkTool"
			/>
			<Tool
				Name="VCManifestTool"
			/>
			<Tool
				Name="VCXDCMakeTool"
			/>
			<Tool
				Name="VCBscMakeTool"
			/>
			<Tool
				Name="VCFxCopTool"
			/>
			<Tool
				Name="VCAppVerifierTool"
			/>
			<Tool
				Name="VCPostBuildEventTool"
			/>
		</Configuration>
	</Configurations>
	<References>
	</References>
	<Files>
		<Filter
			Name="Source Files"
			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
			>
			<File
				RelativePath="src\SampleBrowser.cpp"
				>
			</File>
		</Filter>
		<Filter
			Name="Header Files"
			Filter="h;hpp;hxx;hm;inl;inc;xsd"
			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
			>
			<File
				RelativePath="include\SampleBrowser.h"
				>
			</File>
		</Filter>
		<Filter
			Name="Resource Files"
			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
			>
		</Filter>
	</Files>
	<Globals>
	</Globals>
</VisualStudioProject>
Here's the vcproj file for the CelShading sample:

Code: Select all

<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
	ProjectType="Visual C++"
	Version="9.00"
	Name="Sample_CelShading"
	ProjectGUID="{0C87F161-F1FB-4D78-A056-E036CBEADF88}"
	Keyword="Win32Proj"
	TargetFrameworkVersion="196613"
	>
	<Platforms>
		<Platform
			Name="Win32"
		/>
	</Platforms>
	<ToolFiles>
	</ToolFiles>
	<Configurations>
		<Configuration
			Name="Debug|Win32"
			OutputDirectory="..\Browser\bin\$(ConfigurationName)\samples"
			IntermediateDirectory="intermediate"
			ConfigurationType="2"
			CharacterSet="1"
			>
			<Tool
				Name="VCPreBuildEventTool"
			/>
			<Tool
				Name="VCCustomBuildTool"
			/>
			<Tool
				Name="VCXMLDataGeneratorTool"
			/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"
			/>
			<Tool
				Name="VCMIDLTool"
			/>
			<Tool
				Name="VCCLCompilerTool"
				Optimization="0"
				AdditionalIncludeDirectories="include"
				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TEST1_EXPORTS"
				MinimalRebuild="true"
				BasicRuntimeChecks="3"
				RuntimeLibrary="3"
				UsePrecompiledHeader="0"
				WarningLevel="3"
				DebugInformationFormat="4"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
			/>
			<Tool
				Name="VCPreLinkEventTool"
			/>
			<Tool
				Name="VCLinkerTool"
				AdditionalDependencies="OgreMain_d.lib OIS_d.lib"
				LinkIncremental="2"
				GenerateDebugInformation="true"
				SubSystem="2"
				ImportLibrary="lib\$(ProjectName).lib"
				TargetMachine="1"
			/>
			<Tool
				Name="VCALinkTool"
			/>
			<Tool
				Name="VCManifestTool"
			/>
			<Tool
				Name="VCXDCMakeTool"
			/>
			<Tool
				Name="VCBscMakeTool"
			/>
			<Tool
				Name="VCFxCopTool"
			/>
			<Tool
				Name="VCAppVerifierTool"
			/>
			<Tool
				Name="VCPostBuildEventTool"
			/>
		</Configuration>
		<Configuration
			Name="Release|Win32"
			OutputDirectory="..\Browser\bin\$(ConfigurationName)\samples"
			IntermediateDirectory="intermediate"
			ConfigurationType="2"
			CharacterSet="1"
			WholeProgramOptimization="1"
			>
			<Tool
				Name="VCPreBuildEventTool"
			/>
			<Tool
				Name="VCCustomBuildTool"
			/>
			<Tool
				Name="VCXMLDataGeneratorTool"
			/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"
			/>
			<Tool
				Name="VCMIDLTool"
			/>
			<Tool
				Name="VCCLCompilerTool"
				Optimization="2"
				EnableIntrinsicFunctions="true"
				AdditionalIncludeDirectories="include"
				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;TEST1_EXPORTS"
				RuntimeLibrary="2"
				EnableFunctionLevelLinking="true"
				UsePrecompiledHeader="0"
				WarningLevel="3"
				DebugInformationFormat="3"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
			/>
			<Tool
				Name="VCPreLinkEventTool"
			/>
			<Tool
				Name="VCLinkerTool"
				AdditionalDependencies="OgreMain.lib OIS.lib"
				LinkIncremental="1"
				GenerateDebugInformation="false"
				SubSystem="2"
				OptimizeReferences="2"
				EnableCOMDATFolding="2"
				ImportLibrary="lib\$(ProjectName).lib"
				TargetMachine="1"
			/>
			<Tool
				Name="VCALinkTool"
			/>
			<Tool
				Name="VCManifestTool"
			/>
			<Tool
				Name="VCXDCMakeTool"
			/>
			<Tool
				Name="VCBscMakeTool"
			/>
			<Tool
				Name="VCFxCopTool"
			/>
			<Tool
				Name="VCAppVerifierTool"
			/>
			<Tool
				Name="VCPostBuildEventTool"
			/>
		</Configuration>
	</Configurations>
	<References>
	</References>
	<Files>
		<Filter
			Name="Source Files"
			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
			>
			<File
				RelativePath="src\CelShading.cpp"
				>
			</File>
		</Filter>
		<Filter
			Name="Header Files"
			Filter="h;hpp;hxx;hm;inl;inc;xsd"
			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
			>
			<File
				RelativePath="include\CelShading.h"
				>
			</File>
		</Filter>
		<Filter
			Name="Resource Files"
			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
			>
		</Filter>
	</Files>
	<Globals>
	</Globals>
</VisualStudioProject>
All paths below are relative to the branch directory.

I put my vcproj files under the "Samples/SampleBrowser", "Samples/CelShading" folders in my branch as unversioned files. My Visual Studio has "OgreMain/include", "dependencies/include", and "Samples/Common/include" as global include directories. It also has "lib/Release", "lib/Debug", "dependencies/lib/Release", and "dependencies/lib/Debug" as global library directories.

CABAListic, the files you are looking for are under "Samples/Common/bin/Release" and "Samples/Common/bin/Debug".

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by Assaf Raman »

Thanks!
Watch out for my OGRE related tweets here.

User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1670
Joined: Mon Jan 21, 2008 10:26 pm
x 49

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by madmarx »

Concerning Cmake, I had done a first Cmake conversion (see page 6 of this thread). The problem then is that I don't know were (in both Cmake and Visual Studio) are generated the ressources.cfg files (because I never suspected it to be generated by CMAKE / visual studio).
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by jacmoe »

madmarx:
In Cthugha/CMake/Templates there are resources.cfg.in and resources_d.cfg.in - so, yes: it's generated by the CMake script.
Cthugha/CMake/InstallResources.cmake configures the files, like this:

Code: Select all

  configure_file(${OGRE_TEMPLATES_DIR}/resources${OGRE_CFG_SUFFIX}.cfg.in ${OGRE_BINARY_DIR}/bin/resources.cfg)
So, look there. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
xadhoom
Minaton
Posts: 973
Joined: Fri Dec 28, 2007 4:35 pm
Location: Germany
x 1

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by xadhoom »

Hi Omniter!

I compiled the SampleBrowser and CelShading sample as you described and put everything in the right folder.
Starting the SampleBrowser without ny sample works without problems (tested in Debug). But after adding the CelShading Sample (only) the SampleBrowser crashes with a MinMax assertion in OgreMath.h:

Code: Select all

		template <typename T>
		static T Clamp(T val, T minval, T maxval)             // << all values are 1 !
		{
			assert (minval < maxval && "Invalid clamp range"); // << this assertion hits
			return std::max(std::min(val, maxval), minval);
		}

Code: Select all

>	msvcr80d.dll!_wassert(const wchar_t * expr=0x004c7788, const wchar_t * filename=0x004c77f0, unsigned int lineno=573)  Line 384	C
 	SampleBrowser.exe!Ogre::Math::Clamp<float>(float val=1.0000000, float minval=1.0000000, float maxval=1.0000000)  Line 573 + 0x2f bytes	C++
 	SampleBrowser.exe!OgreBites::Slider::setValue(float value=1.0000000, bool notifyListener=true)  Line 1207 + 0x20 bytes	C++
 	SampleBrowser.exe!OgreBites::Slider::setRange(float minValue=1.0000000, float maxValue=1.0000000, unsigned int snaps=1, bool notifyListener=true)  Line 1190	C++
 	SampleBrowser.exe!OgreBites::SampleBrowser::itemSelected(OgreBites::SelectMenu * menu=0x04b12ad8)  Line 349	C++
 	SampleBrowser.exe!OgreBites::SampleBrowser::populateSampleMenus()  Line 791 + 0x1d bytes	C++
 	SampleBrowser.exe!OgreBites::SampleBrowser::setupWidgets()  Line 773 + 0xf bytes	C++
 	SampleBrowser.exe!OgreBites::SampleBrowser::setup()  Line 592 + 0xf bytes	C++
 	SampleBrowser.exe!OgreBites::SampleContext::go(OgreBites::Sample * initialSample=0x00000000)  Line 146 + 0xf bytes	C++
It seems to be the mSampleSlider slider in the browser.
So your browser only works with !1 samples?! ;-)

xad

User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by omniter »

Hey xadhoom,

Actually yeah, the browser only works with no samples at all, or multiple samples, but not one. It's a cool feature I added earlier on. Unpredictability and strange crashes like this make the browser more interesting.

Just kidding. I fixed it. Thanks for letting me know. madmarx had the same problem earlier on.

Cheers. :)
Last edited by omniter on Fri Aug 21, 2009 8:14 pm, edited 1 time in total.

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by Assaf Raman »

:D
Watch out for my OGRE related tweets here.

User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by omniter »

I have a couple of proposed changes to the samples that I'd like everyone's input on.

The CubeMapping sample is large, clunky, and filled with outdated and obfuscated code. It's ~750 lines of code, but the feature it's demonstrating can be summed up with 2 lines in a material script:

Code: Select all

cubic_texture cubemap.jpg combinedUVW
env_map cubic_reflection
And although the Perlin noise effect is pretty cool, such things should be done using shaders, not fixed-function vertex manipulation. Also, the sample adds a "media.cfg" to the runtime directory. I myself until now had no idea what this file did. I imagine most beginners would experience the same sort of confusion (mostly because it sounds more important than it is, maybe even more important than "resources.cfg").

I'm proposing to simplify this sample to just displaying a model with a cube-mapped material that reflects the skybox. Through widgets, the user will be able to choose from a few entities, cubemaps, and blending modes. I think this will make the sample a lot easier to go through and understand. It also removes the need for "media.cfg". So whether you think this is a good idea, or you think the Perlin effect is just too darn sexy to remove, let me know!

Here are some screenshots from recent conversions:

Image

The BezierPatch sample now uses widgets instead of periodically changing settings. The FacialAnimation sample shows/hides manual widgets instead of enabling/disabling them.

P.S. Also, if anyone can suggest ways to categorise all these samples, that would be greatly appreciated. :)

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by Assaf Raman »

Can you just commit all the sln and proj files to your branch? This will make it easier to compile without needing the time to create proj files or copy them to the right location by hand.
Watch out for my OGRE related tweets here.

User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by omniter »

Assaf Raman, if that'll help, sure. :) It'll only be useful if you use Visual Studio 9 (2008) though. Keep in mind, all the config files under "Samples/Common/bin" are meant to work in the final SDK distribution, while the ones under "Samples/Browser/bin" contain different paths, and are meant to work for testing purposes. Specifically, the former uses "../../media" to reach the media folder, while the latter uses "../../../media". I'll commit the browser's bin directory too so you don't have to worry about that. :)

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by Assaf Raman »

I know, but - for now - it will make your project much easier to review.
Delete all the unneeded files when you get the cmake running.
Watch out for my OGRE related tweets here.

User avatar
xadhoom
Minaton
Posts: 973
Joined: Fri Dec 28, 2007 4:35 pm
Location: Germany
x 1

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by xadhoom »

Also, I had no problem changing the project file version for VS2005 manually...

xad

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by Assaf Raman »

Hi Zi Ye,
We have processed the evaluation for your project named Unified Samples Framework with OGRE.
Congratulations, from our data it seems that you have successfully passed the Final Evaluations. Please contact your mentor to discuss the results of your evaluation and to plan your goals and development plan for the rest of the program
Greetings,
The Google Open Source Programs Team
Watch out for my OGRE related tweets here.

User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: [SoC 2009 - Accepted] Unified Samples Framework & Browser

Post by omniter »

:D

Post Reply