[SoC 2009 - Accepted] Unified Samples Framework & Browser

Threads related to Google Summer of Code
Post Reply
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

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

Post by Brocan »

Congrats :D

And nice browser :wink:
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, Brocan. :)

The Dot3Bump and DynTex samples are now converted.

With Dot3Bump, the widgets made things a lot easier by letting you pick stuff instead of cycling stuff. However, the sample was a poor candidate for orbit camera control. So, for this sample, you click and drag to hide the cursor and enter free-look mode. Let go of the mouse button to exit free-look mode and show the cursor again, giving you access to the widgets. This was quite simple to implement.

I found the old DynTex sample a little difficult to convert, so I rolled my own. Instead of a chemical reaction, I thought making a painting sample would be a clear and simple way of demonstrating dynamic texturing. But I found painting programs really cliche, so I added a twist to it. There's a snowy scene behind a frosted pane. The user can click and drag to wipe away the frost on the pane, but it slowly refreezes and fades back in. This way, it's a lot easier to see that a dynamic texture is being used, rather than projective texturing. The sample also makes use of the SdkTrayManager's getCursorRay method, which is used in a SceneRayQuery to determine which part of the pane to wipe. The sample now comes to 153 lines as opposed to 404.

I plan to combine CubeMapping and RenderToTexture into one Reflection sample, which demonstrates both techniques by rendering the environment onto a cubemap.

Again, please let me know what you think of these changes, everyone! I leave you with some screenies:

Image
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 »

Nice! Our own iFog.
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 »

Fresnel sample converted. :)
Shadow007
Gremlin
Posts: 185
Joined: Sat May 07, 2005 3:27 pm

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

Post by Shadow007 »

I realize it may be a little late, as you already converted a few samples, but is there anything against using an other asset than the Ogre head for the samples ?
I think in particular about you WIP Ogre Model, as well as DragonSnail's, which could be added into the framework...
http://www.artifexterra3d.com/forum/ogr ... dagk9nfdu4
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

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

Post by CABAListic »

Alright, I've begun working on fixing the CMake build. I have the SampleBrowser and the BezierPatch sample successfully running on LInux here, so the rest should be rather straight-forward :)

There were a few minor fixes necessary to get it to work on Linux:
- Linux is case-sensitive, and so far all the cfg files have benn conventionally named lowercase. The SampleBrowser, however, expected them to start with a capital letter. I changed that.
- There was one bug somewhere where you tried to assign a temporary return value to a reference. GCC didn't like that, I suppose Visual C++ just passed over it and you were lucky nothing happened :) Fixed
- __declspec(dllexport) is Visual C++ specific. I've added an appropriate define to SamplePlugin.h to use the correct form for each platform.
- GCC requires a certain attribute set to the SamplePlugin class, otherwise the SampleBrowser wouldn't recognise it as such. I've also added an appropriate define to SamplePlugin.h

Also, I decided to move the sample thumbnails to the Media directory. This location works most naturally, any other would require extra effort to setup, and I think this is agreeable (?).

If you agree, I'll just commit my changes to the branch. There is a very, very minimal chance that it might break the Windows build, so I didn't want to do this without prior warning :)
Meanwhile, I'll take care of the rest of the samples for CMake.
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 »

Shadow007, no it's not late at all. There's still a while until the next release, so we got some time to add/modify samples. I'll definitely be getting to finishing my Sinbad model soon.

CABAListic, great work! Sorry for the little issues I missed and thanks for catching them. I think it'd be fine to put the thumbnails under Media/thumbnails. Go ahead and commit that, and I'll update my copy. Thanks again!
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

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

Post by CABAListic »

Alright, I committed the changes. I still have a couple of samples missing, I'll add them soon.
Anyway, I have some problems with the BSP sample. First of all, it segfaulted when trying to load, this was caused by mSceneMgr->clearScene(); in Sample::_shutdown which didn't check if mSceneMgr was 0. Now I can load the sample, but when I stop it, it will also segfault, only this time the debugger tells me nothing about the cause :( I'll have to investigate this more closely.

BTW: I noticed a slight inconsistency in the Browser behaviour: When a sample is loaded and I return to the browser to select a different sample, then the top button still says "Stop sample", and I need to click it twice to load the new sample. I think it would be convenient (and perhaps less confusing) if you could do with one click. I. e. if you select a different sample, then the button should change to "Start sample" again. But that's just cosmetics :)
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'll look into the segfault. Could be something I did yesterday, actually. :oops:

As for the stop button, I've thought of your idea before, but I realised that you'd HAVE to navigate back to and select the currently running sample in order to stop it (without starting a new sample). The only solution would be to add another start button if a different sample is selected while a sample is running, but this would make it confusing, because there'd be both a start and stop button, and it'll be hard to tell which sample is supposed to start/stop. In the end, I figured it'd be easier to just have one button that starts the selected sample or stops the currently running sample. This isn't exactly an inconsistency, but just a choice on my part as to how the browser should behave. That having been said, it's obviously causing confusion. You're welcome to suggest some alternative solutions. :)
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

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

Post by CABAListic »

Hm, the question is if you actually need to be able to stop a sample. The only visual effect is that the background in the browser changes to green again :)
Personally, I'd favour the two-button scheme, although the stop button should probably be greyed out so long as no sample is loaded.
Anyway, it's really not much of an issue, it just felt strange not to be able to start a selected sample :)
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 »

Alright. Done. When you select another sample, the button says "Start Sample". :)
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 »

Strange... I can't seem to get the BSP sample to segfault like you said, even in debug mode without the scene manager check you put in. Am I missing something? :(
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

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

Post by CABAListic »

Ok, I added the remaining samples to the CMake build and committed the changes. Works on Linux, should probably also work on Windows (though I didn't test it, feel free to give it a go :) ). I can't say anything about Mac, though. Might or might not work.

As for the segfaults: No idea. Well, the missing check on mSceneMgr is a definite error if mSceneMgr can be 0 (since you added a check below I assume it might), so the fix doesn't hurt, either way :)
Unfortunately the debugger remains silent as to the cause of the other segfault. And I found another one: When using the help function in the BumpMapping sample, it segfaults upon clicking the Ok button. Again, the debugger tells me nothing.
It is quite possible that these segfaults may not be related to your code. I wonder if they might be related to the gcc visibility settings, since I had to add a visibility parameter to the SamplePlugin class, chances are I need to add that to all the sample classes. I'll do some experiments.
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 »

Actually, I thought you were the one who added the check for the mSceneMgr being 0. It actually can't be 0 unless _shutdown is called twice in a row (which it shouldn't be), so I never bothered to check. But doesn't hurt to be safe, I guess. :)
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

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

Post by CABAListic »

There is another mSceneMgr check below which I didn't add. :) (The line which destroys mSceneMgr.)
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 think that was peer pressure from all the other checks in the method. :oops:
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 »

So, I just finished converting the Lighting sample. All is well except one thing: the trail colours are swapped... yeah. I spent a good deal of time looking through it and comparing it with the old source code, but I just can't seem to find the problem. Everything is a parallel of the old code, and it looks fine to me. One of the trails also leaves a temporary white stub at the beginning of the sample, as if the initial colour settings haven't yet been applied. Am I doing something wrong, or were some changes made to the RibbonTrail class? If you have any idea, please let me know. Thanks!

Here's a screenshot:

Image

Here's my code:

Code: Select all

#ifndef __Lighting_H__
#define __Lighting_H__

#include "SdkSample.h"

using namespace Ogre;
using namespace OgreBites;

class LightingSample : public SdkSample
{
public:

	LightingSample()
	{
		mInfo["Title"] = "Lighting";
		mInfo["Description"] = "Shows OGRE's lighting support. Also demonstrates automatic "
			"time-relative behaviour using billboards and controllers.";
		mInfo["Thumbnail"] = "thumb_lighting.png";
		mInfo["Category"] = "Effects";
	}

    bool frameRenderingQueued(const FrameEvent& evt)
    {
		// move the lights along their paths
		mGreenLightAnimState->addTime(evt.timeSinceLastFrame);
		mYellowLightAnimState->addTime(evt.timeSinceLastFrame);

		return SdkSample::frameRenderingQueued(evt);   // don't forget the parent class updates!
    }

protected:

	void setupContent()
	{
		// set our camera to orbit around the origin at a suitable distance
		mCameraMan->setStyle(CS_ORBIT);
		mCameraMan->setYawPitchDist(Radian(0), Radian(0), 400);

		mTrayMgr->showCursor();

		// create an ogre head and place it at the origin
		Entity* head = mSceneMgr->createEntity("Head", "ogrehead.mesh");
		mSceneMgr->getRootSceneNode()->attachObject(head);

		setupLights();
	}

	void setupLights()
	{
		mSceneMgr->setAmbientLight(ColourValue(0.1, 0.1, 0.1));  // dim ambient lighting

		// create a ribbon trail that our lights will leave behind
		RibbonTrail* trail = (RibbonTrail*)mSceneMgr->createMovableObject("RibbonTrail");
		mSceneMgr->getRootSceneNode()->attachObject(trail);
		trail->setMaterialName("Examples/LightRibbonTrail");
		trail->setNumberOfChains(2);
		trail->setMaxChainElements(80);
		trail->setTrailLength(400);

		SceneNode* node;
		Animation* anim;
		NodeAnimationTrack* track;
		Light* light;
		BillboardSet* bbs;
		
		// create a light node
		node = mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(50, 30, 0));

		// create a 14 second animation with spline interpolation
		anim = mSceneMgr->createAnimation("Path1", 14);
		anim->setInterpolationMode(Animation::IM_SPLINE);

		track = anim->createNodeTrack(1, node);  // create a node track for our animation

		// enter keyframes for our track to define a path for the light to follow
		track->createNodeKeyFrame(0)->setTranslate(Vector3(50, 30, 0));
		track->createNodeKeyFrame(2)->setTranslate(Vector3(100, -30, 0));
		track->createNodeKeyFrame(4)->setTranslate(Vector3(120, -80, 150));
		track->createNodeKeyFrame(6)->setTranslate(Vector3(30, -80, 50));
		track->createNodeKeyFrame(8)->setTranslate(Vector3(-50, 30, -50));
		track->createNodeKeyFrame(10)->setTranslate(Vector3(-150, -20, -100));
		track->createNodeKeyFrame(12)->setTranslate(Vector3(-50, -30, 0));
		track->createNodeKeyFrame(14)->setTranslate(Vector3(50, 30, 0));

		// create an animation state from the animation and enable it
		mYellowLightAnimState = mSceneMgr->createAnimationState("Path1");
		mYellowLightAnimState->setEnabled(true);

		// set initial settings for the ribbon trail and add the light node
		trail->setInitialColour(0, 1.0, 0.8, 0);
		trail->setColourChange(0, 0.5, 0.5, 0.5, 0.5);
		trail->setInitialWidth(0, 5);
		trail->addNode(node);

		// attach a light with the same colour to the light node
		light = mSceneMgr->createLight();
		light->setDiffuseColour(trail->getInitialColour(0));
		node->attachObject(light);

		// attach a flare with the same colour to the light node
		bbs = mSceneMgr->createBillboardSet(1);
		bbs->createBillboard(Vector3::ZERO, trail->getInitialColour(0));
		bbs->setMaterialName("Examples/Flare");
		node->attachObject(bbs);
		
		// create a second light node
		node = mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(-50, 100, 0));

		// create a 10 second animation with spline interpolation
		anim = mSceneMgr->createAnimation("Path2", 10);
		anim->setInterpolationMode(Animation::IM_SPLINE);

		track = anim->createNodeTrack(1, node);  // create a node track for our animation

		// enter keyframes for our track to define a path for the light to follow
		track->createNodeKeyFrame(0)->setTranslate(Vector3(-50, 100, 0));
		track->createNodeKeyFrame(2)->setTranslate(Vector3(-100, 150, -30));
		track->createNodeKeyFrame(4)->setTranslate(Vector3(-200, 0, 40));
		track->createNodeKeyFrame(6)->setTranslate(Vector3(0, -150, 70));
		track->createNodeKeyFrame(8)->setTranslate(Vector3(50, 0, 30));
		track->createNodeKeyFrame(10)->setTranslate(Vector3(-50, 100, 0));

		// create an animation state from the animation and enable it
		mGreenLightAnimState = mSceneMgr->createAnimationState("Path2");
		mGreenLightAnimState->setEnabled(true);

		// set initial settings for the ribbon trail and add the light node
		trail->setInitialColour(1, 0.0, 1.0, 0.4);
		trail->setColourChange(1, 0.5, 0.5, 0.5, 0.5);
		trail->setInitialWidth(1, 5);
		trail->addNode(node);

		// attach a light with the same colour to the light node
		light = mSceneMgr->createLight();
		light->setDiffuseColour(trail->getInitialColour(1));
		node->attachObject(light);

		// attach a flare with the same colour to the light node
		bbs = mSceneMgr->createBillboardSet(1);
		bbs->createBillboard(Vector3::ZERO, trail->getInitialColour(1));
		bbs->setMaterialName("Examples/Flare");
		node->attachObject(bbs);
	}

	AnimationState* mGreenLightAnimState;
	AnimationState* mYellowLightAnimState;
};

#endif
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 everyone,

Some of you may have noticed my unusually slow pace as of late. When I first began this project, I thought this last sample conversion phase would be a quick and easy copy-n-paste kind of job. It's turned out to be anything but. I find myself compelled to make changes everywhere. If you take a look at all the samples I've already converted, you'll see that all macros have been removed, all #defines are now consts, all arrays are now vectors, all CEGUI or keyboard controls have been replaced with tray controls, the coding conventions have changed, etc. I got a reality check today when I realised that the remaining samples are large and unfamiliar to me, and my knit-picky personality probably won't change anytime soon. I am going at a ridiculously slow pace trying to rewrite all the old samples, while putting off more important things like writing documentation and tutorials. This is why I now leave the task of converting the remaining samples to the team and any other volunteers (if you're not too knit-picky like me, you could copy-n-paste most of the samples fairly quickly). I have already converted 17 samples, and plan to convert 4 more before moving on to writing documentation and tutorials. I also plan to finish my OGRE character model as an addition to the SDK media. Of course I'll still offer my fullest support for the remaining samples and any future samples. The time allocated to this final phase was a gross underestimation on my part, and I apologise.

P.S. I know it sounds like I'm leaving, but really I'm just going to focus on something else now. :) My job here isn't done yet.
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 »

..what's "OgreBites"? :)
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, Vectrex. :) From an earlier post:
omniter wrote:I placed all the classes under a new namespace "OgreBites" (which is also the nickname for the browser). The class names seemed a bit too short and/or generic to not have a namespace, and I didn't want to put something non-core under the "Ogre" namespace. Of course this is just an idea. If you guys think it's a bad one, let me know.
If you want to know why I specifically chose to call it "Bites", then uh... okay, imagine you're at a convention of some sort, and you're treated to some free bite-sized samples of OGRE. Then you have a pretty good idea of what was going through my head when I chose this name.

Of course, this is open to change. If people think it's easier to just put it under the Ogre namespace, then so be it.
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 »

well I can see 1000 questions asking the same because it's not obvious. I thought it might have been a general Ogre utilities thing, so to avoid that something very boring like 'OgreDemos' or 'OgreDemoLauncher' might be better ;) I'd probably avoid words like 'framework' and 'browser' as that will also start a barrage of newbie questions about embedded web browsing :)
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 »

I encounter a crash when running the Fresnel demo going back to menu with escape and starting the particle demo. It crashes on load of the particle demo and lands here:

Code: Select all

Fresnel.h:
void postRenderTargetUpdate(const RenderTargetEvent& evt)
{
   mWater->setVisible(true);  // unhide the water
...
I don´t get the error when I change the example order (I just tried a few). VS2005 XP SP3 Debug

BTW1: The Jaquias are a bit to low sinking into the ground.
BTW2: Very nice DynTex sample :-)

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 »

xadhoom, all fixed.

In the Fresnel sample, the scene manager wasn't cleared before cleaning up the render targets, so the render textures were never removed because they were still being used. So the sample was still registered as a render target listener even after being destroyed. Boom, crash. The scene is now destroyed before cleanupContent is called, so it's not so easy to shoot yourself in the foot anymore.

The Jaiquas were always that low, but you're right, their toes sink into the ground. I changed the plane to be located at -1 on the Y axis, and now it's fine.

Glad that you like the DynTex sample. :)
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 »

Fixed the Lighting sample. Added a simple "ogredance" animated texture and made the TextureFX sample with it. You can see it in my avatar on the right. -->
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 »

For what it's worth I actually really like the original mockup layout :) http://www.ogre3d.org/wiki/index.php/Image:Mockup.jpg
The current one seems a bit crowded to me. Like the description can't fit fully on screen, even though it's the most important bit really.
Post Reply