Many errors with the code of the tuto

Problems building or running the engine, queries about how to use features etc.
Post Reply
Aquila Templum
Gnoblar
Posts: 1
Joined: Thu Feb 21, 2019 6:52 pm

Many errors with the code of the tuto

Post by Aquila Templum »

Hi everybody,
I'm French so I'm sorry for my english !
Foremost, my project doesn't build hence visual studio shows me many errors : :lol:

Gravité Code Description Projet Fichier Ligne État de la suppression
Erreur (active) E0135 class "Ogre::Vector<3, Ogre::Real>" n'a pas de membre "UNIT_Y" OgreProject c:\Ogre\SDK-1.11\appCenter.cpp 117
Erreur (active) E0135 class "Ogre::Vector<3, Ogre::Real>" n'a pas de membre "UNIT_Z" OgreProject c:\Ogre\SDK-1.11\appCenter.cpp 127
Erreur (active) E0135 class "Ogre::Vector<3, Ogre::Real>" n'a pas de membre "UNIT_Y" OgreProject c:\Ogre\SDK-1.11\include\OGRE\OgreCamera.h 340
Erreur (active) E0135 class "Ogre::Vector<3, Ogre::Real>" n'a pas de membre "ZERO" OgreProject c:\Ogre\SDK-1.11\include\OGRE\OgreCamera.h 438
Erreur (active) E0135 class "Ogre::Vector<3, Ogre::Real>" n'a pas de membre "ZERO" OgreProject c:\Ogre\SDK-1.11\include\OGRE\OgreEntity.h 584
Erreur (active) E0135 class "Ogre::Vector<3, Ogre::Real>" n'a pas de membre "UNIT_SCALE" OgreProject c:\Ogre\SDK-1.11\include\OGRE\OgreMatrix4.h 298
Erreur (active) E0135 class "Ogre::Vector<3, Ogre::Real>" n'a pas de membre "UNIT_SCALE" OgreProject c:\Ogre\SDK-1.11\include\OGRE\OgreStaticGeometry.h 619
Erreur MSB6006 Arrêt de "cmd.exe" avec le code -1073741819. ZERO_CHECK C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 171
Erreur MSB6006 Arrêt de "cmd.exe" avec le code 1. OgreProject C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 171


That is my CmakeLists.txt :

cmake_minimum_required (VERSION 2.8)
project (OgreTest01)

set(OGRE_DIR C:/Ogre/SDK-1.11/CMake)

# specify which version and components you need
find_package(OGRE 1.11 REQUIRED COMPONENTS Bites RTShaderSystem)
# copy resource.cfg next to our binaries where OGRE looks for it
file(COPY ${OGRE_CONFIG_DIR}/resources.cfg DESTINATION ${CMAKE_BINARY_DIR})

add_executable(OgreTest01 appCenter.cpp)
target_link_libraries(OgreTest01 ${OGRE_LIBRARIES})

Then the code :

Code: Select all

#include <exception>
#include <iostream>

#include "Ogre.h"
#include "OgreApplicationContext.h"
#include "OgreInput.h"
#include "OgreRTShaderSystem.h"
#include "OgreApplicationContext.h"
#include "OgreCameraMan.h"

using namespace Ogre;
using namespace OgreBites;

class TutorialApplication
        : public ApplicationContext
        , public InputListener
{
public:
    TutorialApplication();
    virtual ~TutorialApplication();

    void setup();
    bool keyPressed(const KeyboardEvent& evt);
};


TutorialApplication::TutorialApplication(): ApplicationContext("OgreTutorialApp")
{
}


TutorialApplication::~TutorialApplication()
{
}


void TutorialApplication::setup()
{
    // do not forget to call the base first
    ApplicationContext::setup();
    addInputListener(this);

    // get a pointer to the already created root
    Root* root = getRoot();
    SceneManager* scnMgr = root->createSceneManager();

    // register our scene with the RTSS
    RTShader::ShaderGenerator* shadergen = RTShader::ShaderGenerator::getSingletonPtr();
    shadergen->addSceneManager(scnMgr);

    // -- tutorial section start --
    //! [cameracreate]
    SceneNode* camNode = scnMgr->getRootSceneNode()->createChildSceneNode();
    Camera* cam = scnMgr->createCamera("myCam");
    //! [cameracreate]

    //! [cameraposition]
    camNode->setPosition(200, 300, 400);
    camNode->lookAt(Vector3(0, 0, 0), Node::TransformSpace::TS_WORLD);
    //! [cameraposition]

    //! [cameralaststep]
    cam->setNearClipDistance(5);
    camNode->attachObject(cam);
    //! [cameralaststep]

    //! [addviewport]
    Viewport* vp = getRenderWindow()->addViewport(cam);
    //! [addviewport]

    //! [viewportback]
    vp->setBackgroundColour(ColourValue(0, 0, 0));
    //! [viewportback]

    //! [cameraratio]
    cam->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
    //! [cameraratio]

    //! [ninja]
    Entity* ninjaEntity = scnMgr->createEntity("ninja.mesh");
    ninjaEntity->setCastShadows(true);

    scnMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ninjaEntity);
    //! [ninja]

    //! [plane]
    Plane plane(Vector3::UNIT_Y, 0);
    //! [plane]

    //! [planedefine]
    MeshManager::getSingleton().createPlane(
            "ground", RGN_DEFAULT,
            plane,
            1500, 1500, 20, 20,
            true,
            1, 5, 5,
            Vector3::UNIT_Z);
    //! [planedefine]

    //! [planecreate]
    Entity* groundEntity = scnMgr->createEntity("ground");
    scnMgr->getRootSceneNode()->createChildSceneNode()->attachObject(groundEntity);
    //! [planecreate]

    //! [planenoshadow]
    groundEntity->setCastShadows(false);
    //! [planenoshadow]

    //! [planesetmat]
    groundEntity->setMaterialName("Examples/Rockwall");
    //! [planesetmat]

    //! [lightingsset]
    scnMgr->setAmbientLight(ColourValue(0, 0, 0));
    scnMgr->setShadowTechnique(ShadowTechnique::SHADOWTYPE_STENCIL_MODULATIVE);
    //! [lightingsset]

    //! [spotlight]
    Light* spotLight = scnMgr->createLight("SpotLight");
    //! [spotlight]

    //! [spotlightcolor]
    spotLight->setDiffuseColour(0, 0, 1.0);
    spotLight->setSpecularColour(0, 0, 1.0);
    //! [spotlightcolor]

    //! [spotlighttype]
    spotLight->setType(Light::LT_SPOTLIGHT);
    //! [spotlighttype]

    //! [spotlightposrot]
    SceneNode* spotLightNode = scnMgr->getRootSceneNode()->createChildSceneNode();
    spotLightNode->attachObject(spotLight);
    spotLightNode->setDirection(-1, -1, 0);
    spotLightNode->setPosition(Vector3(200, 200, 0));
    //! [spotlightposrot]

    //! [spotlightrange]
    spotLight->setSpotlightRange(Degree(35), Degree(50));
    //! [spotlightrange]

    //! [directlight]
    Light* directionalLight = scnMgr->createLight("DirectionalLight");
    directionalLight->setType(Light::LT_DIRECTIONAL);
    //! [directlight]

    //! [directlightcolor]
    directionalLight->setDiffuseColour(ColourValue(0.4, 0, 0));
    directionalLight->setSpecularColour(ColourValue(0.4, 0, 0));
    //! [directlightcolor]

    //! [directlightdir]
    SceneNode* directionalLightNode = scnMgr->getRootSceneNode()->createChildSceneNode();
    directionalLightNode->attachObject(directionalLight);
    directionalLightNode->setDirection(Vector3(0, -1, 1));
    //! [directlightdir]

    //! [pointlight]
    Light* pointLight = scnMgr->createLight("PointLight");
    pointLight->setType(Light::LT_POINT);
    //! [pointlight]

    //! [pointlightcolor]
    pointLight->setDiffuseColour(0.3, 0.3, 0.3);
    pointLight->setSpecularColour(0.3, 0.3, 0.3);
    //! [pointlightcolor]

    //! [pointlightpos]
    SceneNode* pointLightNode = scnMgr->getRootSceneNode()->createChildSceneNode();
    pointLightNode->attachObject(pointLight);
    pointLightNode->setPosition(Vector3(0, 150, 250));
    //! [pointlightpos]
    // -- tutorial section end --
}


bool TutorialApplication::keyPressed(const KeyboardEvent& evt)
{
    if (evt.keysym.sym == SDLK_ESCAPE)
    {
        getRoot()->queueEndRendering();
    }
    return true;
}


int main(int argc, char **argv)
{
    /*try
    {
        TutorialApplication app;
        app.initApp();
        app.getRoot()->startRendering();
        app.closeApp();
    }
    catch (const std::exception& e)
    {
        std::cerr << "Error occurred during execution: " << e.what() << '\n';
        return 1;
    }*/

	TutorialApplication app;
	app.initApp();
	app.getRoot()->startRendering();
	app.closeApp();

    return 0;
}
Moreover, I use the SDK which comes from the Ogre's website. The CmakeList.txt file build the project without INSTALL.vcxproj so I wonder if it's the problem. I think that's all ! :D

Thanks for your help.
User avatar
saintnick
Halfling
Posts: 51
Joined: Tue Nov 27, 2018 1:41 am
x 5

Re: Many errors with the code of the tuto

Post by saintnick »

I didn't run your errors through a translator but I think that you are forgetting to use the Ogre name space before calls to UNIT_X, ZERO, etc

Sample:

Code: Select all

Vector3 zeroVector = Vector3::ZERO;
Vs

Code: Select all

Ogre::Vector3 zeroVector = Ogre::Vector3::ZERO;
I did however post your code into an IDE and look at the lines it says the errors come from. Nothing corresponds.
niubaty
Kobold
Posts: 27
Joined: Thu Jan 10, 2019 2:19 pm
x 2

Re: Many errors with the code of the tuto

Post by niubaty »

The newer OgreVector Header is different from the older version.
ZERO UNIT_X .... are only declared in header file, but defined in OgreVector.cpp which is compiled to the static lib.
I thought you might link the wrong static lib or something like that.
I recommand you can try build sdk from source instead of using prebuild sdk. Then try to compile your project again.
Post Reply