How to make Newtonmesh from ID3DXmesh ?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: How to make Newtonmesh from ID3DXmesh ?

Postby Dave Gravel » Wed Mar 17, 2021 7:13 pm

I think this is the last driver and it say gl 3.1
https://downloadmirror.intel.com/24970/eng/ReleaseNotes_GFX_15.28.24.4229.pdf
https://downloadcenter.intel.com/product/81500/Intel-HD-Graphics-3000

If you have this last driver try to use this commands in the sdk for set gl 3.1 enabled.
It work for me, If you have this driver it is supposed to work for you too.
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
glfwWindowHint(GLFW_CONTEXT_NO_ERROR, GLFW_TRUE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE);
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: How to make Newtonmesh from ID3DXmesh ?

Postby Enclave » Thu Mar 18, 2021 7:23 am

According to the table from wikipedia, the core i5 520M supports opengl 2.1. This is a mobile processor for laptops. Fifth generation (Gen5).

So, Intel HD Graphics 3000 it is not compatible driver.

These are the errors in the debug window:

Code: Select all
Exception thrown at 0x757CC54F in ndSandbox.exe: Microsoft C ++ exception: __GLnsGlsl :: TraverserException at memory location 0x00875FB0.
The fragment shader uses varying posit, but geometry shader does not write to it.
The fragment shader uses varying lightDir, but geometry shader does not write to it.
The fragment shader uses varying uv, but geometry shader does not write to it.
ERROR: 0:14: 'location': syntax error parse error

ERROR: 0:13: 'location': syntax error parse error

The thread 0x12c0 has exited with code 0 (0x0).


With your opengl parameters, we get the following message:
Attachments
opengl.jpg
opengl.jpg (71.52 KiB) Viewed 7735 times
Enclave
 
Posts: 81
Joined: Wed May 01, 2013 6:00 am

Re: How to make Newtonmesh from ID3DXmesh ?

Postby Dave Gravel » Thu Mar 18, 2021 1:35 pm

From what I have read this driver is compatible but maybe i'm wrong. In the pdf they talk about 3000, 2000, and a lot more.

In other forum some users say to have get support for gl 3.0 3.1 and incomplet 3.2 driver with the 520M

My last gl parameters is only compatible if you have this driver.

I see the shader error and I understand how to fix it with older shader commands. But it can become boring to always change the shader and the render code anytime that you download a new sdk version. :( Some demo in the sdk can become complex to reproduce with older shader too.
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: How to make Newtonmesh from ID3DXmesh ?

Postby Enclave » Thu Mar 18, 2021 4:00 pm

I tried running this driver, it displays an error and fails to install. :(

Can you explain how to fix the shaders in Newton 4? I'll try the test how it works.

And little about Newton 3.14.
Is it possible to replace the NewtonMeshAddFace function?
At the beginning of this thread there was a working solution that I used earlier, but in newton 3.14 the NewtonMeshAddFace function was removed as "deprecated". A strange decision, of course, for me.

Newton's code is quite complex, so this is a problem for me. I need to continue my project, but I'm stumped.
Enclave
 
Posts: 81
Joined: Wed May 01, 2013 6:00 am

Re: How to make Newtonmesh from ID3DXmesh ?

Postby Dave Gravel » Thu Mar 18, 2021 5:02 pm

It is hard to say all things that you need to change without having old video card for test.
I have already see a old OpenGL32.dll for emulate old gl code but I don't find the link for test.

First of all you need to change the version in the shaders because it using #version 330
The layout location method is not present in old shader, You need to change this for sure.
Normally old shader use attribute and varying variable name.
If your shader version don't support in and out variable and if you use attribute, It can surely request some little changes in the gl buffer creation too.

You can maybe try this command glGetString(GL_SHADING_LANGUAGE_VERSION);
I think your shader version is 1.2, It can help to find all specification on internet for your shader version.
It can help to find all difference, But it's not a simple task for me because I have nothing for test.

I can try to find the old opengl emulator in the week-end to see if I can help with it.
If you find a other solution just to let's me know.

Do you have try to set my parameters with your gl version ?
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);

Edited:
I have find the dll emulator for rendering old opengl in software but it don't work for me.
https://fdossena.com/?p=mesa/index.frag
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: How to make Newtonmesh from ID3DXmesh ?

Postby Dave Gravel » Thu Mar 18, 2021 6:51 pm

It is 2021 maybe it's the time to think about a system upgrade :D

Old opengl is good but it start to cause problem when you try to make faster rendering.

When you make a simulation with many 3d objects it start to become important to use new gl features.
It is not very fun to make a simulation when the graphics use all ressources and it slowdown the simulation.
New gl features is important when you have 1000 objects in a scene or more.
I think it is very important for newton 4 to use newer gl features.
It is a lot more important if Julio start to use opencl solver.

Using old opengl in newer physics engine is something like trying to use tesla electric motor inside very old car. It can work but you are at risk to have a lot problems with less performance.
It can maybe have good performance but the car chassis is at risk to become broken and lost some parts on the road. The old car is not make for supporting this new motor and speed.

Opengl 3.2 or 3.3 is very a minimum to have in this days and it is already old now.

PS: If you invert the situation with a old gas motor in a new electric car chassis this just make no sense hehe.
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: How to make Newtonmesh from ID3DXmesh ?

Postby Enclave » Fri Mar 19, 2021 8:03 am

Dave Gravel wrote:Do you have try to set my parameters with your gl version ?


Yes, I've tried it, it doesn't work.

All I need from Newton is a Player Controller, and interaction with dynamic bodies.
Therefore, for me it does not matter at all what version it will be 3 or 4.

But it is important for me that I can work with meshes, and now, at the moment I cannot do this.

I started with Newton 2, then switched to version 3 in the hope of getting rid of glitches and problems, it did not help, and now there is a new version, Newton 4. And of course, new glitches. And this process will never end. I'm not sure if I need it now.

I think the best option is to write a replacement for the NewtonMeshAddFace function and use the 3.14 engine.
Enclave
 
Posts: 81
Joined: Wed May 01, 2013 6:00 am

Re: How to make Newtonmesh from ID3DXmesh ?

Postby Julio Jerez » Fri Mar 19, 2021 12:06 pm

Enclave wrote:I started with Newton 2, then switched to version 3 in the hope of getting rid of glitches and problems, it did not help, and now there is a new version, Newton 4. And of course, new glitches. And this process will never end. I'm not sure if I need it now.

I think the best option is to write a replacement for the NewtonMeshAddFace function and use the 3.14 engine.


I am sorry I led you on a wild goose chase by suggesting going to 4.0
I did not know you hardware was not read, you are right you do not need to upgrade hardware.

The reason the demos do not run is that in 3.xx we use opengl fix pipe line, and by the end we use some limited shader. for 4.0 to present that date effiecntlly we have to use featire that are no supported but the fix pipe line, I try to go as far back as I could, and the intance for example start with gl 3.xx
I am sorry about that.

the reason I recomended newton4, and I still do, is that the things you are complaining (gliches) has been resolved, for example, teh player capsule in newton 4 is a body that interact with the environment the way you are asking, and so are those other issues.

but in any case if you wnat to keep with 3.14 and your main problem is that you want to build a newton mesh form a DX11 mesh, ther is a generic test in 3.14 called UsingNewtonMeshTool.cpp


Code: Select all
// create a mesh using the dNewtonMesh wrapper
static NewtonBody* CreateSimpledBox_dNetwonMesh(DemoEntityManager* const scene, const dVector& origin, const dVector& scale, dFloat mass)
{
   dVector array[8];
   dVector scale1(scale);
   for (int i = 0; i < 8; i++) {
      dVector p(&BoxPoints[i * 4]);
      array[i] = scale1 * p;
   }

   dNewtonMesh buildMesh(scene->GetNewton());

   // start build a mesh
   buildMesh.BeginBuild();

   // add faces one at a time
   int index = 0;
   const int faceCount = sizeof (faceIndexList)/sizeof (faceIndexList[0]);
   for (int i = 0; i < faceCount; i ++) {
      const int indexCount = faceIndexList[i];
      const int faceMaterail = faceMateriaIndexList[i];

      buildMesh.BeginPolygon();
      for (int j = 0; j < indexCount; j ++) {
         // add a mesh point
         int k = BoxIndices[index + j];
         buildMesh.AddPoint(array[k].m_x, array[k].m_y, array[k].m_z);

         // add vertex normal
         int n = faceNormalIndex[index + j];
         buildMesh.AddNormal (dFloat32 (normal[n * 3 + 0]), dFloat32 (normal[n * 3 + 1]), dFloat32 (normal[n * 3 + 2]));

         // add face material index
         buildMesh.AddMaterial(faceMaterail);

         // continue adding more vertex attributes of you want, uv, binormal, weights, etc
      }
      buildMesh.EndPolygon();
      index += indexCount;
   }
   buildMesh.EndBuild();

   // get the newtonMesh from the dNewtonMesh class and use it to build a render mesh, collision or anything
   NewtonMesh* const newtonMesh = buildMesh.GetMesh();

   // test collision tree
   //NewtonCollision* const collisionTree = NewtonCreateTreeCollisionFromMesh (scene->GetNewton(), newtonMesh, 0);
   //NewtonDestroyCollision(collisionTree);

   // now we can use this mesh for lot of stuff, we can apply UV, we can decompose into convex,
   NewtonCollision* const collision = NewtonCreateConvexHullFromMesh(scene->GetNewton(), newtonMesh, 0.001f, 0);

   // for now we will simple make simple Box,  make a visual Mesh
   DemoMesh* const visualMesh = new DemoMesh(newtonMesh, scene->GetShaderCache());

   dMatrix matrix(dGetIdentityMatrix());
   matrix.m_posit = origin;
   matrix.m_posit.m_w = 1.0f;

   NewtonBody* const body = CreateSimpleSolid(scene, visualMesh, mass, matrix, collision, 0);
   //dVector veloc (1, 0, 2, 0);
   //NewtonBodySetVelocity(body, &veloc[0]);

   visualMesh->Release();
   NewtonDestroyCollision(collision);

   return body;
}


basically every operation is with in a begin/end block
for example teh pseudo code for buidl a mesh is this

Code: Select all
   begionBuild()
       //for each polygon
       beginPoygon()
            // for each vertex of a polygon
            AddPoint()
            AddNormal()
            Adduv()
            ...
       enmdPolygon()
   endBuild()
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: How to make Newtonmesh from ID3DXmesh ?

Postby Enclave » Fri Mar 19, 2021 3:41 pm

Julio Jerez wrote:the reason I recomended newton4, and I still do, is that the things you are complaining (gliches) has been resolved, for example, teh player capsule in newton 4 is a body that interact with the environment the way you are asking, and so are those other issues.


Julio, you may remember that I had problems with the Player Controller and its interaction with dynamic bodies in version 3.04.
Are they still not fixed in version 3.14?

If so, then I don't even know what to do. It is a good idea to use Newton 4, but then I will try to solve the issue of starting the engine on my system with an old version of shaders.
Enclave
 
Posts: 81
Joined: Wed May 01, 2013 6:00 am

Re: How to make Newtonmesh from ID3DXmesh ?

Postby Julio Jerez » Fri Mar 19, 2021 4:20 pm

can you run 3.14?
there is a play controller working there.

There is one thing, the engine does no rely on open gl for anything. if you integrate newton 4 is should work in you system, you not not jut going to be able to run the demos.

what I can do for you is that I can play a demo of the player controller in 4.0 and make a video so that you see how it interact with the environment.
the player capsule, trigger and few other objects are now core native objects in newton 4.
you make then the same way you make a rigid body or a collision shape.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: How to make Newtonmesh from ID3DXmesh ?

Postby Enclave » Fri Mar 19, 2021 7:02 pm

Julio Jerez wrote:can you run 3.14?
there is a play controller working there.


Yes of course. demo 3.14 works for me.

The problem is because newton 4 using newer gl shader features for the render pass. GL 3.2 is request at minimum for run this shaders. Exemple for get some new gl features like instancing objects and bones animation shader.


Perhaps we have a misunderstanding. :x
The problem is not that I cannot run the demo. I also have a desktop where it should definitely work (but I'll check it out yet).

I understood this to mean that Newton 4 would not be able to work on my system. It turns out that this is a delusion.

If the new engine 4 can work on my system, then my render engine will be able to display all of its physics and meshes.
Enclave
 
Posts: 81
Joined: Wed May 01, 2013 6:00 am

Re: How to make Newtonmesh from ID3DXmesh ?

Postby Julio Jerez » Fri Mar 19, 2021 8:12 pm

Enclave wrote:The problem is because newton 4 using newer gl ...

I understood this to mean that Newton 4 would not be able to work on my system. It turns out that this is a delusion.

If the new engine 4 can work on my system, then my render engine will be able to display all of its physics and meshes.


Yes the engine does not uses opengl for anything.
Only the sdkSamboxDemos use it for rendering.
If you have access to a compute that can run the demos, ease try it out, there are two demos in the new engine that use player controls and both of the have interations with other players and the environment.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: How to make Newtonmesh from ID3DXmesh ?

Postby Enclave » Sat Mar 20, 2021 3:36 pm

Julio Jerez wrote:emos use it for rendering.
If you have access to a compute that can run the demos, ease try it out, there are two demos in the new engine that use player controls and both of the have interations with other players and the environment.


Great, I tested the demo on the desktop. Everything works well. (Some demos are not working, but the PlayerCapsule is fine).

I looked at the PlayerCapsule code, it looks easier to implement than version 3.
There are no questions here yet.

But, how to work with meshes in Newton 4?

Please give me a starting point. In version 3 it was UsingNewtonMeshTool.cpp.
And which one here? I read your post on working with meshes in 3.14.
Enclave
 
Posts: 81
Joined: Wed May 01, 2013 6:00 am

Re: How to make Newtonmesh from ID3DXmesh ?

Postby Julio Jerez » Sat Mar 20, 2021 4:45 pm

Enclave wrote:Great, I tested the demo on the desktop. Everything works well. (Some demos are not working, but the PlayerCapsule is fine).
I looked at the PlayerCapsule code, it looks easier to implement than version 3.
There are no questions here yet.

that's what I was saying, newton 4 is meant to be simpler to used.

for building a mesh in newton, that's also easier, here is an example that build a quad from a vertex list index list array.
Code: Select all
void BuildFlatPlane1(ndDemoEntityManager* const scene, bool optimized)
{
   ndMeshEffect meshEffect;

   dVector floor[] =
   {
      { 100.0f, 0.0f,  100.0f, 1.0f },
      { 100.0f, 0.0f, -100.0f, 1.0f },
      { -100.0f, 0.0f, -100.0f, 1.0f },
      { -100.0f, 0.0f,  100.0f, 1.0f },
   };
   dInt32 index[][3] = { { 0, 1, 2 },{ 0, 2, 3 } };

   meshEffect.BeginBuild();
   for (dInt32 i = 0; i < 2; i++)
   {
      meshEffect.BeginBuildFace();
      for (dInt32 j = 0; j < 3; j++)
      {
         dFloat64 x = floor[index[i][j]].m_x;
         dFloat64 y = floor[index[i][j]].m_y;
         dFloat64 z = floor[index[i][j]].m_z;
         meshEffect.AddPoint(x, y, z);

         // you can add these other face attributes
         //AddLayer(dInt32 layer);
         //AddMaterial(dInt32 materialIndex);
         //AddNormal(dFloat32 x, dFloat32 y, dFloat32 z);
         //AddBinormal(dFloat32 x, dFloat32 y, dFloat32 z);
         //AddVertexColor(dFloat32 x, dFloat32 y, dFloat32 z, dFloat32 w);
         //AddUV0(dFloat32 u, dFloat32 v);
         //AddUV1(dFloat32 u, dFloat32 v);
      }
      meshEffect.EndBuildFace();
   }
   meshEffect.EndBuild(0.0f);
}


once you see the mechanic, you can add the materials, uvs and normals.
ther are no equivalent to UsingMeshTool demo, but there is a fbx parcel that convert from fbx to dMeshEffect.
if you find it hard, I can make a using mesh tool demo that make a cube just like in 3.xx
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: How to make Newtonmesh from ID3DXmesh ?

Postby Enclave » Wed Mar 24, 2021 9:34 am

Now I'm trying to create a mesh from ID3DXMesh. I think I figured out how it works.

In 3.14 there were functions

Code: Select all
NewtonMesh * NewtonMeshSimplify (...);

NewtonMesh * NewtonMeshApproximateConvexDecomposition (...);

In version 4.0, I found similar analogs in the source code

Code: Select all
ndMeshEffect * CreateSimplification (...)

ndMeshEffect * CreateConvexApproximation (...)

But they are commented out.

There is no analogue of this function at all. (but there is ndShapeInstance* CreateConvexCollision(...))

Code: Select all
NewtonCollision * NewtonCreateCompoundCollisionFromMesh (...)

All these functions were previously used by me to simplify the mesh and then to create a (dynamic?) body based on this collision.

Is this the correct way in version 4.0?
How to work with it now?
Enclave
 
Posts: 81
Joined: Wed May 01, 2013 6:00 am

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 5 guests