# User-Manual for ColladaLoader

Currently, ColladaLoader can import dae or kmz files created by Blender or SketchUp. Next two chapters describe some rules about exporting dae files

## SketchUp export instructions

Do / enshure following steps:

- Try to safe existing .skp files into version 8
- Remove all groups in your model:
  Zoom back press CTRL+A then mouse rightclick and choose "explode"
- Enshure for unique textures:
  Do mouse rightclick on each faces which have textures applied and choose "Make Unique Texture"
- save .skp File then export as kmz or dae:
  Choose in Sketchup "File" → "Export" → "3D-Model"

## Blender export instructions

Consider following points:

- use material textures and uv maps (printscreen)
- use material for colors + transparencies (printscreen)
- remove unused uv-maps (printscreen)
- set export options to: (printscreen)
  1. "triangulate"
  2. transformation type "matrix"
  3. "include material textures"
- pure lines (edges) do not have colors or thickness, Blender does not export it
- store dae file and texture pics into same folder
- export and reimport a dae to debug any problems (missing colors or textures, bad scales)
- collada transfers from SketchUp to Blender need the import option "Import Units".

## Import into Processing

The library has demo files they do all the same, but use different renderers. If your platform produce no errors using P3D then ViewerDefault is the right choice.

The examples give a quick start over all features/usage of this library. User should also read javadoc for classes "ColladaLoader" and "ColladaModel". Here is a short beginner sample:

    import ch.dieseite.colladaloader.ColladaLoader;
    import ch.dieseite.colladaloader.wrappers.ColladaModel;

    ColladaModel model;

    void settings() {
    	size(500,500,P3D);
    }

    void setup() {

    	lights();
    	frameRate(10);

    	model = ColladaLoader.load("sketchup.kmz",this,null);
    	//notes:
    	//- loader accepts kmz and dae file endings
    	//- user can create unlimited numbers of models
    	//- loader can process user options via 3rd param
    }

    void draw() {

    	background(0);

    	model.draw();
    	//notes: (see also javadoc)
    	//- model can draw using default renderer (2D) or OpenGL (P2D/P3D)
    	//- model can scale, move or rotate its 3D positions without changing rest of view
    }

User Options
Users can fine adjust colladaLoader's behavior as following:
    import java.util.Properties;
    <...>
    Properties options = new Properties();
    ColladaLoader.load("sketchup.kmz",this,options);
    <...>
Key | Value | Affect
--- | --- | ---
option_no_texture | true | ColladaLoader uses Processing images (PImage) to display textures. If value is true then collada texture data is ignored and replaced by a dummy color. A useful debug tool on problems like "image file not found, unsupported image format, out of memory" etc.
false (default) | textures is enabled
LinkingSchema | Sketchup (default) | A loading profile what consider the way how external 3D modeling applications export 3D data to collada. In other words: exported .dae files by SketchUp should use that value.
Blender | Loads collada file via Blender profile
debuglevel | 0 to 4 | Verbose internal processes from ColladaLoader to system console: 4 = extreme details 3 = details 2 = medium 1 = abstract 0 = none (default)

## Troubleshooting

- enable logging, change LinkingSchema, or disable textures via ColladaLoader user options
- spare hardware stress via Processing API/ sketchbook options:
  1. framerate()
  2. noLoop()
  3. increase max memory size
- run "GLBaseTest" from example on general P2D/P3D problems

## Appendix: GLAdapter / GLBaseTest

GLAdapter is another way to run OpenGL /P3D. Both, Processing API and GLAdapter, use the same native libraries (JOGL) but obviously over different implementations . As Processing increased its version to 2.0 and higher my platform began to crash so I was forced to find a way to patch this bug. Let's suppose I'm not the only one with this issue I included this patch to colladaLoader package now.

GLAdapter emulates a selected part of Processing API (P3D). It has the same names , accepts the same input params and shows the same output behavior. But the performance is not very sexy. Every usage start with this sample stub:

    import ch.dieseite.glemulator.GLAdapter;
    GLAdapter adapter;

    void settings(){
    	size(200, 200); //leave Processing in 2D
    }

    void setup(){
    	adapter = new GLAdapter(200, 200);
    }

    void draw(){
    	adapter.background(200);// An API example (see also list below)

    	adapter.repaint();  //flush jobs, must ALWAYS be called at the end
    }

There exist a class "GLBaseTest" which creates some test shapes.

Following functions is supported by GLAdapter:

- void lights()
- void strokeWeight(float w)
- void stroke(float r, float g, float b)
- void line(float xa, float ya, float za, float xb, float yb, float zb)
- void translate(float x, float y, float z)
- void rotateY(float angle)
- void rotateX(float angle)
- void rotateZ(float angle)
- void scale(float v)
- void beginShape(int mode) (supported mode "GLAdapter.TRIANGLE" only)
- void endShape()
- void fill(float r, float g, float b, float t)
- void fill(float c)
- void vertex(float x, float y, float z)
- void vertex(float x, float y, float z, float tx, float ty)
- void texture(PImage img)
- void background(float c)
- int color(int r, int g, int b, int a)