Here are some questions/answers I’m compiling. I’m not sure if the xith FAQ would be a better place to put it since it would just clog up the FAQ section, so I am putting them here for now. Hope it helps.
1. How do you set whole mesh transparencies? (I want to make my monsters fade away when they die!)
You’ll need to set Transparency Attributes on the mesh’s appearance and the material’s color target.
To make objects fade away, just change the transparency value during your render loop.
ta = new TransparencyAttributes(TransparencyAttributes.BLENDED, 0.1f );
mat.setColorTarget(Material.DIFFUSE);
app.setTransparencyAttributes(ta);
2. How do you use alpha maps? (How do I use a saw I created that uses textures instead of polygons to show the teeth details?)
This is one way of doing it. You will need to load a texture file that supports the alpha channel. The best format for this is PNG. Load the texture as an alpha texture and set it to the object’s appearance. Then, set transparency attributes to the appearance.
app.setTexture(TextureLoader.tf.getAlphaTexture(filename));
ta = new TransparencyAttributes(TransparencyAttributes.BLENDED, 0.0f );
mat.setColorTarget(Material.DIFFUSE);
app.setTransparencyAttributes(ta);
3. How do you render everything as wireframe?
Set the RenderOptions’ wireframe option to true for the canvas peer.
ro = new RenderOptions();
ro.setOption(Option.ENABLE_WIREFRAME_MODE, true);
cp.setRenderOptions(ro);
4. How do you render just one particular model as wireframe?
Get the model’s appearance and set its appearance’s polygon attributes.
Appearance temp = sh.getAppearance();
PolygonAttributes pa = new PolygonAttributes(
PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0f);
temp.setPolygonAttributes(pa);
5. How do you display an image icon over a character?
Use a Billboard and an appearance to create a new shape which can be made a child of the
character’s branchgroup. Apply the image as a texture to the appearance. A Billboard ensures
that the image is always pointing to the camera.
6. What is a Vertex Shader? How do you use a Vertex Shader in Xith?
A Vertex Shader or Vertex Program is essentially a graphics processing function that lets you change properties of a vertex such as position and color. This can allow you to do deformation, morphing and many other interesting effects. This processing is done by the hardware alleviating the burden on the CPU. To use one in xith, you’ll need to open your vertex shader and parse it into a String. Then use that string and set it as the appearance’s vertex program.
appearance.setVertexProgram(new VertexProgram(strVertexShader));