1,326

(21 replies, posted in External Tools)

Hi,

I just tried on osX with Blender 2.59, it's working, the addon-on is in Import-Export,
after you imported the zip file with "Install Add-on" button, don't forget to check the add-on to enable it,
and to do "Save As Default" to save the User Preferences (or it doesn't stay checked).

1,327

(64 replies, posted in General)

Hi,

there is no other customization in 3rdparty, and later I will remove the TinyXML one.
For the MKEY_CONTROL, yes there is not all the time a native one, it can be the LEFT or RIGHT as you say.

About MGLContext.cpp, it's not using glut and not using glew. Only gl and glu (and the GLee lib on windows for extensions, this lib should work on linux too). But yes, it is missing #ifdef _LINUX (I don't know what is the exact name) for specific includes.

1,328

(64 replies, posted in General)

Hi,

I think dbacchet ported the scons build system to work on linux ? Was it not working or did you just preferred CMake ?

About tinyXML, at some point I added the "QueryUIntAttribute" function, but I then removed the call where I was using it as it was not so important and not good to get newer version of TinyXML. Did I forget it somewhere ?

[EDIT] > yes, still used in MMeshLoader.
ps : you can find the modified TinyXML code in SVN/3rdparty/

Maratis works on 64bits, at least on MacOSX (never tested on windows).

1,329

(8 replies, posted in Bug report)

If you cannot run shaders, shadows, bump mapping (normal map) won't work,
but I still think you should have a way to have better opengl drivers at least to have opengl 2.0 ?

About mipmap, iPhone can use it actually, even shaders from iPhone 2.

1,330

(49 replies, posted in General)

LoadLevel should be called only from the MGame class, because behaviors are parts of a level scene so it can cause crashes if it is called in the middle of the level update.

Use the same code you wrote in a custom MGame class at the end of the MGame::update() function. It should work.

1,331

(8 replies, posted in Bug report)

openGl 1.5.0 should at least be able to use multitexture,
so it's strange that sponza fps doesn't show textures.

Maybe your drivers only support power2 texture size, try to create a simple material in blender using a texture having a 256x256 size, and disable "mipmap" :

http://www.maratis3d.com/wp-content/uploads/2011/01/08.jpg

1,332

(8 replies, posted in Bug report)

Maybe you can try to install opengl drivers up to date ?
Is the "SponzaFps" example also not showing texture ? This example originally use fixed renderer.

Shadow only works with standard renderer (it need shaders).

I think it's a driver problem, you should be able to have shaders if your computer is not too old.

1,333

(64 replies, posted in General)

Hi,
yes, all engine code is already portable, the only specific code is MWindow, window creation (opengl init, fullscreen...), inputs (keyboard, mouse...) and some basic things.

For the mac port, I used 90% of GLWF code, with just some renaming (for the keys defines) and some minor modification. Maybe I should have just made a real GLFW wrapper, but there was some things in GLFW that was not fitting. It's possible to do the same thing for the MWindow linux port, to use GLFW X11 code as a base.

About the "plugin system", the mac code use unix portable code so it's normally ported already.

Using boost can be interesting but is not necessary, the standard libraries are working good for now.

1,334

(59 replies, posted in General)

cool,
keep in mind that you are limited to 8 textures,
try to pack the textures as much as you can (for example, using the alpha component of the second texture as blend map, in another texture, use red component for the first specular map and green for the second etc).

1,335

(1 replies, posted in Tutorials/Examples)

very nice !

1,336

(59 replies, posted in General)

The code you used was optimized for using only 4 textures,
the varying variable texCoord was packing the data to use less memory,
so for a 8 textures system there was some modification to do :

(i didn't tested it)

attribute vec3 Vertex;
attribute vec3 Normal;
attribute vec3 Tangent;
attribute vec3 Color;

uniform bool LightShadow[3];
uniform mat4 LightShadowMatrix[3];

uniform mat4 TextureMatrix[8];
uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 NormalMatrix;
uniform mat4 ProjModelViewMatrix;

varying vec2 texCoord[8];
varying vec4 shadowCoord[3];
varying vec4 position, normal, tangent;

attribute vec2 TexCoord0;
attribute vec2 TexCoord1;
attribute vec2 TexCoord2;
attribute vec2 TexCoord3;
attribute vec2 TexCoord4;
attribute vec2 TexCoord5;
attribute vec2 TexCoord6;
attribute vec2 TexCoord7;

void main(void)
{
    if(LightShadow[0]) shadowCoord[0] = LightShadowMatrix[0] * vec4(Vertex, 1.0);
    if(LightShadow[1]) shadowCoord[1] = LightShadowMatrix[1] * vec4(Vertex, 1.0);
    if(LightShadow[2]) shadowCoord[2] = LightShadowMatrix[2] * vec4(Vertex, 1.0);

    normal = NormalMatrix * vec4(Normal, 1.0);
    position = ModelViewMatrix * vec4(Vertex, 1.0);
    gl_Position = ProjModelViewMatrix * vec4(Vertex, 1.0);

    texCoord[0] = (TextureMatrix[0] * vec4(TexCoord0, 1.0, 1.0)).xy;
    texCoord[1] = (TextureMatrix[1] * vec4(TexCoord1, 1.0, 1.0)).xy;
    texCoord[2] = (TextureMatrix[2] * vec4(TexCoord2, 1.0, 1.0)).xy;
    texCoord[3] = (TextureMatrix[3] * vec4(TexCoord3, 1.0, 1.0)).xy;
    texCoord[4] = (TextureMatrix[4] * vec4(TexCoord4, 1.0, 1.0)).xy;
    texCoord[5] = (TextureMatrix[5] * vec4(TexCoord5, 1.0, 1.0)).xy;
    texCoord[6] = (TextureMatrix[6] * vec4(TexCoord6, 1.0, 1.0)).xy;
    texCoord[7] = (TextureMatrix[7] * vec4(TexCoord7, 1.0, 1.0)).xy;
        
    tangent = NormalMatrix * vec4(Tangent, 1.0);
}


uniform bool AlphaTest;
uniform vec4 FogColor;
uniform float FogEnd;
uniform float FogScale;

uniform vec3 MaterialEmit;
uniform float MaterialShininess;
uniform float MaterialOpacity;

uniform vec4 LightPosition[4];
uniform vec3 LightDiffuseProduct[4];
uniform vec3 LightSpecularProduct[4];
uniform vec3 LightSpotDirection[4];
uniform float LightConstantAttenuation[4];
uniform float LightQuadraticAttenuation[4];
uniform float LightSpotCosCutoff[4];
uniform float LightSpotExponent[4];
uniform bool LightActive[4];

uniform sampler2D LightShadowMap[3];
uniform bool LightShadow[3];
uniform float LightShadowBias[3];
uniform float LightShadowBlur[3];

uniform sampler2D Texture[8];
uniform sampler2D RandTexture;

varying vec2 texCoord[8];
varying vec4 shadowCoord[3];
varying vec4 position, normal, tangent;

vec4 texture0 = texture2D(Texture[0], texCoord[0]);                    
vec4 texture1 = texture2D(Texture[1], texCoord[1]);
vec4 texture3 = texture2D(Texture[3], texCoord[3]);

vec3 diffuse = MaterialEmit*texture3.xyz;
vec3 specular = vec3(0.0, 0.0, 0.0);

vec3 nor = normalize(normal.xyz);
vec3 bi = normalize(-cross(normal.xyz, tangent.xyz));
vec3 tan = normalize(tangent.xyz);

vec3 bump = normalize(texture2D(Texture[2], texCoord[2]).xyz * 2.0 - 1.0);

vec3 N = normalize(tan*bump.x + bi*bump.y + nor*bump.z);
vec3 E = normalize(-position.xyz);


float lookup(vec4 shadCoord, sampler2D shadMap, vec2 offSet)
{
    float distanceFromLight = texture2D(shadMap, shadCoord.xy + offSet).z;
    return step(shadCoord.z, distanceFromLight);
}            
                                
float computeShadow(bool shad, vec4 shadCoord, sampler2D shadMap, float shadBias, float shadBlur)
{
    float shadow = 1.0;
    if(shad)
    {
        vec4 shadowCoordinateWdivide = shadCoord;
        shadowCoordinateWdivide.z -= shadBias;

        shadowCoordinateWdivide /= shadowCoordinateWdivide.w;
         
        float blur = (shadBlur*0.01);
        vec4 rand = texture2D(RandTexture, (shadowCoordinateWdivide.xy)*(500.0/(shadBlur+1.0)))*2.0 - 1.0;
        
        vec2 d = rand.xy;
        d = normalize(d)*blur;
                                
        vec2 dp = vec2(d.y, -d.x);
        
        shadow = lookup(shadowCoordinateWdivide, shadMap, rand.zw*blur);
        shadow += lookup(shadowCoordinateWdivide, shadMap,  d);
        shadow += lookup(shadowCoordinateWdivide, shadMap, -d);
        shadow += lookup(shadowCoordinateWdivide, shadMap,  dp);
        shadow += lookup(shadowCoordinateWdivide, shadMap, -dp);
        shadow *= 0.2;

    }                
    return shadow;
}
                                
void computeLight(vec3 lightPosition, float constantAttenuation, float quadraticAttenuation, vec3 lightDiffuse, vec3 lightSpecular, vec3 spotDir, float spotCos, float spotExp, bool shad, vec4 shadCoord, sampler2D shadMap, float shadBias, float shadBlur)
{
    vec3 lightDir = lightPosition - position.xyz;
    vec3 L = normalize(lightDir);

    float lambertTerm = max(dot(N, L), 0.0);
    if(lambertTerm > 0.0)
    {
        if(spotCos > 0.0)
        {
            float spot = dot(spotDir, -L);
            
            if(spot > spotCos)
            {
                float shadow = computeShadow(shad, shadCoord, shadMap, shadBias, shadBlur);
                                
                spot = clamp(pow(spot, spotExp), 0.0, 1.0);
                                
                float lightDirLength2 = dot(lightDir, lightDir);
                float attenuation = (spot / (constantAttenuation + (lightDirLength2 * quadraticAttenuation)))*shadow;

                diffuse = diffuse + (lightDiffuse * lambertTerm * attenuation);

                vec3 S = normalize(E + L);
                float spec = pow(max(dot(S, N), 0.0), MaterialShininess) * attenuation;
                specular = specular + (lightSpecular * spec);
            }
        }
        else
        {
            float lightDirLength2 = dot(lightDir, lightDir);
            float attenuation = (1.0 / (constantAttenuation + (lightDirLength2 * quadraticAttenuation)));

            diffuse = diffuse + (lightDiffuse * lambertTerm * attenuation);

            vec3 S = normalize(E + L);
            float spec = pow(max(dot(S, N), 0.0), MaterialShininess) * attenuation;
            specular = specular + (lightSpecular * spec);
        }
    }
}

void computeLightNoShadow(vec3 lightPosition, float constantAttenuation, float quadraticAttenuation, vec3 lightDiffuse, vec3 lightSpecular, vec3 spotDir, float spotCos, float spotExp)
{
    vec3 lightDir = lightPosition - position.xyz;
    vec3 L = normalize(lightDir);

    float lambertTerm = max(dot(N, L), 0.0);
    if(lambertTerm > 0.0)
    {
        if(spotCos > 0.0)
        {
            float spot = dot(spotDir, -L);
            
            if(spot > spotCos)
            {            
                spot = clamp(pow(spot, spotExp), 0.0, 1.0);
                                
                float lightDirLength2 = dot(lightDir, lightDir);
                float attenuation = (spot / (constantAttenuation + (lightDirLength2 * quadraticAttenuation)));

                diffuse = diffuse + (lightDiffuse * lambertTerm * attenuation);

                vec3 S = normalize(E + L);
                float spec = pow(max(dot(S, N), 0.0), MaterialShininess) * attenuation;
                specular = specular + (lightSpecular * spec);
            }
        }
        else
        {
            float lightDirLength2 = dot(lightDir, lightDir);
            float attenuation = (1.0 / (constantAttenuation + (lightDirLength2 * quadraticAttenuation)));

            diffuse = diffuse + (lightDiffuse * lambertTerm * attenuation);

            vec3 S = normalize(E + L);
            float spec = pow(max(dot(S, N), 0.0), MaterialShininess) * attenuation;
            specular = specular + (lightSpecular * spec);
        }
    }
}


void main(void)
{
    vec4 texture6 = texture2D(Texture[5], texCoord[5]); // blend texture                
        vec4 texture7 = texture2D(Texture[6], texCoord[6]); // second texture
    float interp = texture6.x; // use the red component
        float invInterp = 1.0 - interp;


    if(LightActive[0])
    {
        computeLight(
            LightPosition[0].xyz,
            LightConstantAttenuation[0],
            LightQuadraticAttenuation[0],
            LightDiffuseProduct[0],
            LightSpecularProduct[0],
            LightSpotDirection[0],
            LightSpotCosCutoff[0],
            LightSpotExponent[0],
            LightShadow[0],
            shadowCoord[0],
            LightShadowMap[0],
            LightShadowBias[0],
            LightShadowBlur[0]
        );

        if(LightActive[1])
        {
            computeLight(
                LightPosition[1].xyz,
                LightConstantAttenuation[1],
                LightQuadraticAttenuation[1],
                LightDiffuseProduct[1],
                LightSpecularProduct[1],
                LightSpotDirection[1],
                LightSpotCosCutoff[1],
                LightSpotExponent[1],
                LightShadow[1],
                shadowCoord[1],
                LightShadowMap[1],
                LightShadowBias[1],
                LightShadowBlur[1]
            );

            if(LightActive[2])
            {
                computeLight(
                    LightPosition[2].xyz,
                    LightConstantAttenuation[2],
                    LightQuadraticAttenuation[2],
                    LightDiffuseProduct[2],
                    LightSpecularProduct[2],
                    LightSpotDirection[2],
                    LightSpotCosCutoff[2],
                    LightSpotExponent[2],
                    LightShadow[2],
                    shadowCoord[2],
                    LightShadowMap[2],
                    LightShadowBias[2],
                    LightShadowBlur[2]
                );

                if(LightActive[3])
                {
                    computeLightNoShadow(
                        LightPosition[3].xyz,
                        LightConstantAttenuation[2],
                        LightQuadraticAttenuation[3],
                        LightDiffuseProduct[3],
                        LightSpecularProduct[3],
                        LightSpotDirection[3],
                        LightSpotCosCutoff[3],
                        LightSpotExponent[3]
                    );
                }
            }
        }
    }

    vec4 finalColor = vec4(diffuse*(texture0.xyz*invInterp + texture7.xyz*interp) + specular*texture1.xyz, MaterialOpacity*texture0.w);
    float fogFactor = clamp((FogEnd + position.z) * FogScale, 0.0, 1.0);
    gl_FragColor = mix(FogColor, finalColor, fogFactor);
}

1,337

(59 replies, posted in General)

Do you have error messages in the Maratis console window ?

1,338

(49 replies, posted in General)

Hi,

1) it's automatically cleaned.

2) "setLevel" should be used carefully, it should be only called using the MGame class at the end of "update()".
If you want to load a different level, it's better to use "loadLevel(const char * filename)".
Otherwise, "setLevel" just change the current level pointer.

3) You can use the code of MaratisPlayer (it's on svn) and modify it a bit, or even create your own independent player, it's very simple, there is a ready made vcproj (pc) and xcodeproj (mac).

1,339

(12 replies, posted in General)

Ok, I understood, I forget that when there is no animations,
the armature is not updated.

Just call this after you finish moving your bones and it should work :

armature->processBonesLinking();
armature->updateBonesSkinMatrix();

So, to summary here is a code to rotate a bone :

if(mesh)
{
       MArmature * armature = mesh->getArmature();
       if(armature)
       {
           MOBone * bone = armature->getBone(0); // be sure the bone exist
           bone->addAxisAngleRotation(MVector3(1, 0, 0), 10);
            
           armature->processBonesLinking();
           armature->updateBonesSkinMatrix();
       }
}

1,340

(12 replies, posted in General)

Look at the .mesh file with a text editor and check that you have armature and bones inside.
Or send me the file.

Also, I looked at your behavior code again,
you do : "bone->addAxisAngleRotation(vector,i);"
but "i" is equal to zero, so it won't add any rotation,

try : "bone->addAxisAngleRotation(vector, 10);"

1,341

(12 replies, posted in General)

Hi,

"input->onKeyDown("MOUSE_BUTTON1")" is launched only 1 frame just after you press the mouse button (not every frames).
You maybe want to use "isKeyPressed("MOUSE_BUTTON1")".

You maybe also have animation keys that cancel your changes,
try to not export, or delete the Armature Animation file from Blender (.maa),
or use the piece of code I gave you in the previous post to remove keys for a specific bone.

1,342

(1 replies, posted in General)

Hi,
thank you and welcome !

In Maratis, interactivity is built around 3 tools :

- Behaviors : apply predefined behaviors to objects (like follow, look-at or custom behaviors)
- Lua Script : to script the scene events (collisions, keyboard events, timers...)
- C++ plugins : to write specific game code, write custom behaviors and custom script functions.


The behaviors are set visually in the editor, it's the most simple part, but there is not a lot of behaviors by default yet.
You can also attach objects in Maratis using the "Edit>link selection" menu.

For scripting, you can look at the functions list here, the script loop is synchronized at 60 frame/sec :
http://www.maratis3d.org/?p=269

You can look at the tutorials and docs here :
http://www.maratis3d.org/?page_id=53

There is a general video here :
http://www.maratis3d.org/?p=477


About your mesh follow and look-at question,
it's simply using a behavior with the name of the target to follow or look-at
(behaviors editing happen in the third tab when you have an object selected).

The feet-box is just a trick to be sure that the object touch the ground and not the walls
(because the box is a bit smaller than the collision box).

Multiple camera is possible, start by setting all your cameras in Maratis,
then in script you can use : changeCurrentCamera(object)


I'd like to see your creation for sure, don't hesitate to share some screen-shots and questions on the forum.

1,343

(12 replies, posted in General)

Hi,

to move a bone, you have access to all the MObject3d functions (MOBone derive from MObject3d),
for example, the rotation/translation (there is a lot more, you can look at MObject3d.h for more detail) :

bone->setEulerRotation(euler);
bone->addAxisAngleRotation(axis, angle);
bone->setPosition(position);

Be just careful that there is no keyframes associated with the bone, or it will discard your changes.
If you want to remove keyframes for a specific bone, lets say the bone 0 for example, you can do :

MArmatureAnim * armatureAnim = mesh->getArmatureAnim();
if(armatureAnim)
{
    // get bones anim array
    MObject3dAnim * bonesAnim = armatureAnim->getBonesAnim();

    // clear bone 0 keys
    bonesAnim[0].clearPositionKeys();
    bonesAnim[0].clearScaleKeys();
    bonesAnim[0].clearRotationKeys();
}


To play/stop animation (you can look at MOEntity.h for more animation related functions) :

entity->changeAnimation(animationId);


And for shape keys animation, I started working on it and wrote the MMorphingData class,
but I didn't finished to implement it, maybe you can help by studying how to improve the Blender python script exporter
to export Blender shape keys ?

Cheers,
Anaël.

1,344

(6 replies, posted in External Tools)

Hi

It looks to be very "tool" oriented, in the website it's presented to make gui's to launch command line applications (like a video convertor etc). So exept using it to launch Maratis in command line (to convert files or export to iOS) I don't think it's done to create game gui's.

1,345

(49 replies, posted in General)

Hi,

for deactivate in script, it's maybe a bug, it should not continue to collide, I'll have a look at that, thank you for reporting.
For now you can deactivate the object and set the position far away.

Abour GUI exemple, and in general, there is only 1 script launched at a time,
and it is the one from the current scene (Scene-1 in this exemple).

And for the effect, there is 2 ways you cand do something similar :

1 - animate the effect by hand in blender, make a two-sided mesh looking like the shape you want (here an arc), and in the material (when you are in Maratis render mode), set "additive" blending. You can also animate the texture offset to make a fade effect (use a fade texture going from clear to dark (in additive black is invisible)). If necessary, use some bones to deform the effect mesh.

2 - make the effect by programming (more complicated) using the c++ SDK. First in blender create a small polygon attached to the blade and set a transparent material (for it to be invisble). Then in c++, you can find this polygon according to the material and extrude it dynamically.

But, in the video you sent, I think it's done by hand (like in 1).

Hi,
thank you Piranha, and welcome on the forum smile

I know Blender can export Unreal model and Collada (for unity), but I don't know if Blender can import this files. If Unity or Unreal can export collada maybe.

You can find some tips about terrain and modeling on the website and in this forum :
terrain discussion : http://forum.maratis3d.com/viewtopic.php?id=15

tutorials/examples : http://www.maratis3d.org/?page_id=53

Hope to hear you more here,
cheers.

1,347

(12 replies, posted in General)

cool smile
I'm waiting to see what you are working on wink

1,348

(12 replies, posted in General)

Hi !

Hi, I have a question about Maratis Engine.
if I import a mesh that has several bones, how can I stock them into a MOBone* variable ? (the bones don't appear in the maratis 3d view)

What do you mean by "stock them" ?
Otherwise, to get bones from a mesh entity in c++, you can do like that :

MEngine * engine = MEngine::getInstance();
MLevel * level = engine->getLevel();

// get current scene
MScene * scene = level->getCurrentScene();

// get bone 0 from a mesh entity
MOEntity * entity = scene->getEntityByName("MyEntity");
if(entity)
{
    MMesh * mesh = entity->getMesh();
    if(mesh)
    {
        MArmature * armature = mesh->getArmature();
        if(armature)
        {
            MOBone * bone = armature->getBone(0); // get bone 0
        }
    }
}

1,349

(1 replies, posted in Bug report)

Alpha blending doesn't allow using the depth buffer in the same way,
it's using sorting, sub-meshs are rendered back to front according to the distance they center is to the camera.

It's hard to have something perfect, you need to be careful not having objects with alpha blending too close each other,
and to use one sub-mesh by element.

But it's a bit surprising that it happen in the second image as it seems there is a big distance between the 2 quads.

1,350

(59 replies, posted in General)

the full mesh is loaded, but each sub-mesh is only drawn if visible