Jump to content
Carles Olle

How to assign a texture to a 3D object (Solved)

Recommended Posts

This is a question that probably has a simple answer but that, for some reason I cannot manage to get right.

So far I have this code but it does not seem to produce the expected results (the 3D poly-line does not show any texture at all):

 

vs.BeginPoly3D()
vs.Add3DPt((-5, 0, -5))
vs.Add3DPt(( 5, 0, -5))
vs.Add3DPt(( 5, 0,  5))
vs.Add3DPt((-5, 0,  5))
vs.Add3DPt((-5, 0, -5))
vs.EndPoly3D()
image = vs.LNewObj()
textureRef = vs.Name2Index("Test texture")

vs.SetObjExpandTexture(image, 0)
vs.SetTextureRef(image, textureRef, 1)
vs.SetDefaultTexMap(image)

vs.SetTexMapBool(image, 3, 3, True)		# repeat horizontally
vs.SetTexMapBool(image, 3, 4, True)		# repeat vertically
vs.SetTexMapInt(image, 3, 1, 0)			# plane projection
vs.SetTexMapReal(image, 3, 1, 0)		# offset x
vs.SetTexMapReal(image, 3, 2, 0)		# offset y
vs.SetTexMapReal(image, 3, 3, 10)		# scale
vs.SetTexMapReal(image, 3, 4, 0)		# rotation

Why this doesn't work?

Any hint will be appreciated.

 

--Carles

Edited by Carles Olle

Share this post


Link to post

To assign a texture to the 3D object use the vs.SetTextureRefN(obj, textureRef, texPartID, texLayerID), so your script would look like:

 

vs.BeginPoly3D()
vs.Add3DPt((-5, 0, -5))
vs.Add3DPt(( 5, 0, -5))
vs.Add3DPt(( 5, 0,  5))
vs.Add3DPt((-5, 0,  5))
vs.Add3DPt((-5, 0, -5))
vs.EndPoly3D()
image = vs.LNewObj()

textureRef = vs.Name2Index("Test texture")

texPartID = 0
texLayerID = 0
vs.SetTextureRefN(image, textureRef, texPartID, texLayerID)

 In the above the texPartID is the primary and the texLayerID is about the base object (0) or decals(1 and further).

  • Like 1

Share this post


Link to post

Thanks spaghetto for helping!

 

I think one detail is that the texture part for 3D polygons should be 3 (for overall texture part).  HTH

 

  • Like 1

Share this post


Link to post

Dave your right: 3 is overall, but don't know why it also did work with the 0 as texturePart... 

Did a quick backwards test with an extrude and it seems that 3 is overall, 0 are the sides, 4 is the Top and 5 is the Bottom of an extrude.

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.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.


 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...