Hello everyone!

I'm trying to modify the maratis 4 experimental brunch.
For now, I'm stuck with level loading.

The project is MaratisEditor.
For level loading I added levelLoader in main.cpp, so it looks:

engine->getLevelLoader()->addLoader(xmlLevelLoad)

This took place in winEvents function, when the window is created (MWIN_EVENT_CREATE).


When I try to load level with

engine->loadLevel(...)

from the winEvents in case MWIN_EVENT_CREATE, it works fine:
https://yadi.sk/i/-oDcZ1HMNVGSoA

When i try to load level from somwhere else (for example, from onEvent method of MV3dEdit, there is a problem):
https://yadi.sk/i/Cw9BVE0jXnPDfw

I checked log and did debug, maratis loads the textures both times.

So, could you give me the direction of moving to find a solution?

2

(32 replies, posted in Plugins)

Hi,
i need to move object and i tried to do it with

MPhysicsContext * Phys=engine->getPhysicsContext();
MObject3d * parent = getParentObject();
Phys->addCentralForce(objId?, MVector3(x,y,0));

how can i get objectId?

I mean this:
http://youtu.be/07vn17DA6OU
but i found problem: i wrote setAnimationSpeed in OnBeginScene() function, and in update all works perfectly)

Thanks, that helped me!
and SetAnimationSpeed doesn't work with animated textures, does it mean i should control fade speed by animation length in blender or there are some other ways to control animation speed?

Hey guys!
I need fade in\out effect, so i think the easiest way is to do black plane in blender with animation, in each frame we change alpha value. I've tried to do it, but i don't understand exactly how to release it in blender.  so could you help?

6

(32 replies, posted in Plugins)

wow i didn't think about that,
in this way it willn't change native scene's script
p.s updated link to video
p.p.s updated code with anael's advice

7

(32 replies, posted in Plugins)

So, workable version of text behavior(to create simple menu)
MouseClick.h

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// SimpleGamePlugin
// MouseClick.h
// 
// Code : Anael Seghezzi & hog
/////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef _MOUSE_CLICK_H
#define _MOUSE_CLICK_H

#include <MEngine.h>


class MouseClick : public MBehavior
{
public:

    // constructors / destructors
    MouseClick(MObject3d * parentObject);
    MouseClick(MouseClick & behavior, MObject3d * parentObject);
    ~MouseClick(void);

private:
    
    // custom variables

    const char* m_cameraName;
    const char* m_sceneName;
    MVector4 m_colour;
    const char* m_soundName;
    const char* m_functionName;
    bool m_play;
    
public:

    // destroy
    void destroy(void);

    // get new
    static MBehavior * getNew(MObject3d * parentObject);

    // get copy
    MBehavior * getCopy(MObject3d * parentObject);

    // name
    static const char * getStaticName(void){ return "MouseClick"; }
    const char * getName(void){ return getStaticName(); }

    // variables
    unsigned int getVariablesNumber(void);
    MVariable getVariable(unsigned int id);

    // events (virtuals from MBehavior class)
    void update(void);
    //void onBeginScene(void);
    void runEvent(int param){}
};

#endif

MouseClick.cpp

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// SimpleGamePlugin
// MouseClick.cpp
// 
// Code : Anael Seghezzi & hog
/////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "MouseClick.h"


/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Init, this part is always similar, constructor, copy constructor etc
/////////////////////////////////////////////////////////////////////////////////////////////////////////

// constructor
MouseClick::MouseClick(MObject3d * parentObject):
MBehavior(parentObject),
m_cameraName(""),
m_sceneName(""),
m_colour(1,1,1,1),
m_soundName(""),
m_functionName(""),
m_play(true)
{}

// copy constructor
MouseClick::MouseClick(MouseClick & behavior, MObject3d * parentObject):
MBehavior(parentObject),
m_cameraName(behavior.m_cameraName),
m_sceneName(behavior.m_sceneName),
m_colour(behavior.m_colour),
m_soundName(behavior.m_soundName),
m_functionName(behavior.m_functionName),
m_play(behavior.m_play)
{}

// destructor
MouseClick::~MouseClick(void)
{}

// destroy function : always similar
void MouseClick::destroy(void)
{
    delete this;
}

// getNew function : always similar
MBehavior * MouseClick::getNew(MObject3d * parentObject)
{
    return new MouseClick(parentObject);
}

// getCopy function : always similar
MBehavior * MouseClick::getCopy(MObject3d * parentObject)
{
    return new MouseClick(*this, parentObject);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Variables, allow to access custom variable from script and from Maratis Editor
/////////////////////////////////////////////////////////////////////////////////////////////////////////

unsigned int MouseClick::getVariablesNumber(void){
    return 5;
}

MVariable MouseClick::getVariable(unsigned int id)
{
    switch(id)
    {
    default:
        return MVariable("NULL", NULL, M_VARIABLE_NULL);
    case 0:
        return MVariable("cameraName", &m_cameraName, M_VARIABLE_STRING);
    case 1:
    return MVariable("sceneName", &m_sceneName, M_VARIABLE_STRING);
    case 2:
        return MVariable("colour", &m_colour, M_VARIABLE_VEC4);
    case 3:
    return MVariable("soundName", &m_soundName, M_VARIABLE_STRING);
    case 4:
    return MVariable("functionName", &m_functionName, M_VARIABLE_STRING);
    }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Events
/////////////////////////////////////////////////////////////////////////////////////////////////////////










// update function (called by MGame class by default)
void MouseClick::update(void)
{
MEngine * engine = MEngine::getInstance();//engine
MGame * game = engine->getGame();//game
MSystemContext * system = engine->getSystemContext();
MInputContext * input=engine->getInputContext();

if( !game->isRunning())
        return;

    MObject3d * parent = getParentObject();
    MLevel * SampleLevel=engine->getLevel();//level
MScene *    SampleScene = SampleLevel->getSceneByName(m_sceneName);//scene
MOText*    SampleText = SampleScene->getTextByName(parent->getName());//text
MOCamera*    SampleCamera=SampleScene->getCameraByName(m_cameraName);//camera
    MOSound * SampleSound=NULL;
    SampleSound=SampleScene->getSoundByName(m_soundName);
    MScriptContext * SampleScript=engine->getScriptContext();
MBox3d*    bbox = SampleText->getBoundingBox();
unsigned int width=0;
unsigned int height=0;
    system->getScreenSize(&width, &height);
    
float mouseX = input->getAxis("MOUSE_X");
float mouseY = input->getAxis("MOUSE_Y");
MVector3 origin = SampleCamera->getTransformedPosition();
MVector3 dest = SampleCamera->getUnProjectedPoint(MVector3(mouseX*width, (1.0f - mouseY)*height, 1.0f));
MVector3 localOrigin = SampleText->getInversePosition(origin);
MVector3 localDest = SampleText->getInversePosition(dest);

    if(isEdgeToBoxCollision(localOrigin, localDest,bbox->min,bbox->max)){        
        SampleText->setColor(m_colour);    
        if(SampleSound)
            if(m_play){
            SampleSound->play();
            m_play=false;
            }
            if(input->onKeyDown("MOUSE_BUTTON1"))
            //if(SampleScript)
            SampleScript->callFunction(m_functionName);
    }
    else
    {
        SampleText->setColor(MVector4(0.8,0.8,0.8,0.6));
    m_play=true;
    
    }
    
}

Behavior properties:
1)cameraName - camera that captures text
2) sceneName - scene, where texts/sounds take place
3)colour - text highlighting(r,y,b,a), when you put mouse on it
4)soundName - sound, when you put mouse on text
5)functionName - the function that would be called, when we press on text (must be in you scene script)
example:

...
function funcName()
...
end

you can change the default text colour by editing

SampleText->setColor(MVector4(0.8,0.8,0.8,0.6));

video
http://youtu.be/_l2oAbihUX4

8

(32 replies, posted in Plugins)

First doesn't work but second works perfectly
I've found solution to my problem with empty scene:  i used mvariable in behavior with empty blank (such as "Camera Name"), and you mustn't use such names (good name is "cameraName" for example). May be it will be useful for somebody

9

(32 replies, posted in Plugins)

anael wrote:

In this case you can use the bounding box of the text and send a ray :

unsigned int width = 0;
unsigned int height = 0;
system->getScreenSize(&width, &height);

float mouseX = input->getAxis("MOUSE_X");
float mouseY = input->getAxis("MOUSE_Y");

// ray
MVector3 origin = camera->getTransformedPosition();
MVector3 dest = camera->getUnProjectedPoint(MVector3(mouseX*width, (1.0f - mouseY)*height, 1.0f));

// bounding box
MBox3d * bbox = text->getBoundingBox();

if(isEdgeToBoxCollision(origin, dest, bbox->min, bbox->max))
    // intersection

I've fixed crashes, but it doesn't work.
when I put my resolution instead of height/width it doesn't work too
Any ideas?
hmm, and when i use plugin and save scene with MouseClick behavior on object, the next time i open it, i take an empty scene ( have to back up), even if i didn't change Game.dll

10

(32 replies, posted in Plugins)

Huge help!

11

(32 replies, posted in Plugins)

oooooooops, I did something wrong
1)How do we pick up behaviors? I did in this way, but does it mean that i take first behavior on object?

ClickBeh=MenuText->getBehavior(0);
ClickBeh->runEvent(0);


2)where do i write runEvent?
I declare it in header file in this way

void runEvent(int param);

and then in cpp file of beh:

void MouseClick::runEvent(int param=0){
...
}

can i do in this way?(maratis crashes(it's my classic phrase now :D )

12

(32 replies, posted in Plugins)

can i add OnBeginScene to my behavior?
i've tried to add virtual void to mbehavior.h, and to mouseclick.h and to mybehavior.h, but after that use of mybehavior(from example) and mouseclick behaviors crash maratis

13

(32 replies, posted in Plugins)

thanks, I'll try it

14

(32 replies, posted in Plugins)

cool, I coudn't even imagine - we can do almost everything with maratis )
I decided to create new behavior
That's one problem - my behavior doesn't take place in behavior list
Could you have a look?
MouseClick.h

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// SimpleGamePlugin
// MouseClick.h
// 
// Code : Anael Seghezzi
/////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef _MOUSE_CLICK_H
#define _MOUSE_CLICK_H

#include <MEngine.h>


class MouseClick : public MBehavior
{
public:

    // constructors / destructors
    MouseClick(MObject3d * parentObject);
    MouseClick(MouseClick & behavior, MObject3d * parentObject);
    ~MouseClick(void);

private:
    
    // custom variables

    const char* m_cameraName;
    
public:

    // destroy
    void destroy(void);

    // get new
    static MBehavior * getNew(MObject3d * parentObject);

    // get copy
    MBehavior * getCopy(MObject3d * parentObject);

    // name
    static const char * getStaticName(void){ return "MouseClick"; }
    const char * getName(void){ return getStaticName(); }

    // variables
    unsigned int getVariablesNumber(void);
    MVariable getVariable(unsigned int id);

    // events (virtuals from MBehavior class)
    void update(void);
    void onBeginScene(void);
    void runEvent(int param){}
};

#endif

MouseClick.cpp

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// SimpleGamePlugin
// MouseClick.cpp
// 
// Code : Anael Seghezzi
/////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "MouseClick.h"


/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Init, this part is always similar, constructor, copy constructor etc
/////////////////////////////////////////////////////////////////////////////////////////////////////////

// constructor
MouseClick::MouseClick(MObject3d * parentObject):
MBehavior(parentObject),
m_cameraName(NULL)
{}

// copy constructor
MouseClick::MouseClick(MouseClick & behavior, MObject3d * parentObject):
MBehavior(parentObject),
m_cameraName(behavior.m_cameraName)
{}

// destructor
MouseClick::~MouseClick(void)
{}

// destroy function : always similar
void MouseClick::destroy(void)
{
    delete this;
}

// getNew function : always similar
MBehavior * MouseClick::getNew(MObject3d * parentObject)
{
    return new MouseClick(parentObject);
}

// getCopy function : always similar
MBehavior * MouseClick::getCopy(MObject3d * parentObject)
{
    return new MouseClick(*this, parentObject);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Variables, allow to access custom variable from script and from Maratis Editor
/////////////////////////////////////////////////////////////////////////////////////////////////////////

unsigned int MouseClick::getVariablesNumber(void){
    return 1;
}

MVariable MouseClick::getVariable(unsigned int id)
{
    switch(id)
    {
    default:
        return MVariable("NULL", NULL, M_VARIABLE_NULL);
    case 0:
        return MVariable("Camera name", &m_cameraName, M_VARIABLE_STRING);
    }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Events
/////////////////////////////////////////////////////////////////////////////////////////////////////////
MScene * MenuScene = NULL;
MOText * MenuText = NULL;
MLevel * MenuLevel=NULL;
MOCamera * MenuCamera=NULL;
MInputContext * input=NULL;
void MouseClick::onBeginScene(void)
{
     //MGame::onBeginScene(); 
    
    MEngine * engine = MEngine::getInstance(); // get the engine instance
    MLevel * level = engine->getLevel(); // get the current level
    MObject3d * parent = getParentObject();
    //printf("use");
    //MenuScene=level->getSceneByName("menu");
    MenuText=MenuScene->getTextByName(parent->getName());
    MenuLevel= engine->getLevel();
    MenuCamera=MenuScene->getCameraByName(m_cameraName);

    
}


// update function (called by MGame class by default)
void MouseClick::update(void)
{
    MEngine * engine = MEngine::getInstance();
    MGame * game = engine->getGame();
    unsigned int width = 0;
    unsigned int height = 0;
    MSystemContext * system = engine->getSystemContext();
        system->getScreenSize(&width, &height);


    if(! game->isRunning())
        return;

float mouseX = input->getAxis("MOUSE_X");
float mouseY = input->getAxis("MOUSE_Y");
MVector3 origin = MenuCamera->getTransformedPosition();
MVector3 dest = MenuCamera->getUnProjectedPoint(MVector3(mouseX*width, (1.0f - mouseY)*height, 1.0f));
MBox3d * bbox = MenuText->getBoundingBox();
    if(isEdgeToBoxCollision(origin, dest, bbox->min, bbox->max)){
        printf("it works!");
    }
    // get the associated parent object (who is using this behavior)
    //MObject3d * parent = getParentObject();

    // lets rotate the parent object around the z axis, using our custom "rotationSpeed" variable
    //parent->addAxisAngleRotation(MVector3(0, 0, 1), m_rotationSpeed);
    
}

And did you have any project now? Really interesting

15

(32 replies, posted in Plugins)

It crashes plugin
hmm, I had another question
How can I track mouse click on text?(By engine) Do we have speshial function, which tracks clicks?
http://s1.hostingkartinok.com/uploads/images/2014/05/d491156cdb0bcb1d27cde28ef3b8fe49.png
as 2nd variant I can take 4 ponts and if mouse is inside, highlight text/play sound, etc.(but it's not really "interesting" -
the great solution is to make behavior, which does luascript on click)
or I should use 3d to 2d points conversion?

16

(32 replies, posted in Plugins)

That's really strange, but I copied MyGame.cpp from here
http://www.maratis3d.org/code/simplePlugin/MyGame.cpp
renamed scene's objects and added some code:

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// SimpleGamePlugin
// MyGame.cpp
// 
// Code : Anael Seghezzi
/////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "MyGame.h"


// constructor
MyGame::MyGame(void):
MGame()
{}

// destructor
MyGame::~MyGame(void)
{}

MScene * MenuScene = NULL;
MOText * MenuText = NULL;

void MyGame::onBeginScene(void)
{
    MGame::onBeginScene(); // call the default MGame begin scene
    
    MEngine * engine = MEngine::getInstance(); // get the engine instance
    MLevel * level = engine->getLevel(); // get the current level
    printf("use");
    MenuScene=level->getSceneByName("menu");
    MenuText=MenuScene->getTextByName("menuText");
    
}

void MyGame::update(void)
{
    MEngine * engine = MEngine::getInstance(); // get the engine instance
    MSystemContext * system = engine->getSystemContext(); // get system context
    MInputContext * input = engine->getInputContext();// get input context
    if(MenuScene){
        if(input->onKeyDown("MOUSE_BUTTON1")){
            printf("yeah!");
        }
    }

    MGame::update();
}

And it works!!!
Great thanks, anael, for your support
MLOG_ERROR and MLOG_WARRNING still don't work, but printf("..."); works as I want.

17

(32 replies, posted in Plugins)

http://s7.hostingkartinok.com/uploads/images/2014/05/b11afcbdefdfb4708f2df6c39bab6f55.png
I'm really in release mode.
"Simple Game plugin" and "Gui demo" were compiled in debug, and worked perfectly

18

(6 replies, posted in Scripting)

you can make a ray(from camera) to check if you look at the object, and check distance, then disable physics and change it's position (using lerp may be)

19

(32 replies, posted in Plugins)

Yes, and that's only 32 bit compilation in vs by default
Have you tested this plugin(with maratis editor)?

20

(32 replies, posted in Plugins)

http://yadi.sk/d/n8xRjmUGQhDUv

21

(32 replies, posted in Plugins)

The version is 3.21 beta win32 (downoloaded from http://www.maratis3d.org/?page_id=57)
My system is win7 x64
I use VS2010 Express with SP1
The libraries and includes for project are the same ver (in SDK folder from maratis archive)
in Release mode, all does the same.
And all the tutorial and demo plugins work well
I can send you my project and whole the code for better view

It crashes even with it(MyGame.cpp):

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// SimpleGamePlugin
// MyGame.cpp
// 
// Code : Anael Seghezzi
/////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "MyGame.h"

// constructor
MyGame::MyGame(void):
MGame()
{}

// destructor
MyGame::~MyGame(void)
{}

//MOText * TextEntity= NULL;
// custom begin scene
void MyGame::onBeginScene(void)
{
    MGame::onBeginScene(); // call the default MGame begin scene
    
    MEngine * engine = MEngine::getInstance(); // get the engine instance
    MLevel * level = engine->getLevel(); // get the current level


    MLOG_ERROR("here it is");

}

may be I miss some basic functions to render or smth like this?

22

(32 replies, posted in Plugins)

Thanks for your reply, anael
it's something strange, I did have scene "menu"
http://s1.hostingkartinok.com/uploads/images/2014/05/49fd1928871a8a7b38c40c57d56ff33c.png
and it crashes with your code too, in maratis_log there is only

Log tracked at level :6
Info     Render version : 3.3.0     in main     in d:\maratis_svn\trunk\dev\maratis\editor\main.cpp

when I add any code after

menu = level->getSceneByName("menu");

  (even MLOG_WARNING) it crashes

23

(32 replies, posted in Plugins)

Hello!
I've started f** with c++(cuz I'm noob in it and espeshially in maratis engine)
I have a question

Here is my OnBeginFunction

....
MOText * TextEntity= NULL;
....
void MyGame::onBeginScene(void)
{
    MGame::onBeginScene(); // call the default MGame begin scene
    
    MEngine * engine = MEngine::getInstance(); // get the engine instance
    MLevel * level = engine->getLevel(); // get the current level
    
    
    // get GUI scene and objects
    menu = level->getSceneByName("menu");
    //mouseEntity = menu->getEntityByName("Mouse");
    //barEntity = menu->getEntityByName("Bar");
    TextEntity = menu->getTextByName("Text0");
}

it compiles well but
when I launch game, Maratis crashes and when I del

TextEntity = menu->getTextByName("Text0");

it works well, so what's wrong?
---------------------------------
p.s. Can we put an engine log to console, to find where is a mistake, and if it exists, just disable plugin(as it made with lua)

Thanks!

Tutorial Doctor wrote:

Interesting software, just from using it for a few seconds, I can tell it might be useful. That level looks like a good start also.

I think it is already possible to extend the engine with game plugins as was done here:

http://www.maratis3d.org/?p=563

I mean plugin for editor, not for game, for example, a tool to create decals(plugin  exstends "editor's abilities")

Hello!
I' ve just started with Maratis Engine and the first question I took was about levels - ye, I have Blender, but it's not really easy to creat simple level geometry with textures, etc.
So I found a great solution - a tool called Runtime World Editor. It exports to .obj with textures.
http://yadi.sk/d/KWq_s9dOP3j8y - this version with obj export
You can read more about it here http://runtimelegend.com/rep/rtworld/index
http://s6.hostingkartinok.com/uploads/thumbs/2014/05/ec70a2a26f6689cc301a09d4b46c867f.png
Ok, I think I can give you my test-room, it took me 5 mins to build it with RWE
http://yadi.sk/d/8I66DznFP3mTL
hmm, and about Maratis...
I'm not really good at programming, I worked before with Unity3d(C#/JS), so what's about little tour to maratis c++ basics?
And I have an idea, can we do an in-editor-plugin system for maratis? so that everyone can make mini-plugins to improve engine's work.