public GameScreen(){
spriteBatch = new SpriteBatch(); // buffer ok
texture = new Texture(Gdx.files.internal("bg/gameBG.jpg"));
viewMatrix = new Matrix4(); // matriz de visualização
tranMatrix = new Matrix4(); // matriz de escala
// camera
camera = new PerspectiveCamera(67.0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.near = 0.1f;
camera.far = 1000f;
camera.position.set(0, 5, 10);
camera.lookAt(0, 5, 0);
camera.update();
// ambiente
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1,1,1,1));
// renderizador
modelBatch = new ModelBatch();
p1 = new Player(1);
p2 = new Player(2);
}
java类com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute的实例源码
GameScreen.java 文件源码
项目:StreetCampusFighter
阅读 27
收藏 0
点赞 0
评论 0
ScreenRaider.java 文件源码
项目:enklave
阅读 29
收藏 0
点赞 0
评论 0
private void addBackground(){
decalBackground = Decal.newDecal(new TextureRegion(managerAssets.getAssetsCrafting().getTexture(NameFiles.backgroundCrafting)));
decalBackground.setDimensions(100,200);
decalBackground.setPosition(0,0,0);
environment = new Environment();
// environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
environment.set(new ColorAttribute(ColorAttribute.Diffuse));
environment.set(new ColorAttribute(ColorAttribute.Specular));
environment.set(new ColorAttribute(ColorAttribute.Reflection));
environment.add(new DirectionalLight().set(0.51f, 0.5f, 0.5f, 0f, -2f, -30f));
Model model = managerAssets.getAssetsRaider().getModel(NameFiles.raiderFull);
model.nodes.get(2).translation.set(-12,28.6f,-5.5f);
// model.nodes.get(0).translation.set(0,28f,29.2f);
// model.nodes.get(2).translation.set(0,13,-1);
instance = new ModelInstance(model);
instance.transform.trn(0,-20,25).rotate(0,1,0,-25);
instance.transform.scale(1.5f,1.5f,1.5f);
}
Renderer.java 文件源码
项目:VuforiaLibGDX
阅读 32
收藏 0
点赞 0
评论 0
public Renderer(VuforiaRenderer arRenderer) {
lights = new Environment();
lights.set(new ColorAttribute(ColorAttribute.AmbientLight, Color.WHITE));
camera = new PerspectiveCamera(60, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.near = 1.0F;
camera.far = 1000.0F;
//set camera into "Vuforia - style" direction
camera.position.set(new Vector3(0,0,0));
camera.lookAt(new Vector3(0,0,1));
this.vuforiaRenderer = arRenderer;
modelBatch = new ModelBatch();
}
GameModel.java 文件源码
项目:Chemtris
阅读 34
收藏 0
点赞 0
评论 0
public GameModel(PerspectiveCamera cam, boolean [][][] collision){
//setup the model instances
parts = new Array<ModelInstance>();
frame = new Array<ModelInstance>();
shadow = new Array<ModelInstance>();
//setup environment
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
//setup collision matrix
matrix = collision;
//setup camera
camera = cam;
}
SimulationRunner.java 文件源码
项目:eamaster
阅读 25
收藏 0
点赞 0
评论 0
public SimulationRunner() {
logger.info("Loading models");
ModelBuilder builder = new ModelBuilder();
models.put("box", builder.createBox(5f, 5f, 5f,
new Material(ColorAttribute.createDiffuse(new Color(0.8f, 0f, 0f, 0f))),
VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal));
G3dModelLoader loader = new G3dModelLoader(new JsonReader());
models.put("hub", loader.loadModel(Gdx.files.internal("data/hubreal.g3dj")));
models.put("rim", loader.loadModel(Gdx.files.internal("data/rimreal.g3dj")));
models.put("spoke", loader.loadModel(Gdx.files.internal("data/spoke.g3dj")));
Bullet.init();
logger.info("Initialized Bullet");
}
ConvexHullDistanceTest.java 文件源码
项目:eamaster
阅读 25
收藏 0
点赞 0
评论 0
@Override
public void create () {
super.create();
final Model carModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
disposables.add(carModel);
carModel.materials.get(0).clear();
carModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE));
world.addConstructor("car", new BulletConstructor(carModel, 5f, createConvexHullShape(carModel, true)));
// Create the entities
world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(),
0.25f + 0.5f * (float)Math.random(), 1f);
for (float y = 10f; y < 50f; y += 5f)
world.add("car", -2f + (float)Math.random() * 4f, y, -2f + (float)Math.random() * 4f).setColor(
0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
distance = new ConvexHullDistance();
shapeRenderer = new ShapeRenderer();
}
ConvexHullTest.java 文件源码
项目:eamaster
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void create () {
super.create();
final Model carModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
disposables.add(carModel);
carModel.materials.get(0).clear();
carModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE));
world.addConstructor("car", new BulletConstructor(carModel, 5f, createConvexHullShape(carModel, true)));
// Create the entities
world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(),
0.25f + 0.5f * (float)Math.random(), 1f);
for (float y = 10f; y < 50f; y += 5f)
world.add("car", -2f + (float)Math.random() * 4f, y, -2f + (float)Math.random() * 4f).setColor(
0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
}
GimpactTest.java 文件源码
项目:eamaster
阅读 28
收藏 0
点赞 0
评论 0
@Override
public void create () {
super.create();
final Model chassisModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
disposables.add(chassisModel);
chassisModel.materials.get(0).clear();
chassisModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.RED), ColorAttribute.createSpecular(Color.WHITE));
chassisVertexArray = new btTriangleIndexVertexArray(chassisModel.meshParts);
btGImpactMeshShape chassisShape = new btGImpactMeshShape(chassisVertexArray);
chassisShape.setLocalScaling(new Vector3(1f, 1f, 1f));
chassisShape.setMargin(0f);
chassisShape.updateBound();
world.addConstructor("chassis", new BulletConstructor(chassisModel, 1f, chassisShape));
(ground = world.add("ground", 0f, 0f, 0f)).setColor(0.25f + 0.5f * (float)Math.random(),
0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
world.add("chassis", 3f, 10f, 3f);
world.add("chassis", 4f, 5f, 3f);
world.add("chassis", 4f, 1f, 5f);
btGImpactCollisionAlgorithm.registerAlgorithm(world.dispatcher);
}
GridSpaceHighlighter.java 文件源码
项目:ChessGDX
阅读 25
收藏 0
点赞 0
评论 0
/**
* Initializes a highlighter effect, will be processed in
* {@link GridSpaceHighlighter#update(float)}
*
* @param state
* effect to be initialized
*/
public void setEffect(GridState state) {
mGridState = state;
switch (state) {
case FADE_GREEN:
mModelInstance.materials.get(0).set(ColorAttribute.createDiffuse(0.5f, 1.0f, 0.5f, 1.0f));
mAlphaBlend.opacity = 0.8f;
break;
case FADE_RED:
case ILLEGAL_HOVER:
mModelInstance.materials.get(0).set(ColorAttribute.createDiffuse(Color.RED));
mAlphaBlend.opacity = 0.8f;
break;
case LEGAL_HOVER:
mModelInstance.materials.get(0).set(ColorAttribute.createDiffuse(0.5f, 1.0f, 0.5f, 1.0f));
mAlphaBlend.opacity = 0.8f;
break;
case NONE:
mAlphaBlend.opacity = 0.0f;
default:
break;
}
}
RotateTool.java 文件源码
项目:Mundus
阅读 19
收藏 0
点赞 0
评论 0
public RotateHandle(int id, Color color) {
super(id);
model = UsefulMeshs.torus(new Material(ColorAttribute.createDiffuse(color)), 20, 1f, 50, 50);
modelInstance = new ModelInstance(model);
modelInstance.materials.first().set(getIdAttribute());
switch (id) {
case X_HANDLE_ID:
this.getRotationEuler().y = 90;
this.getScale().x = 0.9f;
this.getScale().y = 0.9f;
this.getScale().z = 0.9f;
break;
case Y_HANDLE_ID:
this.getRotationEuler().x = 90;
break;
case Z_HANDLE_ID:
this.getRotationEuler().z = 90;
this.getScale().x = 1.1f;
this.getScale().y = 1.1f;
this.getScale().z = 1.1f;
break;
}
// mi.transform.translate(0, 100, 0);
}
ScaleTool.java 文件源码
项目:Mundus
阅读 33
收藏 0
点赞 0
评论 0
public ScaleTool(ProjectManager projectManager, GameObjectPicker goPicker, ToolHandlePicker handlePicker,
ShapeRenderer shapeRenderer, ModelBatch batch, CommandHistory history) {
super(projectManager, goPicker, handlePicker, batch, history);
this.shapeRenderer = shapeRenderer;
ModelBuilder modelBuilder = new ModelBuilder();
Model xPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_X)),
Vector3.Zero, new Vector3(15, 0, 0));
Model yPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_Y)),
Vector3.Zero, new Vector3(0, 15, 0));
Model zPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_Z)),
Vector3.Zero, new Vector3(0, 0, 15));
Model xyzPlaneHandleModel = modelBuilder.createBox(3, 3, 3,
new Material(ColorAttribute.createDiffuse(COLOR_XYZ)),
VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
xHandle = new ScaleHandle(X_HANDLE_ID, xPlaneHandleModel);
yHandle = new ScaleHandle(Y_HANDLE_ID, yPlaneHandleModel);
zHandle = new ScaleHandle(Z_HANDLE_ID, zPlaneHandleModel);
xyzHandle = new ScaleHandle(XYZ_HANDLE_ID, xyzPlaneHandleModel);
handles = new ScaleHandle[] { xHandle, yHandle, zHandle, xyzHandle };
}
GameRenderer.java 文件源码
项目:GdxDemo3D
阅读 36
收藏 0
点赞 0
评论 0
public void setEnvironmentLights(Array<BaseLight<?>> lights, Vector3 sunDirection) {
environment = new Environment();
environment.add((shadowLight = new DirectionalShadowLight(
GameSettings.SHADOW_MAP_WIDTH,
GameSettings.SHADOW_MAP_HEIGHT,
GameSettings.SHADOW_VIEWPORT_WIDTH,
GameSettings.SHADOW_VIEWPORT_HEIGHT,
GameSettings.SHADOW_NEAR,
GameSettings.SHADOW_FAR))
.set(GameSettings.SHADOW_INTENSITY,
GameSettings.SHADOW_INTENSITY,
GameSettings.SHADOW_INTENSITY,
sunDirection.nor()));
environment.shadowMap = shadowLight;
float ambientLight = GameSettings.SCENE_AMBIENT_LIGHT;
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, ambientLight, ambientLight, ambientLight, 1));
for (BaseLight<?> light : lights) {
environment.add(light);
}
}
MaterialInterpreter.java 文件源码
项目:Alien-Ark
阅读 18
收藏 0
点赞 0
评论 0
public MaterialInterpreter() {
waterColor = new Color(0.13f, 0.05f, 0.8f, 1);
waterMaterial = new Material(
ColorAttribute.createDiffuse(waterColor),
ColorAttribute.createSpecular(1, 1, 1, 1),
FloatAttribute.createShininess(8f));
sandColor = new Color(0.9f, 0.733f, 0.58f, 1);
sandMaterial = new Material(ColorAttribute.createDiffuse(sandColor),
ColorAttribute.createSpecular(1, 1, 1, 1),
FloatAttribute.createShininess(8f));
grassColor = new Color(0f, 1f, 0f, 1f);
grassMaterial = new Material(ColorAttribute.createDiffuse(grassColor),
ColorAttribute.createSpecular(1, 1, 1, 1),
FloatAttribute.createShininess(8f));
}
DefaultShader.java 文件源码
项目:libgdxcn
阅读 29
收藏 0
点赞 0
评论 0
@Override
public void set (BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
if (renderable.environment == null)
shader.program.setUniform3fv(shader.loc(inputID), ones, 0, ones.length);
else {
renderable.worldTransform.getTranslation(tmpV1);
if (renderable.environment.has(ColorAttribute.AmbientLight))
cacheAmbientCubemap.set(((ColorAttribute)renderable.environment.get(ColorAttribute.AmbientLight)).color);
for (int i = dirLightsOffset; i < renderable.environment.directionalLights.size; i++)
cacheAmbientCubemap.add(renderable.environment.directionalLights.get(i).color,
renderable.environment.directionalLights.get(i).direction);
for (int i = pointLightsOffset; i < renderable.environment.pointLights.size; i++)
cacheAmbientCubemap.add(renderable.environment.pointLights.get(i).color,
renderable.environment.pointLights.get(i).position, tmpV1,
renderable.environment.pointLights.get(i).intensity);
cacheAmbientCubemap.clamp();
shader.program.setUniform3fv(shader.loc(inputID), cacheAmbientCubemap.data, 0, cacheAmbientCubemap.data.length);
}
}
Basic3DTest.java 文件源码
项目:amatsukaze
阅读 34
收藏 0
点赞 0
评论 0
@Override
public void create () {
modelBatch = new ModelBatch(new DefaultShaderProvider());
// modelBatch = new ModelBatch();
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(10f, 10f, 10f);
cam.lookAt(0, 0, 0);
cam.near = 0.1f;
cam.far = 300f;
cam.update();
ModelBuilder modelBuilder = new ModelBuilder();
model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position
| Usage.Normal);
instance = new ModelInstance(model);
// model = new G3dModelLoader(new UBJsonReader()).loadModel(Gdx.files.internal("data/g3d/knight.g3db"));
// instance = new ModelInstance(model);
Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
ShaderCollectionTest.java 文件源码
项目:libgdxcn
阅读 23
收藏 0
点赞 0
评论 0
@Override
public void create () {
super.create();
lights = new Environment();
lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.1f, 0.1f, 0.1f, 1.f));
lights.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f));
shaderProvider = new TestShaderProvider();
shaderBatch = new ModelBatch(shaderProvider);
cam.position.set(1, 1, 1);
cam.lookAt(0, 0, 0);
cam.update();
showAxes = true;
onModelClicked("g3d/shapes/teapot.g3dj");
shaderRoot = (hotLoadFolder != null && Gdx.app.getType() == ApplicationType.Desktop) ? Gdx.files.absolute(hotLoadFolder)
: Gdx.files.internal("data/g3d/shaders");
}
FogTest.java 文件源码
项目:libgdxcn
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void create () {
modelBatch = new ModelBatch();
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
environment.set(new ColorAttribute(ColorAttribute.Fog, 0.13f, 0.13f, 0.13f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(30f, 10f, 30f);
cam.lookAt(0, 0, 0);
cam.near = 0.1f;
cam.far = 45f;
cam.update();
ModelBuilder modelBuilder = new ModelBuilder();
model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position
| Usage.Normal);
instance = new ModelInstance(model);
Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
Basic3DTest.java 文件源码
项目:libgdxcn
阅读 30
收藏 0
点赞 0
评论 0
@Override
public void create () {
modelBatch = new ModelBatch(new DefaultShaderProvider());
// modelBatch = new ModelBatch();
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(10f, 10f, 10f);
cam.lookAt(0, 0, 0);
cam.near = 0.1f;
cam.far = 300f;
cam.update();
ModelBuilder modelBuilder = new ModelBuilder();
model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position
| Usage.Normal);
instance = new ModelInstance(model);
// model = new G3dModelLoader(new UBJsonReader()).loadModel(Gdx.files.internal("data/g3d/knight.g3db"));
// instance = new ModelInstance(model);
Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
CullTest.java 文件源码
项目:libgdxcn
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void create () {
ModelBuilder builder = new ModelBuilder();
sphere = builder.createSphere(2f, 2f, 2f, 16, 16, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)),
Usage.Position | Usage.Normal);
// cam = new PerspectiveCamera(45, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam = new OrthographicCamera(45, 45 * (Gdx.graphics.getWidth() / (float)Gdx.graphics.getHeight()));
cam.near = 1;
cam.far = 200;
Random rand = new Random();
for (int i = 0; i < instances.length; i++) {
pos.set(rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * 100 - rand.nextFloat() * 100,
rand.nextFloat() * -100 - 3);
instances[i] = new ModelInstance(sphere, pos);
}
modelBatch = new ModelBatch();
batch = new SpriteBatch();
font = new BitmapFont();
// Gdx.graphics.setVSync(true);
// Gdx.app.log("CullTest", "" + Gdx.graphics.getBufferFormat().toString());
}
ConvexHullDistanceTest.java 文件源码
项目:libgdxcn
阅读 22
收藏 0
点赞 0
评论 0
@Override
public void create () {
super.create();
final Model carModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
disposables.add(carModel);
carModel.materials.get(0).clear();
carModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE));
world.addConstructor("car", new BulletConstructor(carModel, 5f, createConvexHullShape(carModel, true)));
// Create the entities
world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(),
0.25f + 0.5f * (float)Math.random(), 1f);
for (float y = 10f; y < 50f; y += 5f)
world.add("car", -2f + (float)Math.random() * 4f, y, -2f + (float)Math.random() * 4f).setColor(
0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
distance = new ConvexHullDistance();
shapeRenderer = new ShapeRenderer();
}
ConvexHullTest.java 文件源码
项目:libgdxcn
阅读 19
收藏 0
点赞 0
评论 0
@Override
public void create () {
super.create();
final Model carModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
disposables.add(carModel);
carModel.materials.get(0).clear();
carModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE));
world.addConstructor("car", new BulletConstructor(carModel, 5f, createConvexHullShape(carModel, true)));
// Create the entities
world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(),
0.25f + 0.5f * (float)Math.random(), 1f);
for (float y = 10f; y < 50f; y += 5f)
world.add("car", -2f + (float)Math.random() * 4f, y, -2f + (float)Math.random() * 4f).setColor(
0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
}
GimpactTest.java 文件源码
项目:libgdxcn
阅读 29
收藏 0
点赞 0
评论 0
@Override
public void create () {
super.create();
final Model chassisModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
disposables.add(chassisModel);
chassisModel.materials.get(0).clear();
chassisModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.RED), ColorAttribute.createSpecular(Color.WHITE));
chassisVertexArray = new btTriangleIndexVertexArray(chassisModel.meshParts);
btGImpactMeshShape chassisShape = new btGImpactMeshShape(chassisVertexArray);
chassisShape.setLocalScaling(new Vector3(1f, 1f, 1f));
chassisShape.setMargin(0f);
chassisShape.updateBound();
world.addConstructor("chassis", new BulletConstructor(chassisModel, 1f, chassisShape));
(ground = world.add("ground", 0f, 0f, 0f)).setColor(0.25f + 0.5f * (float)Math.random(),
0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
world.add("chassis", 3f, 10f, 3f);
}
TileHighlightDisplayable.java 文件源码
项目:HelixEngine
阅读 33
收藏 0
点赞 0
评论 0
public TileHighlightDisplayable() {
ModelBuilder modelBuilder = new ModelBuilder();
Model model
= modelBuilder.createRect(0, 0, Z_OFFSET,
1, 0, Z_OFFSET,
1, 1, Z_OFFSET,
0, 1, Z_OFFSET,
0, 0, 1,
GL20.GL_TRIANGLES,
new Material(
new ColorAttribute(
ColorAttribute.createDiffuse(color)),
new BlendingAttribute(
GL20.GL_SRC_ALPHA,
GL20.GL_ONE_MINUS_SRC_ALPHA)),
VertexAttributes.Usage.Position |
VertexAttributes.Usage.TextureCoordinates);
instance = new ModelInstance(model);
}
AreaDisplayable.java 文件源码
项目:HelixEngine
阅读 25
收藏 0
点赞 0
评论 0
public AreaDisplayable(Model model) {
instance = new ModelInstance(model);
animationController = new AnimationController(instance);
instance.transform.rotate(new Vector3(1, 0, 0), 90);
for (Material material : instance.materials) {
TextureAttribute ta
= (TextureAttribute) material.get(TextureAttribute.Diffuse);
ta.textureDescription.magFilter = Texture.TextureFilter.Nearest;
ta.textureDescription.minFilter = Texture.TextureFilter.Nearest;
material.set(ta);
material.set(ColorAttribute.createDiffuse(Color.WHITE));
BlendingAttribute ba = new BlendingAttribute(GL20.GL_SRC_ALPHA,
GL20.GL_ONE_MINUS_SRC_ALPHA);
material.set(ba);
}
}
SimpleRoom.java 文件源码
项目:gdx-vr
阅读 35
收藏 0
点赞 0
评论 0
@Override
public void create() {
assets = new AssetManager();
String model = "Bambo_House.g3db";
assets.load(model, Model.class);
assets.finishLoading();
modelInstance = new ModelInstance(assets.get(model, Model.class), new Matrix4().setToScaling(0.6f, 0.6f, 0.6f));
DefaultShader.Config config = new Config();
config.defaultCullFace = GL20.GL_NONE;
ShaderProvider shaderProvider = new DefaultShaderProvider(config);
modelBatch = new ModelBatch(shaderProvider);
ModelBuilder builder = new ModelBuilder();
float groundSize = 1000f;
ground = new ModelInstance(builder.createRect(-groundSize, 0, groundSize, groundSize, 0, groundSize, groundSize, 0, -groundSize, -groundSize, 0, -groundSize, 0,
1, 0, new Material(), Usage.Position | Usage.Normal), new Matrix4().setToTranslation(0, -0.01f, 0));
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
VirtualReality.renderer.listeners.add(this);
// VirtualReality.head.setCyclops(true);
}
Utils3D.java 文件源码
项目:bladecoder-adventure-engine
阅读 33
收藏 0
点赞 0
评论 0
public static void createFloor() {
ModelBuilder modelBuilder = new ModelBuilder();
modelBuilder.begin();
MeshPartBuilder mpb = modelBuilder.part("parts", GL20.GL_TRIANGLES,
Usage.Position | Usage.Normal | Usage.ColorUnpacked, new Material(
ColorAttribute.createDiffuse(Color.WHITE)));
mpb.setColor(1f, 1f, 1f, 1f);
// mpb.box(0, -0.1f, 0, 10, .2f, 10);
mpb.rect(-10, 0, -10,
-10, 0, 10,
10, 0, 10,
10, 0, -10, 0, 1, 0);
floorModel = modelBuilder.end();
floorInstance = new ModelInstance(floorModel);
// TODO Set only when FBO is active
floorInstance.materials.get(0).set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
}
LedEntity.java 文件源码
项目:BotLogic
阅读 25
收藏 0
点赞 0
评论 0
public LedEntity(Model model) {
super(model);
light = new PointLight();
light.set(new Color(1f,1f, 1f, 1f), Vector3.Zero, 2f);
for (Material material : instance.materials) {
if (material.id.contains("Led")) {
this.colorAttr = (ColorAttribute)material.get(ColorAttribute.Diffuse);
colorAttr.color.set(Color.WHITE);
this.blendingAttribute = (BlendingAttribute)material.get(BlendingAttribute.Type);
blendingAttribute.opacity = 1.0f;
blendingAttribute.sourceFunction = GL20.GL_ONE;
blendingAttribute.destFunction = GL20.GL_SRC_ALPHA;
}
}
}
Stage3d.java 文件源码
项目:Scene3d
阅读 34
收藏 0
点赞 0
评论 0
public Stage3d (float width, float height, boolean keepAspectRatio) {
this.width = width;
this.height = height;
root = new Group3d();
root.setStage3d(this);
modelBatch = new ModelBatch();
camera = new Camera3d();
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.9f, 0.9f, 0.9f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0f, 0f, -1f, -0.8f, -0.2f));
setViewport(width, height, keepAspectRatio);
}
ModelManager.java 文件源码
项目:gdx-proto
阅读 35
收藏 0
点赞 0
评论 0
/** players are represented by cubes, with another cube marking the direction it is facing */
public void createPlayerModel() {
ModelBuilder mb = new ModelBuilder();
ModelBuilder mb2 = new ModelBuilder();
long attr = Usage.Position | Usage.Normal;
float r = 0.5f;
float g = 1f;
float b = 0.75f;
Material material = new Material(ColorAttribute.createDiffuse(new Color(r, g, b, 1f)));
Material faceMaterial = new Material(ColorAttribute.createDiffuse(Color.BLUE));
float w = 1f;
float d = w;
float h = 2f;
mb.begin();
//playerModel = mb.createBox(w, h, d, material, attr);
Node node = mb.node("box", mb2.createBox(w, h, d, material, attr));
// the face is just a box to show which direction the player is facing
Node faceNode = mb.node("face", mb2.createBox(w/2, h/2, d/2, faceMaterial, attr));
faceNode.translation.set(0f, 0f, d/2);
playerModel = mb.end();
}
Basic3D.java 文件源码
项目:amatsukaze
阅读 29
收藏 0
点赞 0
评论 0
@Override
public void create() {
modelBatch = new ModelBatch();
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(10f, 10f, 10f);
cam.lookAt(0, 0, 0);
cam.near = 1f;
cam.far = 300f;
cam.update();
camController = new CameraInputController(cam);
Gdx.input.setInputProcessor(camController);
ModelBuilder modelBuilder = new ModelBuilder();
model = modelBuilder.createBox(5f, 5f, 5f,
new Material(ColorAttribute.createDiffuse(Color.GREEN)),
Usage.Position | Usage.Normal);
instance = new ModelInstance(model);
}