Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
xxx authored and xxx committed Oct 12, 2020
1 parent 463362d commit 80953f4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
41 changes: 38 additions & 3 deletions src/org/soo/outliner/SelectObjectOutliner.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,41 @@ public class SelectObjectOutliner {
private RenderManager renderManager;
private AssetManager assetManager;
private Camera cam;

/**
*
*/
public static int OUTLINER_TYPE_FILTER=0;

/**
*
*/
public static int OUTLINER_TYPE_MATERIAL=1;
private Material wireMaterial;
private Node modelNode;
int outlinerType=OUTLINER_TYPE_FILTER;
private int width=5;
private ColorRGBA color=ColorRGBA.Yellow;

/**
*
*/
public SelectObjectOutliner()
{

}

/**
*
* @param type of filter: OUTLINER_TYPE_FILTER or OUTLINER_TYPE_MATERIAL
* @param width of the selection border
* @param color of the selection border
* @param modelNode direct node containing the spacial. Wil be used to add geometry in OUTLINER_TYPE_MATERIAL node.
* @param fpp - FilterPostProcessor to handle filtering
* @param renderManager
* @param assetManager
* @param cam - main cam
*/
public void initOutliner(int type, int width, ColorRGBA color,Node modelNode, FilterPostProcessor fpp, RenderManager renderManager,AssetManager assetManager, Camera cam)
{
outlinerType=type;
Expand All @@ -66,7 +89,10 @@ public void initOutliner(int type, int width, ColorRGBA color,Node modelNode, F
}
}


/**
*
* @param model to be delected
*/
public void deselect(Spatial model)
{
if(outlinerType==OUTLINER_TYPE_FILTER)
Expand All @@ -77,7 +103,11 @@ public void deselect(Spatial model)
model.setUserData("OutlineSelected", false);
}

public void select(Spatial model)
/**
*
* @param model to delected
*/
public void select(Spatial model)
{
if(outlinerType==OUTLINER_TYPE_FILTER)
showOutlineFilterEffect( model, width, color);
Expand All @@ -87,7 +117,12 @@ public void select(Spatial model)
model.setUserData("OutlineSelected", true);
}

public boolean isSelected(Spatial model)
/**
*
* @param model
* @return
*/
public boolean isSelected(Spatial model)
{
if(model.getUserData("OutlineSelected")!=null && ((Boolean)model.getUserData("OutlineSelected"))==true)
return true;
Expand Down
13 changes: 8 additions & 5 deletions src/org/soo/test/SelectObjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Ray;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Sphere;
import org.soo.outliner.SelectObjectOutliner;
Expand Down Expand Up @@ -62,9 +60,9 @@ public void simpleInitApp() {
//Declare
outliner=new SelectObjectOutliner();
//Init - using filter
outliner.initOutliner(SelectObjectOutliner.OUTLINER_TYPE_FILTER, 2, ColorRGBA.Yellow,rootNode,fpp, renderManager, assetManager, cam);
outliner.initOutliner(SelectObjectOutliner.OUTLINER_TYPE_FILTER, 2, ColorRGBA.Yellow,shootables,fpp, renderManager, assetManager, cam);
//Init - using material
//outliner.initOutliner(SelectObjectOutliner.OUTLINER_TYPE_MATERIAL, 2, ColorRGBA.Yellow,rootNode,fpp, renderManager, assetManager, cam);
//outliner.initOutliner(SelectObjectOutliner.OUTLINER_TYPE_MATERIAL, 2, ColorRGBA.Magenta,shootables,fpp, renderManager, assetManager, cam);


}
Expand Down Expand Up @@ -180,5 +178,10 @@ protected void initCrossHairs() {
guiNode.attachChild(ch);
}


@Override
public void simpleUpdate(float tpf) {
super.simpleUpdate(tpf);
shootables.move(tpf*0.1f, 0, 0) ;
}

}

0 comments on commit 80953f4

Please sign in to comment.