Package org.jdesktop.mtgame

Examples of org.jdesktop.mtgame.Entity


                             Node geometry)
    {
        this.cell = cell;
        this.renderer = renderer;

        entity = new Entity(name + " PickGeometry");
        setupEntity(entity, geometry);
    }
View Full Code Here


        super (name + " PickGeometry");

        this.cell = cell;
        this.renderer = renderer;

        entity = new Entity(name + " PickGeometry");
        setupEntity(entity);

        attach(boxes);
    }
View Full Code Here

    /**
     * Provides a raw input event to process
     */
    protected void inputEvent(Event event) {
        InputManager inputManager = InputManager.inputManager();       
        Entity entity = event.getEntity();
                       
        // Implement hover. We check if the event interrupts hover and we
        // restart the timer. If we kill a timer, there may be an executing
        // hover task run() method. This may lead to a race condition where
        // the run() method has been called at the same time a hover interrupt
        // event happens. To fix this, we keep track of when we kicked off
        // the last timer event.
        if (policy.isHoverInterrupt(event) == true) {
            synchronized(this) {
                // Cancel the current timer (although a run() method of the timer
                // may still happen as a race condition
                if (hoverTimer != null) {
                    hoverTimer.cancel();
                }
               
                // If there is a currently hovering entity, then send a stop
                // event
                MouseEvent mouseEvent = (MouseEvent) ((MouseEvent3D) event).getAwtEvent();
                if (hoverEntity != null) {
                    inputManager.postEvent(new HoverEvent(hoverEntity, false, mouseEvent));
                    hoverEntity = null;
                }
               
                // Update the hover start time. This will cause any remaining
                // timer tasks that may have been run to ignore themselves
                hoverStartTime = System.currentTimeMillis();
               
                // Launch a new timer task, but not unless we are actually over
                // a non-null entity
                if (entity != null) {
                    HoverTimerTask task = new HoverTimerTask(entity, hoverStartTime, mouseEvent);
                    hoverTimer = new Timer();
                    hoverTimer.schedule(task, policy.getHoverDelay());
                }
            }
        }
       
        if (policy.isClearedSelection(event) == true) {
            // If we wish to clear the selection, then simply clear out the
            // list and fire an event
            selectedEntityList.clear();
            inputManager.postEvent(new SelectionEvent(new LinkedList(selectedEntityList)));
            return;
        }
        else if (policy.isSingleSelection(event) == true) {
            // issue #1115: ignore the event if it is selecting an object that
            // is already selected
            if (selectedEntityList.contains(entity) == true) {
                // OWL issue #177: send an empty context event to ensure that
                // any visible context menus are hidden in this case
                MouseEvent mouseEvent = (MouseEvent) ((MouseEvent3D) event).getAwtEvent();
                inputManager.postEvent(new ContextEvent(new LinkedList(), mouseEvent));
               
                return;
            }

            // Clear out the list, add the new Entity and fire an event
            selectedEntityList.clear();
            selectedEntityList.add(entity);
            inputManager.postEvent(new SelectionEvent(new LinkedList(selectedEntityList)));
            return;
        }
        else if (policy.isMultiSelection(event) == true) {
            // If the Entity is already selected, then remove it from the
            // selection list. If not already present, then add it
            // Reset the selection possible. If the entity is not selected,
            // then select it (only). If the entity is selected, then do
            // nothing (if it is part of a group of selected entities)
            if (selectedEntityList.contains(entity) == false) {
                selectedEntityList.add(entity);
            }
            else {
                selectedEntityList.remove(entity);
            }
            inputManager.postEvent(new SelectionEvent(new LinkedList(selectedEntityList)));
            return;
        }
        else if (policy.isEnter(event) == true) {
            enterEntity = entity;
            inputManager.postEvent(new EnterExitEvent(entity, true));
        }
        else if (policy.isExit(event) == true) {
            Entity eventEntity = enterEntity;
            enterEntity = null;
            inputManager.postEvent(new EnterExitEvent(eventEntity, false));
        }
        else if (policy.isActivation(event) == true) {
            inputManager.postEvent(new ActivatedEvent(entity));
View Full Code Here

     *
     * @param event The scene event to post to the system
     */
    public void postEvent(SceneEvent event) {
        InputManager inputManager = InputManager.inputManager();
        Entity entity = ((SceneEvent)event).getPrimaryEntity();

        // Much of this code duplicates the inputEvent() method -- there seems
        // to be no way around this duplication for now.
       
        // Implement hover. We check if the event interrupts hover and we
        // restart the timer. If we kill a timer, there may be an executing
        // hover task run() method. This may lead to a race condition where
        // the run() method has been called at the same time a hover interrupt
        // event happens. To fix this, we keep track of when we kicked off
        // the last timer event.
        if (event instanceof HoverEvent) {
            synchronized(this) {
                // Cancel the current timer (although a run() method of the timer
                // may still happen as a race condition
                if (hoverTimer != null) {
                    hoverTimer.cancel();
                }

                // If there is a currently hovering entity, then send a stop
                // event
                MouseEvent mouseEvent = (MouseEvent) ((HoverEvent) event).getMouseEvent();
                if (hoverEntity != null) {
                    inputManager.postEvent(new HoverEvent(hoverEntity, false, mouseEvent));
                    hoverEntity = null;
                }

                // Update the hover start time. This will cause any remaining
                // timer tasks that may have been run to ignore themselves
                hoverStartTime = System.currentTimeMillis();

                // Launch a new timer task, but not unless we are actually over
                // a non-null entity
                if (entity != null) {
                    HoverTimerTask task = new HoverTimerTask(entity, hoverStartTime, mouseEvent);
                    hoverTimer = new Timer();
                    hoverTimer.schedule(task, policy.getHoverDelay());
                }
            }
        }

        // If a selection event, then set the list of entities and re-post the
        // event.
        if (event instanceof SelectionEvent) {
            // If a selection event, then set the list of entities and re-port
            // the event
            selectedEntityList.clear();
            selectedEntityList.addAll(event.getEntityList());
            inputManager.postEvent(new SelectionEvent(new LinkedList(selectedEntityList)));
            return;
        }

        // If an enter/exit event, then note the Entity we are entering or
        // exiting and repost the event.
        if (event instanceof EnterExitEvent) {
            if (((EnterExitEvent)event).isEnter() == true) {
                enterEntity = entity;
                inputManager.postEvent(new EnterExitEvent(entity, true));
            }
            else {
                Entity eventEntity = enterEntity;
                enterEntity = null;
                inputManager.postEvent(new EnterExitEvent(eventEntity, false));
            }
            return;
        }
View Full Code Here

            else if (event instanceof SelectionEvent) {
                List<Entity> selected = SceneManager.getSceneManager().getSelectedEntities();
                ListIterator<Entity> it = selected.listIterator();
                logger.warning("SELECTION: SELECTION EVENT " + selected.size());
                while (it.hasNext() == true) {
                    Entity entity = it.next();
                    logger.warning("SELECTION: SELETION EVENT " +
                            entity.getName());
                }
            }
            else if (event instanceof ContextEvent) {
                logger.warning("SELECTION: CONTEXT EVENT " +
                        se.getEntityList().size());
View Full Code Here

     * with the first Entity selected. Returns null if none.
     *
     * @return The primary Cell, or null
     */
    public Cell getPrimaryCell() {
        Entity entity = getPrimaryEntity();
        if (entity != null) {
            return getCellForEntity(entity);
        }
        return null;
    }
View Full Code Here

        skybox.setCullHint(Spatial.CullHint.Never);
        skybox.setTextureCombineMode(TextureCombineMode.Replace);
        skybox.updateRenderState();
        skybox.lockBounds();   
   
        Entity e = new Entity("Skybox");
        SkyboxComponent sbc = wm.getRenderManager().createSkyboxComponent(skybox, true);
        e.addComponent(SkyboxComponent.class, sbc);

        skyboxProcessor = new SkyboxProcessor(wm, skybox);
        e.addComponent(SkyboxProcessor.class, skyboxProcessor);
        return e;

    }
View Full Code Here

            skybox.setCullHint(Spatial.CullHint.Never);
            skybox.setTextureCombineMode(TextureCombineMode.Replace);
            skybox.updateRenderState();
            skybox.lockBounds();
            //skybox.lockMeshes();
            Entity e = new Entity("Skybox");
//            e.addComponent(ProcessorComponent.class, new TextureAnimationProcessor(up));
            SkyboxComponent sbc = wm.getRenderManager().createSkyboxComponent(skybox, true);
            e.addComponent(SkyboxComponent.class, sbc);

            skyboxProcessor = new SkyboxProcessor(wm, skybox);
            e.addComponent(SkyboxProcessor.class, skyboxProcessor);

            return e;

        } catch (MalformedURLException ex) {
            Logger.getLogger(DefaultEnvironmentRenderer.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

    private void lightingEnabledCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lightingEnabledCBActionPerformed
        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) {
View Full Code Here

  }
  sb.append("\n");

  int numChildren = entity.numEntities();
  for (int i = 0; i < numChildren; i++) {
      Entity child = entity.getEntity(i);
      appendLine(sb, indentLevel, "==================");
      appendLine(sb, indentLevel, "Child Entity " + i + ": " + child);
      appendLine(sb, indentLevel, getEntityContentsString(child, indentLevel+1));
      appendLine(sb, indentLevel, "==================");
View Full Code Here

TOP

Related Classes of org.jdesktop.mtgame.Entity

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.