Thanks, this time it's work
51 2011-08-27 13:38:18
Re: Few questions (49 replies, posted in General)
52 2011-08-27 11:14:02
Re: Few questions (49 replies, posted in General)
Hi, I made a basic behavior to test the level permutation (level1 to level2 and level2 to level1) :
if(input->onKeyDown("C"))
{
MLevel* level = engine->getLevel();
if (level->getSceneByName("Sc1"))
{
getGlobalFilename(levelx, workingDir, "levels/level2.level");
engine->loadLevel(levelx);
}
else
{
getGlobalFilename(levelx, workingDir, "levels/level1.level");
engine->loadLevel(levelx);
}
}
This work , but after 6-7 commutations (1-2 for levels using complexes shaders) maratis crash.
(maybe it's because of a lack of memory ... ?)
53 2011-08-25 20:27:52
Re: terrain ? (59 replies, posted in General)
Hi, this is an example of a shader that can use to make terrain (derived from Anaël's CustomShaders example) :
1er slot : diffuse texture (1000*1000 pixels or less is good enough)
2em slot : blend texture (black, red, green, blue)
3em slot : normal texture n°1(color associated : black) (example : snow)
4em slot : specular texture n°1(color associated : black)
5em slot : normal texture n°2(color associated : red) (example : grass)
6em slot : specular texture n°2(color associated : red)
7em slot : normal texture n°3(color associated : green) (example : grass n°2)
8em slot : normal texture n°4(color associated : blue) (example : ground)
here an example of a blend texture :
and this is the script (cut, past and save in a .vert or .frag file) :
frag shader :
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 texture2 = texture2D(Texture[2], texCoord[2]);
vec4 texture3 = texture2D(Texture[3], texCoord[3]);
vec4 texture4 = texture2D(Texture[4], texCoord[4]);
vec4 texture5 = texture2D(Texture[5], texCoord[5]);
vec4 texture6 = texture2D(Texture[6], texCoord[6]);
vec4 texture7 = texture2D(Texture[7], texCoord[7]);
float calcule_oppose (float red, float green, float blue)
{
if(red>green)
{
if (red>blue)
{
return (1.0-red);
}
else
{
return (1.0-blue);
}
}
else if(green>blue)
{
return (1.0-green);
}
else
{
return (1.0-blue);
}
}
float red = texture1.x;
float green = texture1.y;
float blue = texture1.z;
float oppose = calcule_oppose(red,green,blue);
vec3 diffuse = MaterialEmit;
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((texture2.xyz*(oppose/(red+green+oppose+blue))+ texture4.xyz*(red/(red+green+oppose+blue))+texture6.xyz*(green/(red+green+oppose+blue))+texture7.xyz*(blue/(red+green+oppose+blue)))* 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)
{
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 + specular*(texture3.xyz*(oppose/(red+green+oppose+blue))+ texture5.xyz*(red/(red+green+oppose+blue))), MaterialOpacity*texture0.w);
float fogFactor = clamp((FogEnd + position.z) * FogScale, 0.0, 1.0);
gl_FragColor = mix(FogColor, finalColor, fogFactor);
}
vert shader :
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);
}
have fun with maratis
56 2011-08-24 10:26:11
Re: terrain ? (59 replies, posted in General)
Hi, I try to transform the standardDSEN shaders (of the customShaders Example) so that it can blend two textures or more on a mesh, but I didn't succeed completely.
could you help me to improve these scripts :
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 vec4 texCoord[8];
varying vec4 shadowCoord[3];
varying vec4 position, normal, tangent;
vec4 texture0 = texture2D(Texture[0], texCoord[0].xy);
vec4 texture1 = texture2D(Texture[1], texCoord[0].zw);
vec4 texture3 = texture2D(Texture[3], texCoord[1].zw);
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[1].xy).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);
}
I didn't touch the standartDSEN.vert file, maybe I should have done it ...
attribute vec3 Vertex;
attribute vec3 Normal;
attribute vec3 Tangent;
attribute vec3 Color;
uniform bool LightShadow[3];
uniform mat4 LightShadowMatrix[3];
uniform mat4 TextureMatrix[4];
uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 NormalMatrix;
uniform mat4 ProjModelViewMatrix;
varying vec4 texCoord[2];
varying vec4 shadowCoord[3];
varying vec4 position, normal, tangent;
attribute vec2 TexCoord0;
attribute vec2 TexCoord1;
attribute vec2 TexCoord2;
attribute vec2 TexCoord3;
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].xy = (TextureMatrix[0] * vec4(TexCoord0, 1.0, 1.0)).xy;
texCoord[0].zw = (TextureMatrix[1] * vec4(TexCoord1, 1.0, 1.0)).xy;
texCoord[1].xy = (TextureMatrix[2] * vec4(TexCoord2, 1.0, 1.0)).xy;
texCoord[1].zw = (TextureMatrix[3] * vec4(TexCoord3, 1.0, 1.0)).xy;
tangent = NormalMatrix * vec4(Tangent, 1.0);
}
57 2011-08-22 15:57:26
Re: Few questions (49 replies, posted in General)
Hi I have also some general questions about levels.
1) if we load mesh in the methode "onbeginlevel" to create entities dynamically during the game , how can we free the memory already used to stock them, when the level is over and the "onendlevel" methode is called ?
2) if I use for example the methode "setLevel (pointortolevel2) " during an update methode of a behavior, what happens exactly?
3) is it possible to create another way to exit the game than "escape" ?
58 2011-08-21 18:21:37
Re: access to the mesh bones (12 replies, posted in General)
this time it's works perfectly, thanks a lot
59 2011-08-21 14:58:42
Re: access to the mesh bones (12 replies, posted in General)
there isn't further reaction ...
apparently there are well bones in the .mesh file :
<Bones num="4">
<Bone id="0" name="Bone">
<position x="-2.618241" y="0.000000" z="0.000000" />
<rotation x="89.999992" y="100.106392" z="0.000001" />
<scale x="1.000000" y="1.000000" z="1.000000" />
</Bone>
<Bone id="1" name="Bone.001">
<parent id="0" />
<position x="0.000000" y="1.000094" z="-0.000000" />
<rotation x="5.679412" y="-179.110901" z="19.974031" />
<scale x="1.000000" y="1.000000" z="1.000000" />
</Bone>
<Bone id="2" name="Bone.002">
<parent id="1" />
<position x="0.000000" y="1.355897" z="-0.000000" />
<rotation x="0.072250" y="0.357129" z="24.149242" />
<scale x="1.000000" y="1.000000" z="1.000000" />
</Bone>
<Bone id="3" name="Bone.003">
<parent id="2" />
<position x="0.000000" y="1.801812" z="-0.000000" />
<rotation x="5.126833" y="-0.721032" z="-7.293643" />
<scale x="1.000000" y="1.000000" z="1.000000" />
</Bone>
</Bones>
here is the all .mesh
thanks for helping me
60 2011-08-21 12:23:41
Re: access to the mesh bones (12 replies, posted in General)
Thanks for the answer, I am sorry but it doesn't work, I probably made a mistake in the mesh creation :
in blender :
I created a plane that I subdivided 5-6 times and a single bone that I extruded 3 times.
I selected the plane and the bone and "ctrl+p -> armature deform with empty group".
and for each bone I selected some faces that I assigned to the bone.
and I exported this (mesh + armature) in maratis mesh without "armature anim".
In Maratis :
I imported the mesh and gave to it my behavior
do you see an error somewhere, please ?
61 2011-08-20 12:31:59
Re: access to the mesh bones (12 replies, posted in General)
maybe you can help by studying how to improve the Blender python script exporter
to export Blender shape keys ?
thank you for you fast response
I am afraid it's quite over my faculties, I am sorry.
I made a very basic behavior to test mesh deforming by moving a bone, but the mesh didn't deform itself, can you see where the problem is, please ?
int i =0.0;
void Behavior::update(void)
{
MEngine * engine = MEngine::getInstance();
MGame * game = engine->getGame();if(! game->isRunning())
{
i=0;
return;
}
MOEntity * parent = (MOEntity *) getParentObject();
MVector3 vector;
MVector3 vector2;
MSystemContext * system = engine->getSystemContext();
MInputContext * input = engine->getInputContext();
if(input->isKeyPressed("A"))
{
i++;
if (i>360)
{
i=i-360;
}
vector2.x=i;
vector2.y=i;
vector2.z=0.0;
parent->setEulerRotation(vector2); // this work perfectly
}
if(parent)
{
MMesh* mesh = parent->getMesh();
if(mesh)
{
MArmature * armature = mesh->getArmature();
if(armature)
{
MOBone* bone=armature->getBone(0);
if(bone)
{ // bone has indeed a no NULL adress here
if(input->onKeyDown("MOUSE_BUTTON1"))
{
vector.x=0.0;
vector.y=1.0;
vector.z=1.0;
bone->addAxisAngleRotation(vector,i); // nothing doing here
}
}
}
}
}}
62 2011-08-09 19:49:26
Re: access to the mesh bones (12 replies, posted in General)
Hi, I have other questions about bones and Maratis engine :
suppose we have a MOBone named Bone0, how can we move him (Euler rotation like in Blender Pose mode, for example ) ?
how can we, with maratis Engine, play, stop and change mesh animations ?
and finally, does animations using shape keys work in maratis ?
63 2011-07-09 10:41:23
Re: access to the mesh bones (12 replies, posted in General)
that's perfect, I didn't see the methode "MArmature * getArmature (void) " in the MMesh class,
that's all I wanted to know, thanks
64 2011-07-08 17:01:04
Topic: access to the mesh bones (12 replies, posted in General)
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)
I thought that they were considered like mesh children but they aren't.
66 2011-06-20 16:30:45
Re: [Plugin] LookAt for Entity (5 replies, posted in Engine)
In "SimpleGamePlugin.cpp"
add
behaviorManager->addBehavior(LookAt::getStaticName(), M_OBJECT3D, LookAt::getNew);
is indispensable ? or just optional ?
67 2011-06-15 20:33:50
Re: terrain ? (59 replies, posted in General)
When writing a custom shader, you can use up to 8 textures in total.
That's why you used a 8 case array ?
uniform sampler2D Texture[8];
varying vec2 texCoord[3];
but where must we put the textures ? in blender texture slots ? if it's right, the blend texture is on the first slot and the others the followers ?
if I import the CustomShader in a .txt in blender, is that work ?
and it is possible to make the same trick with normal/specular map ?