Package org.jdesktop.mtgame

Examples of org.jdesktop.mtgame.RenderComponent


        root = new Node("orb root");
        orbNode = new Node("orb node");
        attachOrb(entity);
        attachNameTag();
        createSpeakingAnimations(entity);
        RenderComponent rc = ClientContextJME.getWorldManager().getRenderManager().createRenderComponent(root);
        entity.addComponent(RenderComponent.class, rc);
        listener.addToEntity(entity);
        setVisible(true);
        return root;
    }
View Full Code Here


        checkDirty();
    }//GEN-LAST:event_lightingEnabledCBActionPerformed

    private void printSceneGraphBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printSceneGraphBActionPerformed
        Entity entity = ((CellRendererJME)editor.getCell().getCellRenderer(RendererType.RENDERER_JME)).getEntity();
        RenderComponent rc = entity.getComponent(RenderComponent.class);
        Node root = rc.getSceneRoot();
        print(root, 0);
//        TreeScan.findNode(root, new ProcessNodeInterface() {
//
//            public boolean processNode(Spatial node) {
//                System.err.println(node+"  "+node.getLocalScale());
View Full Code Here

    private static String getEntityContentsString (Entity entity, int indentLevel) {
  StringBuffer sb = new StringBuffer();
 
  appendLine(sb, indentLevel, "sceneRoot = \n");
  RenderComponent rc = (RenderComponent) entity.getComponent(RenderComponent.class);
  if (rc != null) {
      appendSceneGraph(sb, indentLevel, rc.getSceneRoot());
  }
  sb.append("\n");

  int numChildren = entity.numEntities();
  for (int i = 0; i < numChildren; i++) {
View Full Code Here

        this.view = view;
        name = "Frame for " + view.getName();

        frameEntity = new Entity("Entity for " + name);
        frameNode = new Node("Node for " + name);
        RenderComponent rc =
                ClientContextJME.getWorldManager().getRenderManager().createRenderComponent(frameNode);
        frameEntity.addComponent(RenderComponent.class, rc);

        header = new FrameHeaderSwing(view);
View Full Code Here

        Entity viewEntity = view.getEntity();
        if (viewEntity == null) return;

        viewEntity.addEntity(frameEntity);

        RenderComponent rcFrame = (RenderComponent) frameEntity.getComponent(RenderComponent.class);

        if (rcFrame != null) {
            // We need to attach secondary view frames to the GEOMETRY NODE of its views
            // so that they move with the offset of the view
            //
            // SPECIAL NOTE:
            // This provides special treatment for the left/right/bottom of a secondary frame
            // but it doesn't handle the header. See also: SPECIAL NOTE in View2DEntity.processChanges.
            if (view.getType() == View2D.Type.SECONDARY) {
                rcFrame.setAttachPoint(view.getGeometryNode());
            } else {
                rcFrame.setAttachPoint(view.getViewNode());
            }
        }

        if (header != null) {
            header.setVisible(true);
View Full Code Here

        if (!attached) return;

        Entity viewEntity = view.getEntity();
        if (viewEntity == null) return;
        viewEntity.removeEntity(frameEntity);
        RenderComponent rcFrame = (RenderComponent) frameEntity.getComponent(RenderComponent.class);
        if (rcFrame != null) {
            rcFrame.setAttachPoint(null);
        }
        if (header != null) {
            header.setVisible(false);
        }
        attached = false;
View Full Code Here

        name = "View for " + window.getName();

        // Create entity and node
        entity = new Entity("Entity for " + name);
        viewNode = new Node("Node for " + name);
        RenderComponent rc =
            ClientContextJME.getWorldManager().getRenderManager().createRenderComponent(viewNode);
        entity.addComponent(RenderComponent.class, rc);
        entityMakePickable(entity);

        // Create input-related objects
View Full Code Here

            // First, detach entity (if necessary)
            switch (attachState) {
            case ATTACHED_TO_ENTITY:
                if (parentEntity != null) {
                    logger.fine("Remove entity " + entity + " from parent entity " + parentEntity);
                    RenderComponent rc = (RenderComponent) entity.getComponent(RenderComponent.class);
                    sgChangeAttachPointSetAddEntity(rc, null, null, null);
                    parentEntity.removeEntity(entity);
                    parentEntity = null;
                }
                break;
            case ATTACHED_TO_WORLD:
                logger.fine("Remove entity " + entity + " from world manager.");
                ClientContextJME.getWorldManager().removeEntity(entity);
                break;
            }
            attachState = AttachState.DETACHED;

            // Does the geometry node itself need to change?
            if ((changeMask & CHANGED_GEOMETRY) != 0) {
                if (geometryNode != null) {
                    // Note: don't need to do in RenderUpdater because we've detached our entity
                    sgChangeGeometryDetachFromView(viewNode, geometryNode);
                    if (geometrySelfCreated) {
                        sgChangeGeometryCleanup(geometryNode);
                        geometrySelfCreated = false;
                    }
                }
                if (newGeometryNode != null) {
                    geometryNode = newGeometryNode;
                    newGeometryNode = null;
                } else {
                    geometryNode = new GeometryNodeQuad(this);
                    geometrySelfCreated = true;
                }
                // Note: don't need to do in RenderUpdater because we've detached our entity
                sgChangeGeometryAttachToView(viewNode, geometryNode);
            }

            // Uses: window
            if ((changeMask & (CHANGED_GEOMETRY | CHANGED_SIZE_APP)) != 0) {
                logger.fine("Update texture for view " + this);
                if (geometryNode != null) {
                    DrawingSurface surface = getWindow().getSurface();
                    if (surface != null) {
                        sgChangeGeometryTextureSet(geometryNode, getWindow().getTexture(), surface);
                        windowNeedsValidate = true;
                    }
                }
            }

            // Now reattach geometry if view should be visible
            // Note: MTGame can currently only setOrtho on a visible rc
            // Uses: visible, ortho
            if (isActuallyVisible()) {
                if (ortho) {
                    logger.fine("View is ortho for view " + this);
                    entity.getComponent(RenderComponent.class).setOrtho(true);
                    entity.getComponent(CollisionComponent.class).setCollidable(false);

                    if (type == Type.PRIMARY  || type == Type.UNKNOWN) {
                        // Attach top level ortho views directly to world
                        ClientContextJME.getWorldManager().addEntity(entity);
                        attachState = AttachState.ATTACHED_TO_WORLD;
                        logger.fine("Attached entity " + entity + " to world manager.");
                    } else {
                        parentEntity = getParentEntity();
                        if (parentEntity == null) {
                            // Has no Parent; attach directly to world
                            ClientContextJME.getWorldManager().addEntity(entity);
                            attachState = AttachState.ATTACHED_TO_WORLD;
                            logger.fine("Attached parentless entity " + entity + " to world manager.");
                        } else {
                            RenderComponent rc = (RenderComponent) entity.getComponent(RenderComponent.class);
                            // TODO: these two statements appear to be obsolete.
                            RenderComponent rcParent =
                                (RenderComponent) parentEntity.getComponent(RenderComponent.class);
                            Node attachNode = rcParent.getSceneRoot();

                            // Note: we need to attach non-primaries to the parent geometry node in
                            // ortho mode, rather than the view node. This way it picks up the parent's
                            // offset translation, which contains locationOrtho
                            // TODO: do this cleaner. Convert attach node to a view and get the
                            // geometry node for this view.
                            attachNode = (Node) attachNode.getChild(0);

                            sgChangeAttachPointSetAddEntity(rc, attachNode, parentEntity, entity);
                            attachState = AttachState.ATTACHED_TO_ENTITY;
                            logger.fine("Attach ortho entity " + entity + " to geometry node of parent entity " + parentEntity);
                        }
                    }
                } else {
                    logger.fine("View is not ortho for view " + this);
                    parentEntity = getParentEntity();
                    if (parentEntity == null) {
                        logger.warning("getParentEntity() returns null; must be non-null");
                    } else {
                        logger.fine("Attach entity " + entity + " to parent entity " + parentEntity);

                        RenderComponent rc = (RenderComponent) entity.getComponent(RenderComponent.class);
                        RenderComponent rcParent =
                            (RenderComponent) parentEntity.getComponent(RenderComponent.class);
                        Node attachNode = rcParent.getSceneRoot();

                        // SPECIAL NOTE: Here is where special surgery is done on header windows so
                        // that they are parented to the *geometry node* of their parent view instead of
                        // the view node, as windows normally are. This way it picks up the offset
                        // translation in the geometry node and stays in sync with the rest of the frame.
View Full Code Here

     * a render component and a scene root node.
     */
    public static void entityMakePickable (Entity entity) {
        JMECollisionSystem collisionSystem = (JMECollisionSystem) ClientContextJME.getWorldManager().
            getCollisionManager().loadCollisionSystem(JMECollisionSystem.class);
        RenderComponent rc = (RenderComponent) entity.getComponent(RenderComponent.class);
        CollisionComponent cc = collisionSystem.createCollisionComponent(rc.getSceneRoot());
        entity.addComponent(CollisionComponent.class, cc);
        cc.setCollidable(true);
        cc.setInheritCollidable(true);
    }
View Full Code Here

     */
    protected void initSceneGraph() {

        // Attach the localToCell node to the entity
        localToCellNode = new Node("Local-to-cell node for frame component " + name);
        RenderComponent rc = ClientContextJME.getWorldManager().getRenderManager().
                createRenderComponent(localToCellNode);
        entity.addComponent(RenderComponent.class, rc);
        rc.setEntity(entity);

        // Attach the subclass spatials to the localToCell node
        final Spatial[] spatials = getSpatials();
        if (spatials != null) {
            ClientContextJME.getWorldManager().addRenderUpdater(new RenderUpdater() {
View Full Code Here

TOP

Related Classes of org.jdesktop.mtgame.RenderComponent

Copyright © 2018 www.massapicom. 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.