Where is the code which runs on sample browser?

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Brown
Gnoblar
Posts: 14
Joined: Sat Dec 21, 2024 11:37 am
x 1

Where is the code which runs on sample browser?

Post by Brown »

Hi, I'm new in the field of game development. I wanted to learn some basic game development techniques. To start I first started learning OpenGL because it is open then found out that it is better to start with a game engine which is Object Oriented rather procedural in nature and then I stumbled upon OGRE. I found it quite helpful and it enabled me to compile code in Linux(Ubuntu) which was a pain before CMake introduction in OGRE. Before I use to compile via command line which was not fun. So, I wanted to thank you people for making it open source and now the important question where is the code which I can compile and play myself which I can view in ogre browser. Thanks in advance!

rpgplayerrobin
Bugbear
Posts: 805
Joined: Wed Mar 18, 2009 3:03 am
x 467

Re: Where is the code which runs on sample browser?

Post by rpgplayerrobin »

I guess you are asking about which file you can alter to play around yourself by using the sample browser?

In that case, you can alter any of the samples, for example, the Cube Mapping sample is located at:
ogre-14.3.2\Samples\Simple\include\CubeMapping.h

It is a bit hard to find it in the compiler, but just drag it into it and then you can adjust what you want there.

Brown
Gnoblar
Posts: 14
Joined: Sat Dec 21, 2024 11:37 am
x 1

Re: Where is the code which runs on sample browser?

Post by Brown »

Thanks for the reply @rpgplayerrobin ,

You get it right. I want to explore the code which generated all those samples in the sample browser. I can see SinbadSampleCharacter.h but I want to see the code written for movement, jump etc. I want to explore all those codes available. I couldn't find the cpp file which is responsible for creating the samples. It must be a file but which one generated each of those sample codes? For example, one for Ogre animation and attack, one for quake arena model etc. Because it will give a hands-on experience on how everything is created in a game. Thanks in advance.

Brown
Gnoblar
Posts: 14
Joined: Sat Dec 21, 2024 11:37 am
x 1

Re: Where is the code which runs on sample browser?

Post by Brown »

Thanks for the reply @rpgplayerrobin ,
As I'm new to Ogre I didn't understood your answer at first glance. You're right. All the code I want to play with is in Samples Directory. Sindbad in action is also there. Now, I've to copy paste all the sample code in my directory and create main file for all the sample and create objects and call setup method of all the sample. For newbie like me who is new to Ogre wanted something like below.

//main.cpp
#include "sample_character.h"

int main(){
SampleCharacter* objSampleCharacter;
objSampleCharacter = new SampleCharacter();
objSampleCharacter->setup();
objSampleChracter->clearup();
return 0;
}

I should have posted this question in the newbie section. Appologies!

paroj
OGRE Team Member
OGRE Team Member
Posts: 2284
Joined: Sun Mar 30, 2014 2:51 pm
x 1248

Re: Where is the code which runs on sample browser?

Post by paroj »

Code: Select all

int main(int argc, char *argv[])
{
    OgreBites::ApplicationContext ctx("OgreTutorialApp");
    ctx.initApp();
    {
        Sample_Character sample;
        sample.setShaderGenerator(Ogre::RTShader::ShaderGenerator::getSingletonPtr());
        sample._setup(&ctx);
        ctx.getRoot()->startRendering();
    }
    ctx.closeApp();
    return 0;
}
Brown
Gnoblar
Posts: 14
Joined: Sat Dec 21, 2024 11:37 am
x 1

Re: Where is the code which runs on sample browser?

Post by Brown »

For people like me who had strugle repllicating the code by copy pasting parts of the code. I'll suggest using the above code as is, with some changes, which are below.
Step 1:
Copy-paste the code of SampleCharacter.h in one of your created file, and remove the magic definition of the class as below and add the added code as well.

Replace the definition of the SampleCharacter class.

Code: Select all

class Sample_Character : public SdkSample{
// rest of the code as is.

// I've added this code as the compiler gave the error that the method was not found. I've no idea why?
// The below code is present in the Sample.h file, but with a condition which doesn't get triggered for me. So, I've had to rewrite it in my class.
        void setShaderGenerator(Ogre::RTShader::ShaderGenerator* shaderGenerator)
	{
		mShaderGenerator = shaderGenerator;
	}
}

// Don't forget to add the newly created header file in the above code.
Step 2(Optional and not recomended):
Change line 94 of SinbadCharcter.h to the code below only if you get an error.

Code: Select all

else if (key == OgreBites::SDLK_SPACE && (mTopAnimID == ANIM_IDLE_TOP || mTopAnimID == ANIM_RUN_TOP))

Step 3(CMakeLists.txt):

Code: Select all

cmake_minimum_required(VERSION 3.13.0)

find_package(OGRE REQUIRED COMPONENTS Bites RTShaderSystem CONFIG)
#[b]Don't forget to point it to the right folder.[/b]
file (GLOB SAMPLES_HEADERS ../../ogre-14.4.1/Samples/*/include)
include_directories(${SAMPLES_HEADERS})

add_executable(selfLearning selfLearning.cpp)

target_link_libraries(selfLearning OgreBites OgreRTShaderSystem )

Note:
For people like me who tried to use Sinbad.mesh in their code and got errors like the eye shader is not present, and write your own custom code for it.
I think it is some advanced-level code which I struggle to find and was a breakpoint for me. The above solution is simple and a great starting point.
Now, to add the Quake arena in the above code and make Bullet physics work as well.

Thanks @paroj

Brown
Gnoblar
Posts: 14
Joined: Sat Dec 21, 2024 11:37 am
x 1

Re: Where is the code which runs on sample browser?

Post by Brown »

I have been able to load the Quake Arena with the Sinbad character, but have not able to point it correctly. I see the arena after I keep moving Ogre forward, but something seems off. I'm suspecting the difference in the camera Yaw angle and its setting. Any pointers greatly appreciated. Thanks!
https://github.com/ALTAMASH80/ogre3dSel ... #L233-L241

chilly willy
Halfling
Posts: 82
Joined: Tue Jun 02, 2020 4:11 am
x 27

Re: Where is the code which runs on sample browser?

Post by chilly willy »

What do you mean by "something seems off"? Can you describe it or post a screenshot?

Brown
Gnoblar
Posts: 14
Joined: Sat Dec 21, 2024 11:37 am
x 1

Re: Where is the code which runs on sample browser?

Post by Brown »

I've shared my view on this new topic. Thanks! viewtopic.php?t=97718.