001: /*
002: * GeometryArray.java
003: *
004: * Sun Public License Notice
005: *
006: * The contents of this file are subject to the Sun Public License Version
007: * 1.0 (the "License"). You may not use this file except in compliance with
008: * the License. A copy of the License is available at http://www.sun.com/
009: *
010: * The Original Code is the Java 3D(tm) Scene Graph Editor.
011: * The Initial Developer of the Original Code is Jan Becicka.
012: * Portions created by Jan Becicka are Copyright (C) 2002.
013: * All Rights Reserved.
014: *
015: * Contributor(s): Jan Becicka.
016: *
017: * Created on 14. prosinec 2001, 13:08
018: */
019:
020: package org.jdesktop.j3dedit.scenegrapheditor.sourcecontrol.spec.javax.media.j3d;
021:
022: import org.jdesktop.j3dedit.scenegrapheditor.sourcecontrol.BeanCodeGenerator;
023: import org.jdesktop.j3dedit.scenegrapheditor.sourcecontrol.NamePool;
024:
025: /**
026: *
027: * @author Jan Becicka
028: */
029: public class GeometryArray extends BeanCodeGenerator {
030:
031: /** Creates a new instance of GeometryArray */
032: public GeometryArray(Object bean, NamePool naming) {
033: super (bean, naming);
034: }
035:
036: /** Override this method, if you want to create parametric constructor constr
037: */
038: protected void createConstructionCode() {
039: StringBuffer buf = new StringBuffer();
040: javax.media.j3d.GeometryArray ge = (javax.media.j3d.GeometryArray) bean;
041:
042: buf.append(getFieldName() + " = new " + beanClassName);
043: buf.append("(" + ge.getVertexCount() + ", ");
044: buf.append(ge.getVertexFormat() + ");\n");
045: constructionCode = buf.toString();
046: }
047:
048: protected void createCustomizationCode() {
049: javax.media.j3d.GeometryArray ge = (javax.media.j3d.GeometryArray) bean;
050:
051: int format = ge.getVertexFormat();
052: int len = ge.getVertexCount();
053:
054: if ((format & javax.media.j3d.GeometryArray.BY_REFERENCE) > 0) {
055: if ((format & javax.media.j3d.GeometryArray.INTERLEAVED) > 0) {
056: customizers.add("setInterleavedVertices("
057: + createIdentifier(ge.getInterleavedVertices())
058: + ")");
059: } else {
060: }
061: } else {
062: if ((format & javax.media.j3d.GeometryArray.COORDINATES) > 0) {
063: float array[] = new float[len * 3];
064: ge.getCoordinates(0, array);
065: customizers.add("setCoordinates(0,"
066: + createIdentifier(array) + ")");
067: }
068:
069: if ((format & javax.media.j3d.GeometryArray.NORMALS) > 0) {
070: float array[] = new float[len * 3];
071: ge.getNormals(0, array);
072: customizers.add("setNormals(0,"
073: + createIdentifier(array) + ")");
074: }
075:
076: if ((format & javax.media.j3d.GeometryArray.COLOR_3) > 0) {
077: float array[] = new float[len * 3];
078: ge.getColors(0, array);
079: customizers.add("setColors(0,"
080: + createIdentifier(array) + ")");
081: }
082:
083: if ((format & javax.media.j3d.GeometryArray.COLOR_4) > 0) {
084: float array4[] = new float[len * 4];
085: ge.getColors(0, array4);
086: customizers.add("setColors(0,"
087: + createIdentifier(array4) + ")");
088: }
089:
090: if ((format & javax.media.j3d.GeometryArray.TEXTURE_COORDINATE_2) > 0) {
091: float array2[] = new float[len * 2];
092: ge.getTextureCoordinates(0, array2);
093: customizers.add("setTextureCoordinates(0,"
094: + createIdentifier(array2) + ")");
095: }
096:
097: if ((format & javax.media.j3d.GeometryArray.TEXTURE_COORDINATE_3) > 0) {
098: float array[] = new float[len * 3];
099: ge.getTextureCoordinates(0, array);
100: customizers.add("setTextureCoordinates(0,"
101: + createIdentifier(array) + ")");
102: }
103: }
104: }
105:
106: /** Override this method, if you want to have different default instance (e.g. YourNean(10))
107: * @return instance of bean
108: */
109: protected Object createDefaultInstanceOfBean() {
110: return new Object();
111: }
112:
113: }
|