How to create a rule for placing trees using points.shp?

3025
2
10-28-2014 07:03 AM
aTomasaLooström
New Contributor

Hi,

I haveshape points with type and height for individual trees.

I would like to know how to write a rule that I can use to place the .obj models using
the attributes from the shape-file. The points are loaded in CE at their right
locations.

I manage to
get the right height and rotate them use this rule from the forum, but I get
Unknown Texture… The mtl is in the assets folder.

attr Hojd = 0

attr TREETYPE = "Witch_Hazel_Model_0" 

cowTex =  ("assets/Trad/Witch_Hazel_Model.mtl")

getAssetPath =  ( "assets/Trad/" + TREETYPE + "/Witch_Hazel_Model_0.obj"

 

@StartRule 

TREE --> 

    alignScopeToAxes(y) 

    s(0,Hojd,0) center(xz)

    r(0,rand(360),0)

    i(getAssetPath)

    texture(cowTex)

    Tree. 

Best regards Tomas

Tags (4)
0 Kudos
2 Replies
by Anonymous User
Not applicable

First, omit the line "texture(cowTex)", since the model should have textures applied - the i() operation is all you need to get the textures.

Next, make sure the  file "Witch_Hazel_Model.mtl" is in the same folder as the "Witch_Hazel_Model_0.obj"

This brings up another possible problem. I notice your OBJ file is "Witch_Hazel_Model_0.obj", but the texture file does not have"_0.mtl" at the end. That may or may not indicate a problem. Open the OBJ file in a text editor, and search for the string "Witch_Hazel_Model" (a few searches until you find reference to the ".mtl" material file). Does it say "_0.mtl" or  just ".mtl" at the end? What needs to happen is that the OBJ file must find its texture file.  I'm seeing a possible path problem, and a possible naming problem here. Try those and let me know.

Chris

0 Kudos
aTomasaLooström
New Contributor

Tanks for quick respons:)

I am new to programming, learning by the CE tutorials and at the same time building developments models at the goverment at Gotland, Sweden...

I found this rule that I manage to change it and to work as well:

attr TRAD = ("assets/Trad2/Witch_Hazel_Model_0.obj") 

attr Hojd = 0

@StartRule 

Point --> 

alignScopeToAxes(y)  

s(0,Hojd,0) center(xz)

r(0,rand(360),0) 

i(TRAD) 

/Tomas

0 Kudos