UserHeightFieldCollision + VehicleMultiBody.

Share with us how are you using the powerrrr of the force

Moderator: Alain

UserHeightFieldCollision + VehicleMultiBody.

Postby Dave Gravel » Tue Oct 07, 2008 6:20 am

It's just a quick test with the VehicleMultiBody and the UserHeightFieldCollision.
No idea if this demo running good with ati card.

http://evadlevarg.googlepages.com/Basic ... hicle2.zip
This is really beta...
Last edited by Dave Gravel on Sat Oct 11, 2008 8:04 am, edited 1 time in total.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: UserHeightFieldCollision + VehicleMultiBody.

Postby Julio Jerez » Fri Oct 10, 2008 12:02 pm

I just tested it but I beleube it is too dark, I can bearlly see anything.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: UserHeightFieldCollision + VehicleMultiBody.

Postby Dave Gravel » Fri Oct 10, 2008 12:34 pm

It's surely because my shader method use to render the terrain.
I need to implement a better way and more compatible.
Just a question do you have test with your nvidia or with a ati ?

Thanks.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: UserHeightFieldCollision + VehicleMultiBody.

Postby Julio Jerez » Fri Oct 10, 2008 2:27 pm

I have an nvidea 8800.
are you using GLSL?
I really liek GLSL, is is so eassy and cool.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: UserHeightFieldCollision + VehicleMultiBody.

Postby Dave Gravel » Fri Oct 10, 2008 2:59 pm

Ok, yes I use GLSL but i'm not so good with it.
I have already use it in the past but only with very simple rendering pass.
I work a on more clean render pass and I upload the demo again later with shader if you like to see it.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: UserHeightFieldCollision + VehicleMultiBody.

Postby Dave Gravel » Sat Oct 11, 2008 8:06 am

Julio, at this link you can find my updated demo.
http://evadlevarg.googlepages.com/Basic ... hicle2.zip

Maybe now this one can work better for you.

Thanks.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: UserHeightFieldCollision + VehicleMultiBody.

Postby Julio Jerez » Sat Oct 11, 2008 8:35 am

This is much more bright, but I think the the ambinet value fo rteh ligh can be a bit hight still, because is is too dark in some place.

Also is this a user terrian or a hight map terrain?

Th edriving fells very nice and smooth. :mrgreen: :mrgreen:
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: UserHeightFieldCollision + VehicleMultiBody.

Postby Dave Gravel » Sat Oct 11, 2008 1:53 pm

My friend say it is dark too, here I see it normally i'm not sure if it depending from my screen config.
The terrain is based on the UserHeightFieldCollision but I loading a bmp data and I use pretty big celling.
The vehicle can behav better with a better terrain configuration about size and celling, this demo is only a quick test size with big celling.

I need to find what is the problem about the light..
The camera need some fix too.
Edited:
Just in case this is my terrain shader.
Code: Select all
procedure TOXNewtonUserHeightField.PrepareShaderVert;
begin
  with FShaderVertStr do begin
    Clear;
    Add('attribute vec3 s_attribute_0;');
    Add('attribute vec4 s_attribute_1;');
    Add('attribute vec4 gl_Vertex;');
    Add('uniform vec3 camera;');
    Add('uniform vec4 lods;');
    Add('varying vec3 lightDir,normal;');
    Add('void main()');
    Add('{');
    Add('  float dist = length(camera-s_attribute_0);');
    Add('  gl_Vertex = vec4(s_attribute_0,1.0);');
    Add('  if(dist>lods.w){');
    Add('    gl_Vertex.y = s_attribute_1.w;');
    Add('  }else');
    Add('  if(dist>lods.z){');
    Add('    float k = (dist-lods.z)/(lods.w-lods.z);');
    Add('    gl_Vertex.y = s_attribute_0.z*(1.0-k)+s_attribute_1.w*k;');
    Add('  }else');
    Add('  if(dist>lods.y){');
    Add('    float k = (dist-lods.y)/(lods.z-lods.y);');
    Add('    gl_Vertex.y = s_attribute_0.y*(1.0-k)+s_attribute_1.z*k;');
    Add('  }else');
    Add('  if(dist>lods.x){');
    Add('    float k = (dist-lods.x)/(lods.y-lods.x);');
    Add('    gl_Vertex.y = s_attribute_0.x*(1.0-k)+s_attribute_1.y*k;');
    Add('  }else{');
    Add('    float k = clamp((dist/lods.x)*2.0-1.0,0.0,1.0);');
    Add('    gl_Vertex.y = s_attribute_0.y*(1.0-k)+s_attribute_1.x*k;');
    Add('  }');
    Add('  gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex;');
    //Add('  gl_Position = ftransform();');
    Add('  gl_TexCoord[0] = gl_MultiTexCoord0;');
    Add('}');
  end;
end;

procedure TOXNewtonUserHeightField.PrepareShaderFrag;
begin
  with FShaderFragStr do begin
    Clear;
    Add('uniform sampler2D tex1;');
    Add('uniform sampler2D tex2;');
    Add('uniform sampler2D tex3;');
    Add('uniform sampler2D tex4;');
    Add('uniform float SplatScale = 40.0f;');
    Add('varying vec3 lightDir,normal;');
    Add('void main()');
    Add('{');
    Add('  vec4 final;');
    Add('  vec4 a1 = texture2D(tex1,gl_TexCoord[0].st);');
    Add('  vec4 a2 = texture2D(tex2,gl_TexCoord[0].st);');
    Add('  vec4 a3 = texture2D(tex3,gl_TexCoord[0].st);');
    Add('  vec4 a4 = texture2D(tex4,gl_TexCoord[0].st);');
    Add('  vec4 color1 = texture2D(tex1,gl_TexCoord[0].st*SplatScale);');
    Add('  vec4 color2 = texture2D(tex2,gl_TexCoord[0].st*SplatScale);');
    Add('  vec4 color3 = texture2D(tex3,gl_TexCoord[0].st*SplatScale);');
    Add('  vec4 color4 = texture2D(tex4,gl_TexCoord[0].st*SplatScale);');
    Add('  final.r = (color1.r*a1.a)+(color2.r*a2.a)+(color3.r*a3.a)+(color4.r*a4.a);');
    Add('  final.g = (color1.g*a1.a)+(color2.g*a2.a)+(color3.g*a3.a)+(color4.g*a4.a);');
    Add('  final.b = (color1.b*a1.a)+(color2.b*a2.a)+(color3.b*a3.a)+(color4.b*a4.a);');
    Add('  final.a = 1.0;');
    Add('  vec4 texel;');
    Add('  float intensity,at,af;');
    Add('  lightDir = normalize(vec3(gl_LightSource[0].position));');
    Add('  intensity = max(dot(lightDir,normalize(normal)),1.0);');
    Add('  texel = texture2D(tex1,gl_TexCoord[0].st);');
    Add('  vec4 ffcol1;');
    Add('  ffcol1 = vec4(vec3(texel.rgb)*vec3(intensity*(gl_FrontMaterial.diffuse).rgb+');
    Add('  gl_FrontMaterial.ambient.rgb),float(texel.a*gl_FrontMaterial.diffuse.a));');
    Add('  gl_FragColor = vec4(final * ffcol1);');
    Add('}');
  end;
end;

And it is apply like this.

    with FTerrainGLSL do begin
      UseProgramObject;
        Uniform1i['tex1']:=0; ApplyMultiTex(0);
        Uniform1i['tex2']:=1; ApplyMultiTex(1);
        Uniform1i['tex3']:=2; ApplyMultiTex(2);
        Uniform1i['tex4']:=3; ApplyMultiTex(3);
        Uniform1f['SplatScale']:=128;
        Uniform3f['camera']:=AbsoluteToLocal(Scene.CurrentGLCamera.AbsoluteAffinePosition);
        Uniform4f['lods']:=VectorMake(5000,5000,5000,5000);
        glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER,FVBOIndices);
        glDrawRangeElements(GL_TRIANGLES,0,FIndiceCount,FIndiceCount,GL_UNSIGNED_INT,nil);
        UnApplyMultiTex;
      EndUseProgramObject;
    end;


Thanks for have test.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.


Return to User Gallery

Who is online

Users browsing this forum: No registered users and 13 guests