seriously learnig NGD

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

Moderator: Alain

Re: seriously learnig NGD

Postby JernejL » Sun Jul 18, 2010 5:49 pm

Use a trimesh for geometry like that, you can use heightmap if you use real terrain, but trimeshes will be ok for most buildings & objects you need.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: seriously learnig NGD

Postby coimbra79 » Sun Jul 18, 2010 7:00 pm

NewtonWiki watching on, I guess at the page :arrow: http://newtondynamics.com/wiki/index.php5?title=NewtonTreeCollisionBeginBuild , there is an error in the session parameters same for NewtonTreeCollisionEndBuild and NewtonTreeCollisionAddFace ...
NewtonTreeCollisionBeginBuild(const NewtonCollision* treeCollision), NewtonTreeCollisionEndBuild( const NewtonCollision* treeCollision, int optimize) and NewtonTreeCollisionAddFace (..., ...), dont want newtonworld pointer, want instead (i think) a pointer to tree collision i before created using NewtonCreateTreeCollision (const NewtonWorld* newtonWorld); - - - eg.

-mapCollision = NewtonCreateTreeCollision (NW)
-NewtonTreeCollisionBeginBuild mapCollision
-----for CurrentFace = 0 to totFaces-1
---------NewtonTreeCollisionAddFace mapCollision,4,arrayFace(CurrentFace).Vertex(0),12,totGlobalFaces
---------totGlobalFaces=totGlobalFaces+1 'put unique id for current face
-----next
-NewtonTreeCollisionEndBuild mapCollision
Last edited by coimbra79 on Sun Jul 18, 2010 7:26 pm, edited 2 times in total.
User avatar
coimbra79
 
Posts: 42
Joined: Sun Jun 27, 2010 1:39 pm

Re: seriously learnig NGD

Postby coimbra79 » Sun Jul 18, 2010 7:02 pm

:D :D did I studied? :D :D

Helped you improving the Newton Game Dynamics WIKI
User avatar
coimbra79
 
Posts: 42
Joined: Sun Jun 27, 2010 1:39 pm

Re: seriously learnig NGD

Postby JernejL » Mon Jul 19, 2010 3:58 am

You are doing it wrong, do it in this order:

1. NewtonCreateTreeCollision
2. NewtonTreeCollisionBeginBuild
3. NewtonTreeCollisionAddFace (for each face)
4. NewtonTreeCollisionEndBuild (finalize and optimize the mesh shape)
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: seriously learnig NGD

Postby coimbra79 » Mon Jul 19, 2010 7:00 am

Delfi wrote:You are doing it wrong, do it in this order:

1. NewtonCreateTreeCollision
2. NewtonTreeCollisionBeginBuild
3. NewtonTreeCollisionAddFace (for each face)
4. NewtonTreeCollisionEndBuild (finalize and optimize the mesh shape)


what is the difference between mine and yours :?: :!: I'm sorry, I do not see ...

I certainly something wrong, I need your help, because the tests I've run do not work
I also read your other discussions on the subject, but I still have some questions eg:

void NewtonTreeCollisionAddFace (treeCollision, vertexCount, :?: vertexPtr :?: , strideInBytes, faceAttribute);
for vertPointer is good a structure like this?

VertArray(totVertexzInCurrentFace).Vertex(3) ... where ...
VertArray(0).Vertex(0) = 1st vertex x coo in current Face
VertArray(0).Vertex(1) = 1st vertex y coo in current Face
VertArray(0).Vertex(2) = 1st vertex z coo in current Face
- - -
VertArray(1).Vertex(0) = 2nd vertex x coo in current Face
VertArray(1).Vertex(1) = 2nd vertex y coo in current Face
VertArray(1).Vertex(2) = 2nd vertex z coo in current Face
- - - etc...

very tnks!
User avatar
coimbra79
 
Posts: 42
Joined: Sun Jun 27, 2010 1:39 pm

Re: seriously learnig NGD

Postby JernejL » Mon Jul 19, 2010 9:31 am

there is an error in the session parameters same for NewtonTreeCollisionEndBuild and NewtonTreeCollisionAddFace ...


What does that mean? what is a error in session parameters?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: seriously learnig NGD

Postby coimbra79 » Mon Jul 19, 2010 10:07 am

Delphi, very sorry, probably my English is not the best. what want tell is that simply I noticed that in newtonwiki there are probably Errors in Part explaining parameters, infact, NewtonTreeCollisionBeginBuild(), NewtonTreeCollisionAddFace() and NewtonTreeCollisionEndBuild() unwilling parameter pointer NewtonWorld, but pointer to treeCollision. look in wiki for parameters explanation in this functions and tell me if they are right...

Image
User avatar
coimbra79
 
Posts: 42
Joined: Sun Jun 27, 2010 1:39 pm

Re: seriously learnig NGD

Postby Carli » Mon Jul 19, 2010 11:19 am

You have to create a newton world context before you do anything with newton.
Carli
 
Posts: 245
Joined: Fri Oct 02, 2009 5:28 am

Re: seriously learnig NGD

Postby coimbra79 » Mon Jul 19, 2010 12:02 pm

Thanks Charles, but I'm already quite advanced for the suggestion you gave me.
The reference to the NW is passed to the physics engine, calling
NewtonCreateTreeCollision (NewtonWorld)
functions as following:
NewtonTreeCollisionBeginBuild, NewtonTreeCollisionAddFace, NewtonTreeCollisionEndBuild need only reference to the newly generated treeCollision inheriting the NewtonWorld
... It's amazing how no one, despite my remarks, still has not noticed the bug in the wiki pages.
(Ps I changed the reference image error)
User avatar
coimbra79
 
Posts: 42
Joined: Sun Jun 27, 2010 1:39 pm

Re: seriously learnig NGD

Postby JernejL » Mon Jul 19, 2010 1:18 pm

I cannot give you any credit for being very clear on what was actually wrong on the wiki, what you meant was, that those functions are documented as taking a newtonworld parameter where it's actually collision shape.. the bug was only in parameter lists, and not in the actual function definition. Additionally to that, the shapeid was missing in NewtonCreateTreeCollision function, which i also corrected.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: seriously learnig NGD

Postby coimbra79 » Mon Jul 19, 2010 1:43 pm

wow, finally! Thanks Delfi! was becoming a chore. JJ advised me, to look NewtonWiki as a complete reference for all aspects of Newton. this is true ... everything I've done since now, thanks to a few examples, this forum and most of all the NewtonWiki!
I never imagined that NewtonCreateTreeCollision missing a parameter, surely that's why it did not work ... Now I try it now!
At Work! :wink:

apologize for having called you 'Delphi'
________________________________________________________________________
I Helped you to improve NewtonWiki
User avatar
coimbra79
 
Posts: 42
Joined: Sun Jun 27, 2010 1:39 pm

Re: seriously learnig NGD

Postby coimbra79 » Mon Jul 19, 2010 5:33 pm

After creating a TREECOLLISION, SHOULD I USE NEWTONCREATEBODY OR WHAT ?
User avatar
coimbra79
 
Posts: 42
Joined: Sun Jun 27, 2010 1:39 pm

Re: seriously learnig NGD

Postby JernejL » Mon Jul 19, 2010 5:39 pm

No problem, also you can edit the wiki too. I know it is not yet perfect, but we keep improving it!
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: seriously learnig NGD

Postby coimbra79 » Thu Jul 22, 2010 8:42 pm

coimbra79 wrote:
Delfi wrote:You are doing it wrong, do it in this order:

I certainly something wrong, I need your help, because the tests I've run do not work
I also read your other discussions on the subject, but I still have some questions eg:

void NewtonTreeCollisionAddFace (treeCollision, vertexCount, :?: vertexPtr :?: , strideInBytes, faceAttribute);
for vertPointer is good a structure like this?

VertArray(totVertexzInCurrentFace).Vertex(3) ... where ...
VertArray(0).Vertex(0) = 1st vertex x coo in current Face
VertArray(0).Vertex(1) = 1st vertex y coo in current Face
VertArray(0).Vertex(2) = 1st vertex z coo in current Face
- - -
VertArray(1).Vertex(0) = 2nd vertex x coo in current Face
VertArray(1).Vertex(1) = 2nd vertex y coo in current Face
VertArray(1).Vertex(2) = 2nd vertex z coo in current Face
- - - etc...

very tnks!


an answer plz! :roll:
User avatar
coimbra79
 
Posts: 42
Joined: Sun Jun 27, 2010 1:39 pm

Re: seriously learnig NGD

Postby coimbra79 » Fri Jul 23, 2010 8:54 am

solved!
all those who may need this information:
in VB6 the vertexpnt () must be a list containing all the coordinates of the vertices of the face to add, as in figure (I am one of the blackboard)
Image
so... vb comlete code sample to build treemesh (adapted from coiAxis*)
Code: Select all
____________________________________________________________
'loadedMap is an object whit an array of face containing pointers to vertex array into object (coiAxis*)
map = NewtonCreateTreeCollision(NW, 0)
    NewtonTreeCollisionBeginBuild map
        For tFaces = 0 To loadedMap.Totfaces - 1 'for each face into mesh i loaded
            For TVertx = 0 To 3 'fixed in this case only
                'i use mid to be sure to take 5 bytes for each vertex coordinates : -1.123456 ll'become -1.12
                VertPntr(ind) = Mid(loadedMap.ArrayVert(loadedMap.ArrayFace(tFaces).IndVert(TVertx)).x, 1, 5): ind = ind + 1
                VertPntr(ind) = Mid(loadedMap.ArrayVert(loadedMap.ArrayFace(tFaces).IndVert(TVertx)).y, 1, 5): ind = ind + 1
                VertPntr(ind) = Mid(loadedMap.ArrayVert(loadedMap.ArrayFace(tFaces).IndVert(TVertx)).z, 1, 5): ind = ind + 1
            Next
            NewtonTreeCollisionAddFace map, 4, VertPntr(0), 15, totGlobFaces
            ind = 0 ' reset vertex array pointer for next face cicle
            totGlobFaces = totGlobFaces + 1
        Next
    NewtonTreeCollisionEndBuild InscrMappa, 1

    ReDim Preserve NewtonObjs(totNewtoObjs)
    NewtonObjs(totNewtoObjs).NewtonBody = NewtonCreateBody(newtonWorld, InscrMappa)
    NewtonReleaseCollision newtonWorld, InscrMappa
    NewtonBodySetMassMatrix NewtonObjs(totNewtoObjs).NewtonBody, 0, 0, 0, 0    'its a static floor
__________________________________________________________

:wink:
User avatar
coimbra79
 
Posts: 42
Joined: Sun Jun 27, 2010 1:39 pm

PreviousNext

Return to User Gallery

Who is online

Users browsing this forum: No registered users and 19 guests