insert obj into scene from rule?

5717
18
05-27-2015 01:17 PM
MicahTaylor
Occasional Contributor III

I have used the complete_streets rule in a model I have created.  However, I want to use my own street lamps. However, they do not show up.

Here is what I have done so far.

1.  Drag and dropped existing globe street lamp from the "complete_streets" rule into the scene.

2.  Converted the obj into shapes

3.  re-shaped the new shape into the lamp I want (with textures and size)

4.  exported the new shape as an obj into the asset file where the rule is getting its lamps from. (Dir_lamps)

5.  Selected the new obj in the inspector window as the lamp I want to use.

The lamps do not show up.  They appear in the preview window...but not in the scene.

Any ideas?

Thanks.

0 Kudos
18 Replies
DavidWasserman
Occasional Contributor III

Just a side note about OBJ files, they store the file paths to the MTLs with relative path from the OBJ. So if you want to organize your MTLs into a folder (Sketchup can sometimes be gross in that it may not create a folder), you should open up Notepad++ and manually enter in  a few file location relative to the object.

You don't have to, but it is something you CAN do if you want.

Glad things worked out!

David

David Wasserman, AICP
MicahTaylor
Occasional Contributor III

Ok, that makes sense. I did create the model lamp in CE.

Thanks!

0 Kudos
TessOldemeyer
Occasional Contributor

I am having a similar issue loading OBJ models to point locations. I have created a quick CGA rule to apply to the points to load the .obj models I need. In my case, I am hoping to insert fire hydrants to point locations in my scene. I keep receiving an 'unknown asset' error at the point locations. If I add in a texture rule them I receive an 'unknown texture error'. I have made sure the .obj, .mtl, and any .jpg textures are included in the mapped folder.

After having the same issues loading models I had downloaded. I ended up trying to use the fire hydrant in the original Downtown Damage example folder. I have mapped to assets>streets in that folder (the .obj, .mtl, and .jpg images are in the folder) and am still receiving the 'unknown asset' error when I try to load the fire hydrants.

Unknown Asset.JPG

UnknownTexture.JPG

The CGA rule I currently have is:

version "2015.1"

attr myFireHydrantPoints = "C:/Users/gardta/Desktop/Example_Downtown_Damage__2011_2/assets/streets/hydrant.obj"

attr H = 0

@StartRule

Point-->

alignScopeToAxes(y)

s(0,H,0) center(xz)

r(0,rand(360),0)

i(myFireHydrantPoints)

I have also tried calling the asset using the const operation, using comp (f) {all: HydrantTexture} and using a separate rule for texture, and manually editing the .obj and .mtl files. Any suggestions? I am still pretty new to CGA.

Thanks,

Tess

0 Kudos
DavidWasserman
Occasional Contributor III

Hey Tess,

Try using relative path from your assets folder rather than an absolute path.

"streets/hydrant.obj" as an example.

However, if you want to get fancy, use the @File annotation on your attribute so you could pick between different KINDS of fire hydrants if you have another obj (or other similar models).

David

David Wasserman, AICP
0 Kudos
TessOldemeyer
Occasional Contributor

...hmm the relative path didn't seem to do much. I'll keep pecking away at it though. Thanks for the help!


Tess

0 Kudos
DavidWasserman
Occasional Contributor III

Tess,


If you are having trouble, it might be worth playing around with some of asset search functions to get an idea of what the directory you are sourcing from is looking like.

See file search here: http://cehelp.esri.com/help/index.jsp?topic=/com.procedural.cityengine.help/html/cgareference/func_f...

David Wasserman, AICP
0 Kudos
TessOldemeyer
Occasional Contributor

Are the asset search functions performed within a rule? I have been working with a few (i.e. fileSearch, fileExists, and assetInfo) and am not seeing anything being printed. I do not see a CGA console...

Thanks for your help and patience...just learning CE and CGA

Tess

0 Kudos
TessOldemeyer
Occasional Contributor

Well still no luck with the search functions. I was able to get the hydrant shapes in (with a different .obj file and a relative path), but the textures didn't come through correctly. In order to apply the color I was looking for, I ended up using this CGA rule to apply a custom texture:

version "2015.1"

attr myFireHydrantPoints = "assets/FireHydrant/fire hydrant.obj"

attr H=0

attr Texture="assets/FireHydrant/red1.jpg"

@StartRule

Point-->

alignScopeToAxes(y) 

s(0,H,0) center(xz)

r(0,rand(360),0)

i(myFireHydrantPoints)

comp (f) {all: HydrantTexture}

HydrantTexture-->

texture(Texture)

Thanks for the help!

Tess

0 Kudos
DavidWasserman
Occasional Contributor III

Hey Tess,

File search might be a python function, and in retrospect seems a little silly to recommend. I really just wanted to make sure CE knew where your asset was relative to the project folder.

It might be the object, and as far as the textures not coming with the object, remember that obj files are simple containers of coordinates that relate to MTL files. If you have textures make sure the MTL files are in the same relative location as when they were exported.

David

David Wasserman, AICP
0 Kudos