Package jsynoptic.plugins.syn3d.xith3d

Source Code of jsynoptic.plugins.syn3d.xith3d.SynopticViewNodeXith3d$ViewTransformator

/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info:  http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2004, by :
*     Corporate:
*         EADS Corporate Research Center
*     Individual:
*         Nicolas Brodu
*
* $Id: SynopticViewNodeXith3d.java,v 1.3 2004/04/01 14:55:57 brodu Exp $
*
* Changes
* -------
* 19-Mar-2004 : Creation date (NB);
*
*/
package jsynoptic.plugins.syn3d.xith3d;

import java.awt.Rectangle;
import java.awt.image.BufferedImage;

import com.xith3d.render.jogl.PBufferCanvas3D;
import com.xith3d.scenegraph.Transform3D;
import com.xith3d.scenegraph.View;
import jsynoptic.plugins.syn3d.SynopticViewNode;
import jsynoptic.plugins.syn3d.View3DShape;
import syn3d.base.ActiveNode;
import syn3d.nodes.SceneChangeListener;
import syn3d.nodes.SceneNode;
import syn3d.nodes.xith3d.SceneNodeXith3D;
import syn3d.ui.Transformator;

/**
*
*/
public class SynopticViewNodeXith3d extends SynopticViewNode implements SceneChangeListener {
   
    protected transient PBufferCanvas3D canvas;
    protected transient View view;
    protected transient View3DShape shape = null;
    protected transient ViewTransformator transformator;

    public SynopticViewNodeXith3d(ActiveNode parent) {
        super(parent);
        view = new View();
        ((SceneNodeXith3D)parent).getUniverse().addView(view);
        ((SceneNode)parent).addListener(this);
        transformator = new ViewTransformator();
    }

    public void sceneChanged(SceneNode scene) {
        if (canvas!=null) canvas.updateImage();
        if (shape!=null) shape.notifyChange();
    }

    public void attach(View3DShape shape) {
        this.shape = shape; // caller will decide whether to notifyChange() the shape or not
        if (canvas!=null) view.removeCanvas3D(canvas);
        Rectangle bounds = shape.getBounds();
    canvas = new PBufferCanvas3D(bounds.width,bounds.height);
    transformator.setWSize(Math.min(bounds.width,bounds.height));
    transformator.updateZoomMatrix();
        view.addCanvas3D(canvas);
    }

    public BufferedImage getSnapShot() {
        if (canvas==null) return null;
        return canvas.getLastImage();
    }
   
    /* (non-Javadoc)
     * @see jsynoptic.plugins.syn3d.SynopticViewNode#getTransformator()
     */
    public Transformator getTransformator() {
        return transformator;
    }
   
    protected class ViewTransformator extends Transformator {

      protected Transform3D transform;
      protected Transform3D tempTransform;

        public ViewTransformator() {
            super();
          transform = new Transform3D();
          tempTransform = new Transform3D();
        updateZoomMatrix();
        updateTranslateMatrix();
        applyTransform();
        }

        public void applyTransform(){
        super.applyTransform();
        transform.set(rot);
        tempTransform.set(trans);
        transform.mul(tempTransform);
        tempTransform.set(zoom);
        transform.mul(tempTransform);
        view.setTransform(transform);
            if (canvas!=null) canvas.updateImage();
            if (shape!=null) shape.notifyChange();
      }
       
    }
   
   
}
TOP

Related Classes of jsynoptic.plugins.syn3d.xith3d.SynopticViewNodeXith3d$ViewTransformator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.