UniverseにIDで管理するものを追加 #19

Merged t-hayashi merged 1 commit into nitta-lab-2018:master from nitta-lab-2018:hash_univ on 26 Jun 2018
Showing 4 changed files
View
.idea/caches/build_file_checksums.ser
Not supported
View
17
app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/types/PlayerId.java 0 → 100644
package org.ntlab.radishforandroidstudio.cactusClient.types;
 
import android.support.annotation.NonNull;
 
import org.ntlab.radishforandroidstudio.framework.common.CommonId;
 
/**
* Player IDの管理クラス
*
* @author s.iwatani
*/
public class PlayerId extends CommonId<Integer> {
public PlayerId(@NonNull Integer id) {
super(id);
}
}
View
26
app/src/main/java/org/ntlab/radishforandroidstudio/framework/common/CommonId.java 0 → 100644
package org.ntlab.radishforandroidstudio.framework.common;
 
import android.support.annotation.NonNull;
 
/**
* Id管理の基底クラス
*
* @author s.iwatani
* @param <IdType>
*/
public abstract class CommonId<IdType> {
private IdType id = null;
 
public CommonId(@NonNull IdType id) {
setId(id);
}
 
public IdType getId() {
return id;
}
 
public void setId(IdType id) {
this.id = id;
}
}
View
30
app/src/main/java/org/ntlab/radishforandroidstudio/framework/model3D/Universe.java
package org.ntlab.radishforandroidstudio.framework.model3D;
 
import org.ntlab.radishforandroidstudio.framework.common.CommonId;
import org.ntlab.radishforandroidstudio.framework.physics.Ground;
import org.ntlab.radishforandroidstudio.java3d.BranchGroup;
import org.ntlab.radishforandroidstudio.java3d.Group;
import org.ntlab.radishforandroidstudio.java3d.Leaf;
import org.ntlab.radishforandroidstudio.java3d.Transform3D;
import org.ntlab.radishforandroidstudio.java3d.TransformGroup;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
 
public class Universe {
private BranchGroup root = null;
private ArrayList<Light> lights = new ArrayList<Light>();
private BackgroundBox skyBox = null;
private Ground ground = null;
private ArrayList<Movable> movableList = new ArrayList<Movable>();
private Map<CommonId, Object3D> objMap = new HashMap<>();
public Universe() {
root = new BranchGroup();
}
} else if (node instanceof Leaf) {
viewer.draw(node);
}
}
 
public void apply(HashMap<CommonId, ArrayList<Property3D>> properties) {
for (Map.Entry<CommonId, ArrayList<Property3D>> entry : properties.entrySet()) {
Object3D target = objMap.get(entry.getKey());
for (Property3D prop : entry.getValue()) {
target.apply(prop, false);
}
}
}
 
public void update(long interval){
for(int i = 0; i < movableList.size(); i++){
Movable movable = movableList.get(i);
movable.motion(interval,ground);
public void place(Node node) {
root.addChild(node);
}
 
public void place(Object3D obj, CommonId id) {
objMap.put(id, obj);
}
 
/**
* 後で取り除けるようにオブジェクトを配置する
*
* @param obj
private void displace(Node node) {
root.removeChild(node);
}
 
public void displace(CommonId id) { objMap.remove(id); }
 
public ArrayList<Light> getLights() {
return lights;
}