本文整理匯總了Java中com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute類的典型用法代碼示例。如果您正苦於以下問題:Java ColorAttribute類的具體用法?Java ColorAttribute怎麽用?Java ColorAttribute使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ColorAttribute類屬於com.badlogic.gdx.graphics.g3d.attributes包,在下文中一共展示了ColorAttribute類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: GameScreen
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
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);
}
示例2: addBackground
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
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);
}
示例3: Renderer
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
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();
}
示例4: GameModel
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
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;
}
示例5: SimulationRunner
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
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");
}
示例6: create
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
@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();
}
示例7: create
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
@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);
}
示例8: create
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
@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);
}
示例9: setEffect
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
/**
* 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;
}
}
示例10: RotateHandle
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
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);
}
示例11: ScaleTool
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
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 };
}
示例12: setEnvironmentLights
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
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);
}
}
示例13: MaterialInterpreter
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
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));
}
示例14: set
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
@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);
}
}
示例15: create
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; //導入依賴的package包/類
@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)));
}