[SoC 2009 - Accepted] Unified Samples Framework & Browser

Threads related to Google Summer of Code
Post Reply
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 »

The trays are only sorted vertically. As you can see, almost all the widgets are flat, and were designed to be stacked on top of each other. This was one of the key design decisions to keep the system simple. However, if you simply add a widget to the null tray (TL_NONE), or remove a widget from another tray, it becomes free-floating, meaning you can place it wherever you want. This is how the dialog boxes were implemented. Notice how the Yes and No buttons are right beside each other. Hope that helps. :)

P.S. I have considered adding a "sticky" flag to widgets, to signal to the tray manager that they "stick" onto the end of the widget above them, instead of being pushed down into their own row. It wouldn't be too complicated to setup, but for now I'd like to concentrate on more important matters. Remind me later if you feel like you really need it!
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 »

New shimmering thumbnail frame, dynamic reconfiguration, SDK sample conversion, and orbit camera are the topics in this week's video.

No screenies, because there really isn't anything too (visually) new.

While I convert the samples, I will be adding the rest of the keyboard shortcuts to SdkSample, and at some point I will need to add the progress bar widget. The project is in its final stages, so if you have any suggestions, don't hesitate to make 'em! :D
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2
Contact:

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

Post by Noman »

Wow. Good stuff!
I think the vids really showcase your work well.

Got one question - I saw that there was a 'category' identifier for the sample.
Is there a browsing option that is more list-based, perhaps allowed to browse by category?
(When you will finish converting the demos, I think you will find that navigating via the current method to get to the 30th sample a bit annoying)
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 »

Noman wrote: Got one question - I saw that there was a 'category' identifier for the sample.
Is there a browsing option that is more list-based, perhaps allowed to browse by category?
(When you will finish converting the demos, I think you will find that navigating via the current method to get to the 30th sample a bit annoying)
Of course. The category just defaults to "All". :) Changing the category menu will update the slider, the Select Sample menu, and also the carousel. Within each category, you can browse by sliding through the carousel, clicking on a thumbnail, or selecting a sample from the Select Sample menu.
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

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

Post by Vectrex »

Very nice. Clean. Should stop a bit of newb confusion :)
One thing, the 'round' taskbar icons thing would probably look less confusing and cleaner as just a straight vertical line of icons. I'm sure you don't want to get rid of that though as it would have been harder to implement ;)
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
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 »

Nice. One of the things I like most about your project is the attention to detail, everything is looking very slick, and you've made a lot of sensible choices about things like making the browser robust enough to handle exceptions etc. This is looking great.
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

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

Post by Praetor »

Yep, lots of attention to detail. I like the new features, and the orbit camera will be very handy. Many of the samples would be easier to play with that kind of camera control anyway, and having available will be nice. I'm really happy with the way to runtime config changing worked out. I know you wanted some options to take effect without a device re-initialization, but it seems to work very well this way.
Game Development, Engine Development, Porting
http://www.darkwindmedia.com
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 »

Week 10 has ended! Here's another video showing some of the samples I've converted, and a few features I've added to make the browser and samples more user-friendly. There's texture refreshing, a details panel, different textures for the ogre head model, a help dialog, and more. Here, have some screenies. Click it for the full version. :)

Image

P.S. If anybody wants to, please feel free to lend a hand in converting the samples! Not trying to cheat my way out of the work, of course, ;) but there are quite a few samples! This could be a good chance to familiarise yourself with the new framework (it's really straight forward), and the sooner the samples are converted, the sooner I can start working on the new documentation/tutorials! :D
User avatar
spookyboo
Silver Sponsor
Silver Sponsor
Posts: 1141
Joined: Tue Jul 06, 2004 5:57 am
x 151
Contact:

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

Post by spookyboo »

This is really cool. :D
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 »

This must be the coolest demo browser I've ever seen :D
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
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 »

Haha, love the fish swimming through the torus knot. :) Great work again this week.

You have much more imagination than I do, some of these samples are just there because I wanted to make sure a feature worked. Feel free to modify or combine demos to generally make them cooler; you don't need to assume you need a 1:1 conversion. So long we can quickly run through a bunch of demos that test out the feature points we want to prove work, that's fine. The transparency demo was there just to prove that the transparency out-sorting and ordering worked, for example, and each of the sky* demos were just to prove each version worked, the textureFX was to show a few different fixed-function texture transforms, dyntex was CPU->GPU texture updates, RenderToTexture was both RTTs and reflection camera tests (with animated reflection plane - that's important) etc. I'm sure you could merge a whole bunch of them or replace them with something that proved the same features but didn't require so many separate demos. Nothing is sacrosanct so long as we're still proving the same features. For example, putting Athene and her animated lights on a moving reflective plane with a software updated texture in the background would replace Dot3Bump, RenderToTexture and DynTex in one demo. I have no problem with that sort of thing, these demos just evolved feature-for-feature and could use some stripping of dead wood.

Don't bother converting the deferred shading demo, it's quite large and it's going to be replaced anyway because of Noman's work over the summer, so that would be a waste of your time.
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

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

Post by Vectrex »

I recommend if any demos get merged into bigger/cooler ones, keep the simple ones too. Demos are used for learning as much as showing off. Also on that topic, I'd love to see some playpen examples converted. eg the pssm shadows demo is MUCH simpler to understand than the full on shadows demo. One demo for learning a feature, another to showcase everything about that feature :)
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

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

Post by madmarx »

I am amazed by the quality of your explanation in the videos. You have got great communication skills. It seems also that the code you have is extremely readable, which is a good thing IMHO.

Concerning things that I would like to see in the new demos : in the code, it would be appreciated to get rid of old C code and Macro (ex : use of std::vector instead of C-style array).

Concerning Vectrex point of view I understand it (demo to learn or not), but as I understand it, 'demo' are made for showcase feature of the engin, and 'tuto' should be more to explain things. As a consequence, maybe a simple http link to the corresponding wiki page in the 'demo code', corresponding to the wiki tutorial could be more appropriate. Personnaly I imagine that if I had to re-learn the ogre engin basics once more, I would like to see clearly separated 'demos' and 'tutos' in the code, with simple things explained in the 'tutos'.

Anyway, I am volunteering to help Omniter for the update of the facial animation and the skeleton animation demos during August.
(for the law things, I have already signed the contributor agreement). If you are ok, tell me how you prefer me to upgrade them (directly via soc subversion? or other way?).
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 »

madmarx, that sounds fantastic. I really appreciate your help. :) If you would like to commit directly to SVN, then you'll need commit privileges, which I'd have to ask sinbad about. Alternatively, you could just give me the code through the forums or something. If I remember correctly, the Facial Animation sample has tons of slider bars, and one disadvantage about the new tray manager (compared to CEGUI) is that it uses pixel metrics, which means it's not gonna scale based on the window's dimensions. All those sliders will probably not fit down one side of the viewport in the exact same way as before, so it's gonna need some clever arrangement (maybe split it up into vowels and consonants?). On the bright side, you can move the logo and stats panel wherever you want on the screen, and most of the screen is empty for this sample anyway. Let me know if you run into any serious trouble with the interface.
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

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

Post by madmarx »

Thanks for the advice. I think I can post on the forum. I will try not to polute it too much ^^.
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
CoreDumped
Gremlin
Posts: 177
Joined: Sun Aug 05, 2007 3:55 pm
x 14

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

Post by CoreDumped »

jacmoe wrote:This must be the coolest demo browser I've ever seen :D
+1
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

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

Post by madmarx »

ok, so first, I think the cmake file should be updated.

I tried it for the Transparency so you can have a glance :

Code: Select all

# Configure Transparency demo build

set(HEADER_FILES include/Transparency.h)
set(SOURCE_FILES src/Transparency.cpp)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
#add_library(Demo_Transparency ${OGRE_LIB_TYPE} ${HEADER_FILES} ${SOURCE_FILES} ${RESOURCE_FILES})
add_library(Demo_Transparency SHARED ${HEADER_FILES} ${SOURCE_FILES} ${RESOURCE_FILES})

target_link_libraries(Demo_Transparency ${OGRE_LIBRARIES} ${OIS_LIBRARIES})

set_target_properties(Demo_Transparency PROPERTIES
    COMPILE_DEFINITIONS OGRE_GLPLUGIN_EXPORTS
  )

ogre_config_sample(Demo_Transparency)

add_dependencies(Demo_Transparency ${SAMPLE_DEPENDENCIES})
It seemes to work, but I don't know if it's better to use ${OGRE_LIB_TYPE} or SHARED. I think that it will always be shared, and may have nothing to do with the fact that someone wants Ogre as static library. Could someone confirms ?

Also Omniter, when you'll try, there is a very minor error in the cmakefile of the samples :
line 114 it should be : add_subdirectory(Transparency) :D hope it will save you some time.

EDIT : Onmiter, could you post an example of a valid Sample.cfg ?
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 »

Heya madmarx. Sorry about the late reply (I'm on a small trip home right now). I haven't gotten to the cmake system at all yet, actually. In fact, I don't really know anything about it. We're gonna go through it all after the samples are converted. I am aware that the old Transparency directory was named Transpacency. I renamed it the first time I found out. The cmake files will be modified to reflect this change. You can find the Samples.cfg I use in the Samples/Common/bin/Release directory. But here it is anyway:

Code: Select all

SampleFolder=samples
Sample=Sample_CelShading
Sample=Sample_EnvMapping
Sample=Sample_ParticleFX
Sample=Sample_SkyBox
Sample=Sample_SkyDome
Sample=Sample_SkyPlane
Sample=Sample_Terrain
Sample=Sample_Transparency
Hope that helps! :)
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

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

Post by madmarx »

Ok thanks.
It works in release, but I got an assert min>max from math.h in debug mode.
I am currently doing the skeletal animation samples. Concerning the ResourceGroup, do I create a new one to pre-load the jaiqua and other things, and then destroy it at the end? Or is another one preferred?

I now see details that are difficults to see in your videos (the cursor for example), and it's looking great. And what I appreciate even more are the nice comments /explanation you've wrote around your code.

EDIT : SkeletalAnimation working ok (as a copy of the original one -modulo vector instead of c-array[]-).
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 »

I believe the assertion exception probably originates from a slider. I'll look into that when I get the chance.

As for resource groups, don't worry about it. Just use the resources.cfg that's already there. There's an Essential group containing the tray manager resources and the thumbnails, and there's a Popular group, which contains all the resources used by the SDK samples. It works basically the same way as the old framework. If the sample uses really large resources which aren't used in other samples (like the BSP sample, for instance), then the sample should override the locateResources and loadResources methods. Otherwise, its resources go in the Popular group. In short, you don't have to do anything at all. :)

I'm glad you're getting along with my code. I was afraid it might have been too confusing. :) The tray widgets could definitely use more thorough documentation.
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

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

Post by madmarx »

Hi,

I am currently on the facial animation samples. Unfortunately, I got some problems with the model "facial.mesh". I tried only to create an Entity (without animation or anything) and attach it to a scene node and it fails at the first draw (note : I tried with other meshes, and it works). I don't have a clue right now, because I already upgraded it to the soc2009SVN version with OgreMeshUpgrader.
I may try to convert it to xml to see what's up. Should I setup the demo with another model ?

Now some remarks :
-> the "unload" button gives me errors when one plugin is still running.
-> how to set the beginning position / orientation of the camera, when it is controlled by SdkCameraMan (orbit + freefly styles)?
-> the framerenderqueued is called after reconfiguring, when the scene has not been setup again. As a consequence, I am currently using a boolean in the setupScene()+framerenderqueued() to now if the sample has been initialised or not. It seems that you are doing the tests yourself in the parent function framerenderqueued. Is this solution acceptable / wanted ?

I will tell if I manage to correct the facial model.
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 »

Hey madmarx,

Try setting up the sample without the model for now. In the meantime, I will see if I have the same problem. The unload button seems to be working fine here. What errors are you getting? As for setting initial camera position, for free-look or manual mode, you can just use mCamera to manipulate the camera directly. I do this in some of the samples. For orbit mode, you can use SdkCameraMan::setTargetOffset to set the yaw, pitch, and distance. I'm not sure I understand your third remark about the frameRenderingQueued. Are you getting an exception? If so, please provide details. And could you perhaps paste some code to show me what you mean? Thanks a lot. :)
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

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

Post by madmarx »

concerning my config : windows, VS2009Express, GPU: nvidia9600M
For the unload :
1/ in Samples.cfg I only keep the CellShading example.
2/ I launch the SampleBrowser
3/ I click "unload samples"
4/ it bugs (traditionnal windows error "the program produced an error ...")
End of the log gives :

Code: Select all

22:44:42: Finished parsing scripts for resource group Popular
22:44:42: Texture: sdk_bands.png: Loading 1 faces(PF_A8R8G8B8,2x32x1) with 5 generated mipmaps from Image. Internal format is PF_A8R8G8B8,2x32x1.
22:44:42: Loading library .\Demo_CelShading
22:44:42: Installing plugin: Cel-shading Sample
22:44:42: Plugin successfully installed
22:44:42: Texture: thumb_cel.png: Loading 1 faces(PF_R8G8B8,128x96x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x96x1.
22:44:43: Texture: sdk_button_over.png: Loading 1 faces(PF_A8R8G8B8,128x32x1) with 5 generated mipmaps from Image. Internal format is PF_A8R8G8B8,128x32x1.
22:44:43: Texture: sdk_pulse.png: Loading 1 faces(PF_R8G8B8,8x1x1) with 3 generated mipmaps from Image. Internal format is PF_X8R8G8B8,8x1x1.
22:44:44: Texture: sdk_button_down.png: Loading 1 faces(PF_A8R8G8B8,128x32x1) with 5 generated mipmaps from Image. Internal format is PF_A8R8G8B8,128x32x1.
22:44:44: Uninstalling plugin: Cel-shading Sample
22:44:44: Plugin successfully uninstalled
22:44:44: Unloading library .\Demo_CelShading
For the skeletal animation currently I have :
in 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-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.
-----------------------------------------------------------------------------
*/
/*
-----------------------------------------------------------------------------
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 SkeletalAnimation : 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;

	SkeletalAnimation():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),
		mIsInitialised(false)
	{
		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)
	{
		if(mIsInitialised)	
			// if I suppress this one then I got an error at mAnimState[i]->getTimePosition()
			// I suppose mAnimState[i] is NULL during one frame after reconfigure (<=> setup was still not called).
		{
			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;
		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
			mSceneNode[i] = mSceneMgr->getRootSceneNode()->createChildSceneNode();
			mSceneNode[i]->attachObject(ent);
			mSceneNode[i]->rotate(q);
			mSceneNode[i]->translate(mBasePositions[i]);

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

			// Report whether hardware skinning is enabled or not
			if(i==0)
			{
				MaterialPtr material = ent->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);
				}
			}

			rot += rotInc;
		}

		// 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
		// TODO : here it does not work properly with mCameraMan : it's as if everything was translating in another tranformspace.
		//mCamera->setPosition(100,20,0);
		//mCamera->lookAt(0,10,0);
		//mCameraMan->setCamera(mCamera);

		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);
		
		mIsInitialised = true;
	}

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;
	bool mIsInitialised;			// used to check if scene was created.
};


#endif
in the .cpp (less interesting)

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 "SkeletalAnimation.h"

using namespace Ogre;
using namespace OgreBites;

SamplePlugin* gsp;
Sample* gs;

extern "C" __declspec(dllexport) void dllStartPlugin()
{
	gs = new SkeletalAnimation;
	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;
}

You can have a look at "mIsInitialised" in the .h. I explain the problem in a comment at the beginning of frameRenderingQueued.
Concerning the coding style, this skeletonAnimation demo was a first try. It could be much more readable with a little struct per "jaiqua". I can do it, but after finishing the facialanimation sample.
BTW your trays are truly simple to use. Sliders where done easily.
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 »

This is quite strange. The unload button works fine here (you could see it working in the videos too). What does the debugger say? Also, I'm not getting an error when i get rid of the check inside frameRenderingQueued either. The sample works fine (and survives reconfiguration). I just have no idea why you're getting these errors. Are you using the SDK to build everything, or are you building OGRE from source? I'm also curious as to whether you've obtained the latest version of my code, because if I remember correctly, I've corrected the slider min/max error before. I'm getting none of the issues you've described.

P.S. It seems like you did a great job with the skeletal animation sample. Thanks again. :)
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

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

Post by madmarx »

Good news, I have found the source of the problem concerning facial.mesh and the unload errors : my opengl version does not work properly, but directX9 is ok. So I can work with directX9. I will try to do the facialanimation this evening (sooner I can't).
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
Post Reply