876

(11 replies, posted in Scripting)

And something like that ?

Sound0 = getObject("Sound0")
SOUND = {obj = Sound0, impact = 0}

function play_impact(sound)
    if sound.impact == 0 then
        playSound(sound.obj)
        sound.impact = 1
    end
end

function stop_impact(sound)
   sound.impact = 0
end

function onSceneUpdate()
   
    if isCollisionBetween(Car, Ground) then
        changeCurrentCamera(Camera1)
        deactivate(Text0)
        deactivate(Text1)  
        camcycle = 1
        play_impact(SOUND)
    else
        stop_impact(SOUND)
    end

end

877

(1 replies, posted in Gossip)

Hello ! Welcome !
What a nice post, it's good to see you like it smile
I'm waiting to see your game project,

Cheers

A nice add-on for creating light maps of entire scenes (source: BlenderNation) :
http://code.google.com/p/blender-addons-by-mifth/

Yes, a spot cannot be more than 89.9 because it cannot be more than 180 degrees (fact 90x2 = 180° total angle)

Wait, I taught there was only one light in your scene,
if there is more than one I think I know what is going on,
in Maratis each entity use only the closest light around :

For desktop it's the 4 closest lights, but on iOS because it slower, it's only the closest.
So that's why you can see a different behavior than on Maratis editor.
Try to use less number of light for ios, or to be sure the lights radius don't overlap too much.

881

(9 replies, posted in General)

I updated the ios example to allow npk.
It can load xml files as before or it can load a npk file transparently.

For using npk, you will need the mproj file and the npk file with the same name in the same folder
ex : MyGame.mproj and MyGame.npk

can you check that your camera is looking at the objects and that the clipping is correct,
also, just try the light with a big radius (in case)...

You are not using a custom shader with the mesh or something like that ?

Do you have at least one camera in the current scene ?

was your game files in the project directories meshs/ maps/ etc ?

885

(9 replies, posted in General)

I'm seeing what I can do, there is some small problem on iOS,
continue working with the mesh xml, later you will just have to replace the xml by the bin, it's transparent,
I'll let you know.

886

(9 replies, posted in General)

Hi, in fact xml mesh are transform to binary when the project is published and packed to a npk file.

But we didn't update the ios example to load from npk, you remind me.

To read npk it needs :

- MFileManager/MPackageManagerNPK
- MLoaders/MBinMeshLoader

887

(2 replies, posted in Scripting)

Hey, I think it's "MOUSE_BUTTON1" not "MOUSE_BUTTON_1"

(http://wiki.maratis3d.org/index.php?title=Keys)

888

(11 replies, posted in Engine)

Very nice smile

For the text you can also use MOText manually I think, but there might be a little trick for drawing it if it's not in a scene (not sure).

889

(11 replies, posted in Engine)

Looks nice smile
Are you doing an in-game GUI system ?

There is multiple way to do it, you can use RayHit by sending a ray starting from the touch position,
or you can use collision detection :

- move a cube (collision physics as a ghost) depending on the touch position.
- detect if there is a collision with other objects (also set as ghost) : http://wiki.maratis3d.org/index.php?tit … ionBetween

891

(10 replies, posted in General)

Yes, for mobile you normally have to use build-in feature only, at least for iOS. For Android I'm not sure, as it is a linux-based system, a desktop lib might work.

There is no build-in variable for fps, you have to count the frames every seconds,
you can do that in MGame::draw for example, increment a number every frame and when 1 sec is done you'll have fps.

But I'll try to add this feature by default soon.

update is called 60 times/sec

I think the problem is in your algorithm,
and should you not do : 

MVector3 newPosition = initialPos + dpos;

instead of :

MVector3 newPosition = parent->getPosition() + dpos;

Also, to get ticks, use engine->getSystemContext()->getSystemTick() instead of gettimeofday (more portable)

894

(11 replies, posted in Engine)

If you want to draw 2d, you might also need to disable depth-test and face-culling.

895

(11 replies, posted in Engine)

It's working ?

896

(11 replies, posted in Engine)

Hi,

you have to set the viewport and the matrix, like with openGL :

void set2dMode(unsigned int width, unsigned int height)
{
    MRenderingContext * render = MEngine::getInstance()->getRenderingContext();
    render->setViewport(0, 0, width, height);
    
    // set ortho projection
    render->setMatrixMode(M_MATRIX_PROJECTION);
    render->loadIdentity();
    
    render->setOrthoView(0.0f, (float)width, (float)height, 0.0f, 1.0f, -1.0f);
    
    render->setMatrixMode(M_MATRIX_MODELVIEW);
    render->loadIdentity();
}

(used in the post process example : http://www.maratis3d.com/code/post-process/MyGame.cpp)

897

(48 replies, posted in General)

To draw text on top of your game you can use a text object (MOText) in a separate scene.

In cpp like this : http://www.maratis3d.org/?p=563
Or in script (it's a new feature) : http://wiki.maratis3d.org/index.php?tit … ameraLayer

You can communicate from lua to c++ (and so for objective c I suppose)

For example by creating your own script function :

int exampleFunc(void)
{
    MEngine * engine = MEngine::getInstance();
    MScriptContext * script = engine->getScriptContext();
    
    if(script->getArgsNumber() == 2)
    {
        int firstArgument = script->getInteger(0);
        int secondArgument = script->getInteger(1);
        
        // do a simple addition
        script->pushInteger(firstArgument+secondArgument);
        return 1; 
    }
    
    return 0;
}



MyGame * game = NULL;

void StartPlugin(void)
{
    // get engine
    MEngine * engine = MEngine::getInstance();

    // add script function
    MScriptContext * script = engine->getScriptContext();
    script->addFunction("testFunction", exampleFunc);
    
    // set my game
    game = new MyGame();
    engine->setGame(game);
}

void EndPlugin(void)
{
    SAFE_DELETE(game);
}

There is also examples to download here : http://www.maratis3d.org/?page_id=53

899

(48 replies, posted in General)

Cool ! can we see a screenshot ? smile
how is the performance ?

900

(48 replies, posted in General)

Nice, thanks,
I'll try to modify all examples to use M_UINT to be cross platform.