Jump to content
Shadoh

cpp Get Terrain shader at runtime

Recommended Posts

Hey guys, I'm trying to get the shader for adjusting plane clipping values at runtime.

When I do:

 

Material* Mat = terrain->GetMaterial();

 

I get a null reference sad.png

 

What's the correct way of doing that?

 

Also, adding the terrain object to the documentation would be awesome ;)

Share this post


Link to post

I believe, you have to use the surface. The following doesn't yield NULL:

Material* mat = terrain->surface[0]->GetMaterial();

 

Though I have no idea, what the index is for, maybe this can give you a push to the right direction.

Share this post


Link to post

The index is used to access next surface if your model have 2 surfaces, the second one would be surface[1]

Share this post


Link to post

@shadmar

Yeah, but what actually is a surface? Just a group of vertices? If so, what separates the vertices from one surface from those in another one? Are those just user-defined groups of vertices? So why would a terrain have multiple surfaces ("surface" is defined as an array of 5 within the terrain-class, so this isn't something simply inherited)?

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...