OK. This seems WAY over my head.
On Jun 25, 2005, at 4:05 PM, Frank Condello wrote:
That will replace the texel data for each object, but it won't
actually share it! The TextureShader3D.SetTexture method actually
copies the picture you pass to it (too keep things simple I didn't
expose pixmap objects directly in the Quesa wrappers or else something
like that might've been possible).
To share a texture you need to assign the *same* TextureShader3D or
AttributeSet3D object to a your various meshes:
' Create a the textueshader you you wish to share,
' or better yet, use an AttributeSet3D, to share all material
attributes:
Dim mat as AttributeSet3D
Dim tex as TextureShader3D
tex = New TextureShader3D(somePicture, tex.kPixelTypeRGB32)
mat = New AttributeSet3D
mat.SetTextureShader tex
' Set other "mat" attributes if ya like (colors, transparency,
shininess etc.)
' Now apply "mat" to all the objects you want to share the same
material
UpdateObjTexture(obj, mat)
UpdateObjTexture(obj2, mat)
' ... etc ...
The update method would look something like this:
Sub UpdateObjTexture(obj As Object3D, mat As AttributeSet3D)
Dim tmsh as Trimesh3D
tmsh = obj.GetFirstTrimeshInShape(i)
if tmsh <> Nil then
tmsh.SetMaterial mat
end if
End Sub
Iterating through each Object3D shape and each trimesh in each shape
isn't much more work, but keep in mind that the 3DMF format can be a
little slippery at times. Textureshader objects can be placed inside
display groups to affect all the geometry in that group (same with
attribute sets). So although you're replacing the trimesh texture,
there may be a stray textureshader or attribute set in the 3DMF data
that no longer affects the final render, but still gets uploaded to
hardware wasting VRAM/RAM and CPU/GPU resources. This would occur if
you used the above method on an object shape created with
AddShapePicture for example. To be safe, you should first run through
all the shape's display groups and delete any stray texture shaders
and attribute sets. That's a bit more work, but the 3DMF format is
unpredictable and often requires special attention.
HTH!
Frank.
============
Daniel R. Lurie
============
http://www.vikingdan.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|