Modify heightField in real time

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Modify heightField in real time

Postby kikosmalltalk » Fri Jun 19, 2009 10:19 am

Hi all

I have a question over the heightfield collision primitive.
I can modify the primitive in real time ?
Or should i create a new primitive ?

Advanced thanks

kiko
kikosmalltalk
 
Posts: 31
Joined: Mon Dec 04, 2006 10:48 am
Location: Argentina

Re: Modify heightField in real time

Postby Leadwerks » Fri Jun 19, 2009 11:49 am

You can modify the heightfield in real-time.
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Modify heightField in real time

Postby kikosmalltalk » Fri Jun 19, 2009 2:30 pm

Hi Leadwerk

Thanks.
I'm looking the samples and the heightfield functions . I not found functions for this.
Please any example or help ?.

Thanks again

kiko
kikosmalltalk
 
Posts: 31
Joined: Mon Dec 04, 2006 10:48 am
Location: Argentina

Re: Modify heightField in real time

Postby JernejL » Fri Jun 19, 2009 3:22 pm

I think the heightfield always uses original data, so you can just change the original data.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Modify heightField in real time

Postby Julio Jerez » Fri Jun 19, 2009 4:08 pm

from the 2.2 SDK file \toolBox\HeightFieldPrimitive.cpp
here is how you can modify hieghtMap in real time

Code: Select all
   NewtonCollisionInfoRecord collisionInfo;
   memset (&collisionInfo, 0, sizeof (NewtonCollisionInfoRecord));
   NewtonCollisionGetInfo (collision, &collisionInfo);
   if (collisionInfo.m_collisionType == SERIALIZE_ID_HEIGHTFIELD) {
          int width;
                int height;
          unsigned short* elevations;

      width = collisionInfo.m_heightField.m_width;
      height = collisionInfo.m_heightField.m_height;

      // this is the elevation data, the application can use this to modify the terrain on the flight
      elevations = collisionInfo.m_heightField.m_elevation;

      // I am am usin elvation data to build a visual mesh
      geometry = new OGLMesh(dMesh::D_STATIC_MESH);
      AddMesh (geometry);
      geometry->Release();
                                         ....
   }
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Modify heightField in real time

Postby kikosmalltalk » Sat Jun 20, 2009 5:13 pm

Hi all

Thanks.
I'm using Truevision3d, this has a TVLandscape object for creation terrain.
The terrain it may be modified in real time

Julio wrote:
from the 2.2 SDK file \toolBox\HeightFieldPrimitive.cpp
here is how you can modify hieghtMap in real time


I want to make the inverse. To modify the TVLandscape in real time and then to use these data in the heightfield of newton.

Delfi wrote:
I think the heightfield always uses original data, so you can just change the original data.


How ?.
Making one new heightfield each time which I modify the Newfoundland.


Advanced thanks

kiko
kikosmalltalk
 
Posts: 31
Joined: Mon Dec 04, 2006 10:48 am
Location: Argentina

Re: Modify heightField in real time

Postby JernejL » Sat Jun 20, 2009 5:48 pm

See the advice julio gave you 1 post up (viewtopic.php?f=9&t=5210#p37152)
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Modify heightField in real time

Postby Aphex » Sat Jun 27, 2009 6:13 am

This is how I modify mine dynamically:

Code: Select all
   const int vertIndex = change.mHtmapY*mHeightMap->Width() + change.mHtmapX;
   NewtonCollisionInfoRecord collisionInfo;
   NewtonCollisionGetInfo(NewtonBodyGetCollision(mPhysicsBody), &collisionInfo);
   collisionInfo.m_heightField.m_elevation[vertIndex] = change.mNewVal;
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: Modify heightField in real time

Postby zorgblaubaer » Thu Aug 06, 2009 5:45 am

hi aphex,

could you explain a bit more detailed how you use this to modify the heightmap? i am new to newton and can only make use of it when i know how this dynamic heightmap modifying works.

thanks in advance!

edit: more detailed my problem is to get a collision from my heightmap so that i can give it as an argument in the NewtonCollisionGetInfo function... or what exactly shall this argument be? the function needs to know which heightmap it should edit, doenst it?
edit2: i figured out how to do it. the heightmap now changes, but its geometry doesnt. how do i do this/ ;((
zorgblaubaer
 
Posts: 10
Joined: Thu Aug 06, 2009 2:16 am

Re: Modify heightField in real time

Postby zorgblaubaer » Fri Aug 14, 2009 6:23 am

i still was not able to find out how the visuals of my heightmap can update together with the collision model.
the collision/heightmap change works nice, but the OGL object stays in its initialization state ;(
zorgblaubaer
 
Posts: 10
Joined: Thu Aug 06, 2009 2:16 am

Re: Modify heightField in real time

Postby JernejL » Fri Aug 14, 2009 7:16 am

zorgblaubaer wrote:i still was not able to find out how the visuals of my heightmap can update together with the collision model.
the collision/heightmap change works nice, but the OGL object stays in its initialization state ;(


This is not a newton problem, you need to rebuild your graphical model's geometry cache.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Modify heightField in real time

Postby zorgblaubaer » Fri Aug 14, 2009 8:07 am

yes, and its working now. thanks!
zorgblaubaer
 
Posts: 10
Joined: Thu Aug 06, 2009 2:16 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron