/*
* GeometryArray.java
*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License Version
* 1.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is available at http://www.sun.com/
*
* The Original Code is the Java 3D(tm) Scene Graph Editor.
* The Initial Developer of the Original Code is Jan Becicka.
* Portions created by Jan Becicka are Copyright (C) 2002.
* All Rights Reserved.
*
* Contributor(s): Jan Becicka.
*
* Created on 14. prosinec 2001, 13:08
*/
package org.jdesktop.j3dedit.scenegrapheditor.sourcecontrol.spec.javax.media.j3d;
import org.jdesktop.j3dedit.scenegrapheditor.sourcecontrol.BeanCodeGenerator;
import org.jdesktop.j3dedit.scenegrapheditor.sourcecontrol.NamePool;
/**
*
* @author Jan Becicka
*/
public class GeometryArray extends BeanCodeGenerator {
/** Creates a new instance of GeometryArray */
public GeometryArray(Object bean, NamePool naming) {
super(bean, naming);
}
/** Override this method, if you want to create parametric constructor constr
*/
protected void createConstructionCode() {
StringBuffer buf = new StringBuffer();
javax.media.j3d.GeometryArray ge = (javax.media.j3d.GeometryArray) bean;
buf.append(getFieldName() + " = new " + beanClassName);
buf.append("(" + ge.getVertexCount() + ", ");
buf.append( ge.getVertexFormat() + ");\n");
constructionCode = buf.toString();
}
protected void createCustomizationCode() {
javax.media.j3d.GeometryArray ge = (javax.media.j3d.GeometryArray) bean;
int format = ge.getVertexFormat();
int len = ge.getVertexCount();
if ((format & javax.media.j3d.GeometryArray.BY_REFERENCE) > 0){
if ((format & javax.media.j3d.GeometryArray.INTERLEAVED) > 0){
customizers.add("setInterleavedVertices(" + createIdentifier(ge.getInterleavedVertices()) + ")");
}
else {
}
}
else {
if ((format & javax.media.j3d.GeometryArray.COORDINATES) > 0 ) {
float array[] = new float[len*3];
ge.getCoordinates(0, array);
customizers.add("setCoordinates(0," + createIdentifier(array) + ")");
}
if ((format & javax.media.j3d.GeometryArray.NORMALS) > 0 ) {
float array[] = new float[len*3];
ge.getNormals(0, array);
customizers.add("setNormals(0," + createIdentifier(array) + ")");
}
if ((format & javax.media.j3d.GeometryArray.COLOR_3) > 0 ) {
float array[] = new float[len*3];
ge.getColors(0, array);
customizers.add("setColors(0," + createIdentifier(array) + ")");
}
if ((format & javax.media.j3d.GeometryArray.COLOR_4) > 0 ) {
float array4[] = new float[len*4];
ge.getColors(0, array4);
customizers.add("setColors(0," + createIdentifier(array4) + ")");
}
if ((format & javax.media.j3d.GeometryArray.TEXTURE_COORDINATE_2) > 0 ) {
float array2[] = new float[len*2];
ge.getTextureCoordinates(0, array2);
customizers.add("setTextureCoordinates(0," + createIdentifier(array2) + ")");
}
if ((format & javax.media.j3d.GeometryArray.TEXTURE_COORDINATE_3) > 0 ) {
float array[] = new float[len*3];
ge.getTextureCoordinates(0, array);
customizers.add("setTextureCoordinates(0," + createIdentifier(array) + ")");
}
}
}
/** Override this method, if you want to have different default instance (e.g. YourNean(10))
* @return instance of bean
*/
protected Object createDefaultInstanceOfBean() {
return new Object();
}
}
|