Jump to content

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
Link to comment

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
Link to comment

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.

×
×
  • Create New...