<cite>@wezrule said:</cite>
where do you create the terrain variable?
Now that is the interesting question. I’m following the instructions on the page given above regarding the terrain editor. As the instructions say nothing about creating a terrain varible I have no idea how to do that. I took it as read that the necessary variable was created as part of the creating a terrain as given in the instructions.
Somewhere along the lines something went missing in the instructions. There’s something else outside of the instructions I need to to. But what? Create a terrain variable? Then how? How does it link up to the terrain I created in the terrain editor? Do I need to somehow load the scene? Does that then load the terrain with the terrain variable?
What have I missed? Has anyone actually used the terrain editor to create a terrain? If so, how did you load the terrain and get it working?
As normen said, you will have to brush up on Java a bit more and run through some of the tutorials.
I see you are trying to attach the LOD control to the terrain. You need to find the terrain in the scene first. Terrain is just a mesh attached to the scene node. So to find it, you have to dig down in the scene, getting all the children from the root node, and those children, and their children, testing to see if one of them is a Terrain object
if (spatial instanceof Terrain) {
// yay I got the terrain, now I cast the Spatial to Terrain and I have my terrain variable
}
Before you start all of that though, look at the Node class and its getChild(String name) method. Get familiar with it and how it is finding the spatial recursively.
[java]
/**
* getChild returns the first child found with exactly the
* given name (case sensitive.) This method does a depth first recursive
* search of all descendants of this node, it will return the first spatial
* found with a matching name.
*
* @param name
* the name of the child to retrieve. If null, we’ll return null.
* @return the child if found, or null.
*/
public Spatial getChild(String name) {
if (name == null)
return null;
<<As normen said, you will have to brush up on Java a bit more >>
I already know Java, been using for many years now. As far as I can see, this is not a Java problem. So, in an attempt to explain this a bit better:
You have a tutorial that explains how to use the terrian editor - so far so good
Your tutorial then provides an example of how to link up the output from the terrain editor into the code. - it fails
Therefore, the tutorial provides insufficient information. - the tutorial is where the problem lies
I hope you follow that.
<<You need to find the terrain in the scene first. Terrain is just a mesh attached to the scene node. So to find it, you have to dig down in the scene, getting all the children from the root node, and those children, and their children, testing to see if one of them is a Terrain object >>
Now, that’s information that should go in the tutorial. Thanks.
If that is the sort of things that needs to be done to go from designing a terrain in the terrain editor to getting it to work in the code then I would suggest you add that to the tutorial with a working example so we can follow it.