Skip to content
This repository has been archived by the owner on Nov 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #24 from david-hall/Exporters
Browse files Browse the repository at this point in the history
Remove Collida DAE from the whitelist in getNaiveExporter()
  • Loading branch information
vorth authored Jul 19, 2016
2 parents 0640799 + 17c91cd commit b230aae
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
24 changes: 14 additions & 10 deletions src/main/java/com/vzome/core/editor/DocumentModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import com.vzome.core.construction.SegmentCrossProduct;
import com.vzome.core.construction.SegmentJoiningPoints;
import com.vzome.core.editor.Snapshot.SnapshotAction;
import com.vzome.core.exporters.DaeExporter;
import com.vzome.core.exporters.Exporter3d;
import com.vzome.core.exporters.OpenGLExporter;
import com.vzome.core.exporters.POVRayExporter;
Expand Down Expand Up @@ -1125,14 +1124,17 @@ else if ( "plane" .equals( group ) )

public Exporter3d getNaiveExporter( String format, Camera view, Colors colors, Lights lights, RenderedModel currentSnapshot )
{
Exporter3d exporter = null;
if ( format.equals( "pov" ) )
return new POVRayExporter( view, colors, lights, currentSnapshot );
exporter = new POVRayExporter( view, colors, lights, currentSnapshot );
else if ( format.equals( "opengl" ) )
return new OpenGLExporter( view, colors, lights, currentSnapshot );
else if ( format.equals( "dae" ) )
return new DaeExporter( view, colors, lights, currentSnapshot );
else
return null;
exporter = new OpenGLExporter( view, colors, lights, currentSnapshot );

boolean inArticleMode = (renderedModel != currentSnapshot);
if(exporter != null && exporter.needsManifestations() && inArticleMode ) {
throw new IllegalStateException("The " + format + " exporter can only operate on the current model, not article pages.");
}
return exporter;
}

/*
Expand All @@ -1146,14 +1148,16 @@ else if ( format.equals( "dae" ) )
*
* POV-Ray is a bit of a special case, but only because the .pov language supports coordinate values as expressions,
* and supports enough modeling that the different strut shapes can be defined, and so on.
* It is likely that COLLADA DAE has the same character. OpenGL and WebGL (Web3d/json) could as well, since I
* can control how the data is stored and rendered.
* OpenGL and WebGL (Web3d/json) could as well, since I can control how the data is stored and rendered.
*
* The POV-Ray export reuses shapes, etc. just as vZome does, so really works just with the RenderedManifestations
* (except when the Manifestation is available for structured coordinate expressions). Again, any rendering exporter
* could apply the same reuse tricks, working just with RenderedManifestations, so the current limitations to
* mRenderedModel for many of these is spurious.
*/
*
* The base Exporter3d class now has a boolean needsManifestations() method which subclasses should override
* if they don't rely on Manifestations and therefore can operate on article pages.
*/

// TODO move all the parameters inside this object!

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/vzome/core/exporters/Exporter3d.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ public String getContentType()
return "text/plain";
}

/**
* Subclasses can override this if they don't rely on Manifestations and therefore can operate on article pages
* See the comments below DocumentModel.getNaiveExporter() for a more complete explanation.
*/
public boolean needsManifestations() {
return true;
}

/**
* Subclasses can override this if they need to export history or the lesson model.
*/
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/vzome/core/exporters/OpenGLExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ public class OpenGLExporter extends Exporter3d
{
private static final NumberFormat FORMAT = NumberFormat .getNumberInstance( Locale .US );

public OpenGLExporter( Camera scene, Colors colors, Lights lights, RenderedModel model )
{
super( scene, colors, lights, model );
}

@Override
public boolean needsManifestations() {
return false;
}

@Override
public void doExport( File directory, Writer writer, int height, int width ) throws IOException
{
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/vzome/core/exporters/POVRayExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ public void mapViewToWorld( Camera view, Vector3f vector )
viewTrans .invert();
viewTrans .transform( vector );
}


@Override
public boolean needsManifestations() {
return false;
}

@Override
public void doExport( File povFile, File directory, Writer writer, int height, int width ) throws IOException
{
Expand Down

0 comments on commit b230aae

Please sign in to comment.