Object Hierarchy | Related C++ Class: ImageClip2
ImageClip
v2.0
The ImageClip object represents an instance of an Image Source, which in turn is a reference to an image
stored on disk. ImageClips and Image Sources are used as a means of
introducing images into FxTrees, or as
textures influencing Shaders. Image clips
are created by calling AddImageClip or CreateImageClip.
Important information such as the File path and resolution are
stored as Parameters of the Image
Source, which can be retrieved by calling
Clip.Source. You can read the pixel
values of the image by calling ImageClip.GetImage.
' ' This example illustrates how to create an ImageClip object and connect it ' as the source of an image texture. ' NewScene , false set oImage = AddImageSource( "$SI_HOME\Data\XSI_SAMPLES\Pictures\jio.jpg" ) set oImageClip = AddImageClip( oImage ) set oSphere = ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface" ) set oMaterial = oSphere.AddMaterial("Phong") set oPhong = oMaterial.Surface.Source set oColor8Mix1 = oPhong.ambient.ConnectFromProgID("Softimage.sib_color_8mix.1") set oColor8Mix2 = oPhong.diffuse.ConnectFromProgID("Softimage.sib_color_8mix.1") set oTex2D = oColor8Mix1.color1.ConnectFromProgID("Softimage.txt2d-image-explicit.1") call oColor8Mix2.color1.Connect(oTex2D) set oTex2D.tex.Source = oImageClip |
/* This example illustrates how to retrieve the image file name used for the texture of an object. It also illustrates how to retrieve the x and y resolution of that image. */ var oCube = CreatePrim("Cube", "MeshSurface", null, null); ApplyShader(null, null, null, siUnspecified, siLetLocalMaterialsOverlap); CreateProjection("cube", siTxtSpherical, siTxtDefaultSpherical, "", "Texture_Projection", null, siRelDefault, ""); BlendInPresetsInsp(null, null, null, true, siReplaceAndBlendInPreset, null, null, null, null); var oImageClip = oCube.Material.CurrentImageClip; var oImageSource = oImageClip.Source; LogMessage("The image filename is " + oImageSource.Parameters("FileName").Value); LogMessage("The image x resolution is " + oImageSource.Parameters("XRes").Value); LogMessage("The image y resolution is " + oImageSource.Parameters("YRes").Value); // Expected result: //INFO : "The image filename is <$factory>\Application\rsrc\noIcon.pic" //INFO : "The image x resolution is 256" //INFO : "The image y resolution is 256" |