Intermediate Tutorial 2: RaySceneQueries and Basic Mouse Usage

Original version by Clay Culver

Initial .NET C# port by DigitalCyborg

Note: This was written for Ogre 1.2 and is known to compile against it. Any problems you encounter while working with this tutorial should be posted to the OgreDotNet Forum.

Introduction

In this tutorial we will create the beginnings of a basic Scene Editor. During this process, we will cover:

  1. How to use RaySceneQueries to keep the camera from falling through the terrain
  2. More usage of the OgreDotNet.EventHandler
  3. Using the mouse to select x and y coordinates on the terrain

Prerequisites

This tutorial will assume that you already know how to set up an OgreDotNet project and make it compile successfully. Knowledge of basic Ogre objects (SceneNodes, Entities, etc) is assumed.

Familiarity with STL iterators also helps since the cpp version of the tutorial uses them and we'll introduce how IEnumerator works in a similar fashion. Clay says "(Ogre also uses a lot of STL, if you are not familiar with it, you should take the time to learn it.)" which to us, means take the to learn the how the functionality IEnumator defines is intended to be used.

Getting Started

First, you need to create a new project for the demo. Add a file called "MouseQuery.cs" to the project, and add this to it:

using System;
 using System.Drawing;
 using System.Text;
 
 using Math3D;
 using OgreDotNet;
 using OgreDotNet.Cegui;
 using CeguiDotNet;
 
 namespace OgreDotNetTutorial
 {
    class IntermediateTutorial2 : ExampleApplication
    {
        protected RaySceneQuery mRaySceneQuery = null;      // The ray scene query pointer
        protected bool mLMouseDown, mRMouseDown = false;    // True if the mouse buttons are down
        protected int mCount = 0;                           // The number of robots on the screen
        protected SceneNode mCurrentObject = null;          // The newly created object
 
        protected OgreCEGUIRenderer mGUIRenderer = null;    //CEGUI Renderer
        protected GuiSystem mGUISystem = null;              //GUISystem
        
        float mouseX, mouseY;
 
        protected override void MouseClick(MouseEvent e)
        {
        }
 
        protected override void MouseDragged(MouseMotionEvent e)
        {
        }
 
        protected override void MouseMotion(MouseMotionEvent e)
        {
        }
 
        protected override void MousePressed(MouseEvent e)
        {
        }
 
        protected override void MouseReleased(MouseEvent e)
        {
        }
 
        protected override bool FrameStarted(FrameEvent e)
        {
            if (!base.FrameStarted(e))
                return false;
            return true;
        }
 
        protected override bool FrameEnded(FrameEvent e)
        {
            return base.FrameEnded(e);
        }
 
        protected override void CreateSceneManager()
        {
            mSceneManager = mRoot.CreateSceneManager((ushort)SceneType.ExteriorClose);
        }
 
        protected override void CreateScene()
        {
        }
 
        protected override void CreateEventHandler() 
        {
            base.CreateEventHandler();
        }
 
     public IntermediateTutorial2() : base()
        { 
        }
 
        public override void Dispose()
        {
            base.Dispose();
        }
 
        [MTAThread]
        static void Main(string[] args)
        {
            using (IntermediateTutorial2 app = new IntermediateTutorial2())
                app.Start();
        }
    }
 }

Be sure this code compiles before continuing.

Setting up the Scene

Go to the CreateScene method. The following code should all be familiar. If you do not know what something does, please consult the Ogre API reference before continuing. Add this to CreateScene

// Set ambient light 
            mSceneManager.SetAmbientLight(Color.FromArgb(127, 127, 127));
 
            // World geometry & Sky
            mSceneManager.SetSkyDome(true,"Examples/CloudySky", 5, 8);
            mSceneManager.SetWorldGeometry("terrain.cfg");
             
            // Set camera look point           
            mCamera.SetPosition(new Math3D.Vector3(40,100,280));
            mCamera.Pitch(new Radian(new Degree(-30)));
            mCamera.Yaw(new Radian(new Degree(-45)));

Also, since we are using terrian, we need to setup a SceneManager which can use it. Add this line to CreateSceneManager:

mSceneManager = mRoot.CreateSceneManager((ushort)SceneType.ExteriorClose);

I think we already covered why we need it in an earlier tutorial.

Now that we have the basic world geometry set up, we need to turn on the cursor. We do this using some CEGUI function calls. Before we can do that, however, we need to start up CEGUI. We first create an OgreCEGUIRenderer, then we create the System object and give it the Renderer we just created. I will leave the specifics of setting up CEGUI for a later tutorial, just know that you always have to tell CEGUI which SceneManager you are using with the last paramater to mGUIRenderer.

// CEGUI setup
            mGUIRenderer = new OgreCEGUIRenderer(base.mRenderWindow,
                (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY, false, 3000, mSceneManager);
            mGUIRenderer.Initialise();
            mGUISystem = GuiSystem.CreateGuiSystemSpecial(mGUIRenderer);

Now we need to actually show the cursor. Again, I'm not going to explain most of this code. We will revisit it in a later tutorial.

//Setup Mouse cursor
            CeguiDotNet.SchemeManager.getSingleton().LoadScheme("TaharezLook.scheme");
            CeguiDotNet.MouseCursor.getSingleton().setImage("TaharezLook", "MouseArrow");

Now, since OgreCEGUIRender and GUISystem both implement IDisposable, we'll need to call thier Dispose methods in our applications Dispose method just before we call base.Dispose()

mGUISystem.Dispose();
            mGUIRenderer.Dispose();

If you compile and run the code, you will see a cursor at the center of the screen. yay!

Introducing the EventHandler

That was all that needed to be done for the application. The EventHandler is the complicated portion of the code, so I will spend some time outlining what we are trying to accomplish with the application so you have an idea before we start implementing it.

  • First, we want to bind the right mouse button to a "mouse look" mode. It's fairly annoying not being able to use the mouse to look around, so our first priority will be making adding mouse control back to the program (though only when we hold the right mouse button down).
  • Second, we want to make it so that the camera does not pass through the Terrain. This will make it closer to how we would expect program like this to work.
  • Third, we want to add entities to the scene anywhere on the terrain we left click.
  • Finally, we want to be able to "drag" entities around. That is by left clicking and holding the button down we want to see the entity, and move him to where we want to place him. Letting go of the button will actually lock him into place.


To do this we are going to use several protected variables (these are already added to the class):

protected RaySceneQuery mRaySceneQuery = null;      // The ray scene query pointer
        protected bool mLMouseDown, mRMouseDown = false;    // True if the mouse buttons are down
        protected int mCount = 0;                           // The number of robots on the screen
        protected SceneNode mCurrentObject = null;          // The newly created object
 
        protected OgreCEGUIRenderer mGUIRenderer = null;    //CEGUI Renderer
        protected GuiSystem mGUISystem = null;              //GUISystem

The mRaySceneQuery variable holds a copy of the RaySceneQuery we will be using to find the coordinates on the terrain. The mLMouseDown and mRMouseDown variables will track whether we have the mouse held down (i.e. mLMouseDown is true when the user holds down the left mouse button, false otherwise). mCount counts the number of entities we have on screen. mCurrentObject holds a pointer to the most recently created SceneNode that we have created (we will be using this to "drag" the entity around). Finally, mGUIRenderer holds a pointer to the CEGUI Renderer, which we will be using to update CEGUI with.

Also note that there are many functions related to EventHandler. We will not be using all of them in this demo, but they must be there. Since the ExampleApplication already defines them, and we want to create our own versions of them, we use the override keyword.

Setting up the EventHandler

Go to the IntermediateTutorial2 constructor, and add the following initialization code. Note that we are reducing the movement speed since the Terrain is fairly small, and increasing the rotational speed.

// Reduce move speed
         mMoveSpeed = 50;
         mRotateSpeed *= 2;

Remember that, in order for the EventHandler to recieve events, it be must be subscribed to the events. Since our base class ExampleApplication already does this and we already covered it in an earlier tutorial I won't go into it again here. But, I think the CreateEventHandler function is an ideal place the create the RaySceneQuery... so add this line to CreateEventHandler, right after the call to base.CreateEventHandler();

// Create RaySceneQuery
            mRaySceneQuery = mSceneManager.CreateRayQuery(new Ray());

This is all we do to create the SceneQuery, but if we create a RaySceneQuery, we must later dispose of it since it implements IDisposable. Go to the Applications Dispose() method and add the following line above what is already there.

mRaySceneQuery.Dispose();

Be sure you can compile your code before moving on to the next section.

Adding Mouse Look

We are going to bind the mouse look mode to the right mouse button. To do this, we are going to:

  • update CEGUI when the mouse is moved (so that the cursor is also moved)
  • set mRMouseButton to be true when the mouse is pressed
  • set mRMouseButton to be false when it is released
  • change the view when the mouse is "dragged" (that is held down and moved)
  • hide the mouse cursor when the mouse is dragging


Find the MouseMotion method. We will be adding code to move the mouse cursor every time the mouse has been moved. Add this code to the function:

// Update CEGUI with the mouse motion
            GuiSystem.Instance.InjectMouseMove(e.DeltaX * mRenderWindow.Width, 
                e.DeltaY*mRenderWindow.Height);

Since the mouse being dragged is stored in a seperate callback (and the mouse needs to be moved then too), we need to add this to the beginning of MouseDragged as well:

// Update CEGUI with the mouse motion
           MouseMotion(e);

Now find the MousePressed method. This chunk of code hides the cursor when the right mouse button goes down, and sets the mRMouseDown variable to true. I don't really like that the switch statement uses numerical values (16,32)and not enums... if there is an enum that exists for the ButtonID, please update this.

switch (e.ButtonID)
            {
                case 16:
                    mLMouseDown = true;
                    break;
                case 32:
                    mRMouseDown = true;
                    CeguiDotNet.MouseCursor.getSingleton().hide();
                    break;
                default:
                    break;
            }

Next we need to show the mouse cursor again and toggle mRMouseDown when the right button is let up. Find the MouseReleased function, and add this code:

switch (e.ButtonID)
            {
                case 16:
                    mLMouseDown = false;
                    break;
                case 32:
                    mRMouseDown = false;
                    CeguiDotNet.MouseCursor.getSingleton().show();
                    break;
                default:
                    break;
            }

Now that we have all of the prerequisite code written, we want to change the view when the mouse is moved while holding the right button down. What we are going to do is read the distance it has moved since the last time the method was called. This is accomplished by using the DeltaX & DelatY methods. This code should be added to the MouseDragged function above where it calls MouseMotion. When you normally move your mouse, MouseMotion is called, but when you move your mouse while a button is pressed, MouseDragged is called instead.

if (mLMouseDown)
            {
            } // if mLMouseDown
 
            // If we are dragging the right mouse button.
            else if (mRMouseDown)
            {
                mCamera.Yaw(new Radian(-e.DeltaX * mRotateScale));
                mCamera.Pitch(new Radian(-e.DeltaY * mRotateScale));
            } // else if mRMouseDown

Now if you compile and run this code you will be able to control where the camera looks by holding the right mouse button down.

Terrain Collision Detection

We are now going to make it so that when we move towards the terrain, we cannot pass through it. Since the base class ExampleApplication already handles moving the camera, we are not going to touch that code. Instead, after the EventHandler moves the camera we are going to make sure the camera is 10 units above the terrain. If it is not, we are going to move it there. Please follow this code closely. We will use the RaySceneQuery to do several other things by the time this tutorial is finished, and I will not go into as much detail after this time.

Go to the FrameStarted method and remove all of the code from the method. The first thing we are going to do is call the base class (ExampleApplication) FrameStarted method to do all of its normal functions. If it returns false, we will return false as well.

if (!base.FrameStarted(e))
                return false;

Now the camera has been moved. Our trick is to find the camera's current position, and fire a Ray straight down it into the terrain. This is called a RaySceneQuery, and it will tell us the height of the Terrain below us. After getting the camera's current position, we need to create a Ray. A Ray takes in an origin (where the ray starts), and a direction. In this case our direction will be NegativeUnitY, since we are pointing the ray straight down. Once we have created the ray, we tell the RaySceneQuery object to use it.

// Setup the scene query
            Math3D.Vector3 camPos = mCamera.GetPosition();
            Ray cameraRay = new Ray( new Math3D.Vector3(camPos.x, 5000.0f, camPos.z),
                Math3D.Vector3.NegativeUnitY);
            mRaySceneQuery.setRay(cameraRay);

Next we need to execute the query and get the results. The results of the query come in the form of an RaySceneQueryResultEnumerator, which I will breifly describe. First thing to know is that it implements IEnumerator which means there are some functions that are guaranteed (by the compiler) to be implemented. Let's add the code to perform the query, then we'll talk about it a little more.

// Perform the scene query;
            RaySceneQueryResult result = mRaySceneQuery.execute();
            RaySceneQueryResult.RaySceneQueryResultEnumerator itr = result.GetEnumerator();

The result of the query is basically (oversimplification here) a list of worldFragments (in this case the Terrain) and a list of movables (we will cover movables in a later tutorial). If you are not familiar with IEnumerator, to get the enumerator we have to call GetEnumerator (one of the methods that all classes that implement IEnumerator must have). We also have to call MoveNext to actually go to the first element. MoveNext() returns false, then there were no results returned. In the next demo we will have to deal with multiple return values for SceneQuerys. For now, we'll just do some hand waving and move through it. The following line of code ensures that the query returned at least one result ( itr != null && itr.MoveNext ), and that the result is the terrain (itr.Current.getWWorldFragment).

// Get the results, set the camera height
            if((itr != null) && itr.MoveNext()){

The worldFragment struct contains the location where the Ray hit the terrain in the singleIntersection variable (which is a Vector3). We are going to get the height of the terrain by assigning the y value of this vector to a local variable. Once we have the height, we are going to see if the camera is below the height, and if so we are going to move the camera up to that height. Note that we actually move the camera up by 10 units. This ensures that we can't see through the Terrain by being too close to it.

float terrainHeight = itr.Current.getWorldFragment().getSingleIntersection().y;
 
                if((terrainHeight + 10.0f) > camPos.y) 
                    mCamera.SetPosition(camPos.x,terrainHeight + 10.0f, camPos.z);
            }
            return true;

Lastly, we return true to continue rendering. At this point you should compile and test your program.

Terrain Selection

In this section we will be creating and adding objects to the screen every time you click the left mouse button. Every time you click and hold the left mouse button, an object will be created and "held" on your cursor. You can move the object around until you let go of the button, at which point it will lock into place. To do this we are going to need to change the MousePressed function to do something different when you click the left mouse button. Find the following code in the MousePressed function. We will be adding code inside this case statement.

mouseX = e.X;
            mouseY = e.Y;
 
            switch (e.ButtonID)
            {
                case 16:
                    mLMouseDown = true;
                    break;

The first piece of code will look very familiar. We will be creating a Ray to use with the mRaySceneQuery object, and setting the Ray. Ogre provides us with Camera.GetCameraToViewpointRay; a nice function that translates a click on the screen (x and y coordinates) into a Ray that can be used with a RaySceneQuery object.

// Setup the ray scene query
                    Ray mouseRay = mCamera.GetCameraToViewportRay(e.X,e.Y);
                    mRaySceneQuery.setRay(mouseRay);
                
                    // Execute query
                    RaySceneQueryResult result = mRaySceneQuery.execute();
                    RaySceneQueryResult.RaySceneQueryResultEnumerator itr = result.GetEnumerator();
                    
                    // Get results, create a node/entity on the position
                    if ( itr != null && itr.MoveNext() )
                    {

Now that we have the worldFragment (and therefore the position that was clicked on), we are going to create the object and place it on that position. Our first difficulty is that each Entity and SceneNode in ogre needs a unique name. To accomplish this we are going to name each Entity "Robot1", "Robot2", "Robot3"... and each SceneNode "RobotNode1", "RobotNode2", "RobotNode3"... and so on. To do this we are going to make use of the way strings are handled in C# (namely that the + operation concatenates 2 strings) and the ToString method. We'll be forming the strings Robot1 and RobotNode1 like this:

"Robot" + mCount.ToString()
              "RobotNode" + mCount.ToString()

Next we create the Entity and SceneNode. Note that we use itr.Current.GetWorldFragment().GetSingleIntersection() for our default position of the Robot. We also scale him down to 1/10th size because of how small the terrain is. Be sure to take note that we are assigning this newly created object to the member variable mCurrentObject. We will be using that in the next section.

Entity ent = mSceneManager.CreateEntity(
                            "Robot" + mCount.ToString(), "robot.mesh");
 
                        mCurrentObject = mSceneManager.GetRootSceneNode().CreateChildSceneNode(
                            "RobotNode" + mCount.ToString(),
                            itr.Current.getWorldFragment().getSingleIntersection());
                        
                        mCount++;
                        mCurrentObject.AttachObject(ent);
                        mCurrentObject.SetScale( 0.1f, 0.1f, 0.1f );
                    } //
                    mLMouseDown = true;
                    break;

Now compile and run the demo. You can now place Robots on the scene by clicking anywhere on the Terrain. We have almost completed our program, but we need to implement object dragging before we are finished. Go to the MouseDragged function. We will be adding code inside this if statement:

// If we are dragging the left mouse button.
        if ( mLMouseDown )
        {
        } // if

This entire code chunk should be self explanatory now. We create a Ray based on the mouse's current location, we then execute a RaySceneQuery and move the object to the new position. Note that we don't have to check mCurrentObject to see if it is valid or not, because mLMouseDown would not be true if mCurrentObject had not been set by mousePressed.

if (mLMouseDown)
            {
                mouseX += e.DeltaX;
                mouseY += e.DeltaY;
                Ray mouseRay = mCamera.GetCameraToViewportRay(mouseX,mouseY)
                mRaySceneQuery.setRay(mouseRay);
 
                RaySceneQueryResult result = mRaySceneQuery.execute();
                RaySceneQueryResult.RaySceneQueryResultEnumerator itr = result.GetEnumerator();
 
                if ((itr != null) && itr.MoveNext())
                {
                    mCurrentObject.SetPosition(itr.Current.getWorldFragment().getSingleIntersection());
                }
            } // if mLMouseDown

Compile and run the program. We are now finished! Your result should look something like this, after some strategic clicking: http://www.idleengineer.net/images/tutorial_02.png

Notice: You (the Ray's origin) must be over the Terrain for the RaySceneQuery to report the intersection when using the TerrainSceneManager.

Exercises for Further Study

Easy Exercises

  1. To keep the camera from looking through the terrain, we chose 10 units above the Terrain. This selection was arbitrary. Could we improve on this number and get closer to the Terrain without going through it? If so, make this variable a static class member and assign it there.
  2. We sometimes do want to pass through the terrain, especially in a SceneEditor. Create a flag which turns toggles collision detection on and off, and bind this to a key on the keyboard. Be sure you do not make a SceneQuery in frameStarted if collision detection is turned off.

Intermediate Exercises

  1. We are currently doing the SceneQuery every frame, regardless of whether or not the camera has actually moved. Fix this problem and only do a SceneQuery if the camera has moved. (Hint: Find the translation vector in ExampleFrameListener, after the function is called test it against Vector3::ZERO.)

Advanced Exercises

  1. Notice that there is a lot of code duplication every time we make a scene query call. Wrap all of the SceneQuery related functionality into a protected function. Be sure to handle the case where the Terrain is not intersected at all.

Exercises for Further Study

  1. In this tutorial we used RaySceneQueries to place objects on the Terrain. We could have used it for many other purposes. Take the code from Tutorial 1 and complete Difficult Question 1 and Expert Question 1. Then merge that code with this one so that the Robot now walks on the terrain instead of empty space.
  2. Add code so that every time you click on a point on the scene, the robot moves to that location.

<HR>
Creative Commons Copyright -- Some rights reserved.


THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.

BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.

1. Definitions

  • "Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License.
  • "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License.
  • "Licensor" means the individual or entity that offers the Work under the terms of this License.
  • "Original Author" means the individual or entity who created the Work.
  • "Work" means the copyrightable work of authorship offered under the terms of this License.
  • "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
  • "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.

2. Fair Use Rights

Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws.

3. License Grant

Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:

  • to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works;
  • to create and reproduce Derivative Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works.
  • For the avoidance of doubt, where the work is a musical composition:
    • Performance Royalties Under Blanket Licenses. Licensor waives the exclusive right to collect, whether individually or via a performance rights society (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital performance (e.g. webcast) of the Work.
    • Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right to collect, whether individually or via a music rights society or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions).
    • Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor waives the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions).


The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved.

4. Restrictions

The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:

  • You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any credit as required by clause 4(c), as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any credit as required by clause 4(c), as requested.
  • You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan). You must include a copy of, or the Uniform Resource Identifier for, this License or other license specified in the previous sentence with every copy or phonorecord of each Derivative Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Derivative Works that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder, and You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Derivative Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Derivative Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Derivative Work itself to be made subject to the terms of this License.
  • If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or any Derivative Works or Collective Works, You must keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor designate another party or parties (e.g. a sponsor institute, publishing entity, journal) for attribution in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; the title of the Work if supplied; to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit.

5. Representations, Warranties and Disclaimer

UNLESS OTHERWISE AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE MATERIALS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.

6. Limitation on Liability.

EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

7. Termination

  • This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works or Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
  • Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.

8. Miscellaneous

  • Each time You distribute or publicly digitally perform the Work or a Collective Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
  • Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
  • If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
  • No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
  • This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.