本文整理汇总了Java中org.rajawali3d.materials.Material.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java Material.setColor方法的具体用法?Java Material.setColor怎么用?Java Material.setColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.rajawali3d.materials.Material
的用法示例。
在下文中一共展示了Material.setColor方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPhotoSphereWithTexture
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
private static Sphere createPhotoSphereWithTexture(ATexture texture) {
Material material = new Material();
material.setColor(0);
try {
material.addTexture(texture);
} catch (ATexture.TextureException e) {
throw new RuntimeException(e);
}
Sphere sphere = new Sphere(50, 64, 32);
sphere.setScaleX(-1);
sphere.setMaterial(material);
return sphere;
}
示例2: init
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
private void init() {
this.setTransparent(true);
this.setDoubleSided(true);
float[] vertices = new float[MAX_VERTICES * 3];
float[] normals = new float[MAX_VERTICES * 3];
int[] indices = new int[MAX_VERTICES];
for (int i = 0; i < indices.length; ++i) {
indices[i] = i;
int index = i * 3;
normals[index] = 0;
normals[index + 1] = 1;
normals[index + 2] = 0;
}
setData(vertices, normals, null, null, indices, false);
Material material = new Material();
material.setColor(color);
setMaterial(material);
rebuildPoints();
setPosition(new Vector3(0, -1.4, 0));
}
示例3: Trajectory
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
public Trajectory(int color, float thickness) {
super();
init(true);
Material m = new Material();
m.setColor(color);
setMaterial(m);
mVertexBuffer = ByteBuffer
.allocateDirect(MAX_NUMBER_OF_VERTICES * Geometry3D.FLOAT_SIZE_BYTES)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
}
示例4: initScene
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
@Override
protected void initScene() {
// Create a quad covering the whole background and assign a texture to it where the
// Tango color camera contents will be rendered.
ScreenQuad backgroundQuad = new ScreenQuad();
Material tangoCameraMaterial = new Material();
tangoCameraMaterial.setColorInfluence(0);
// We need to use Rajawali's {@code StreamingTexture} since it sets up the texture
// for GL_TEXTURE_EXTERNAL_OES rendering
mTangoCameraTexture =
new StreamingTexture("camera", (StreamingTexture.ISurfaceListener) null);
try {
tangoCameraMaterial.addTexture(mTangoCameraTexture);
backgroundQuad.setMaterial(tangoCameraMaterial);
} catch (ATexture.TextureException e) {
Log.e(TAG, "Exception creating texture for RGB camera contents", e);
}
getCurrentScene().addChildAt(backgroundQuad, 0);
// Add a directional light in an arbitrary direction.
DirectionalLight light = new DirectionalLight(1, 0.2, -1);
light.setColor(1, 1, 1);
light.setPower(0.8f);
light.setPosition(3, 2, 4);
getCurrentScene().addLight(light);
blue = new Material();
blue.setColor(Color.BLUE);
floorPlan = new FloorPlan(data);
getCurrentScene().addChild(floorPlan);
floorPlan.setVisible(renderVirtualObjects);
}
示例5: addAxis
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
private void addAxis(Vector3 direction, int color) {
Stack<Vector3> points = new Stack<Vector3>();
points.add(new Vector3());
points.add(direction);
Line3D line = new Line3D(points, mThickness);
Material material = new Material();
material.setColor(color);
line.setMaterial(material);
addChild(line);
}
示例6: Points
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
public Points(int numberOfPoints) {
super();
mMaxNumberofVertices = numberOfPoints;
init(true);
Material m = new Material();
m.setColor(Color.GREEN);
setMaterial(m);
}
示例7: Trajectory
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
public Trajectory(int color, float thickness) {
super();
init(true);
Material m = new Material();
m.setColor(color);
setMaterial(m);
mVertexBuffer = ByteBuffer
.allocateDirect(mMaxNumberOfVertices * Geometry3D.FLOAT_SIZE_BYTES)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
}
示例8: initScene
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
@Override
protected void initScene() {
// Remember to call super.initScene() to allow TangoRajawaliArRenderer to set-up
super.initScene();
// Add a directional light in an arbitrary direction
DirectionalLight light = new DirectionalLight(1, 0.2, -1);
light.setColor(1, 1, 1);
light.setPower(0.8f);
light.setPosition(3, 2, 4);
getCurrentScene().addLight(light);
// Set-up a material: green with application of the light and instructions
Material material = new Material();
material.setColor(0xff009900);
try {
Texture t = new Texture("instructions", R.drawable.instructions);
material.addTexture(t);
} catch (ATexture.TextureException e) {
e.printStackTrace();
}
material.setColorInfluence(0.1f);
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
// Build a Cube and place it initially in the origin
mObject = new Cube(CUBE_SIDE_LENGTH);
mObject.setMaterial(material);
mObject.setPosition(0, 0, -3);
mObject.setRotation(Vector3.Axis.Z, 180);
getCurrentScene().addChild(mObject);
}
示例9: getMaterialForMesh
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
private Material getMaterialForMesh(Object3D o, String name) {
Material mat = new Material();
FBXMaterial material = null;
Stack<Connect> conns = mFbx.connections.connections;
int num = conns.size();
String materialName = null;
for(int i=0; i<num; ++i) {
if(conns.get(i).object2.equals(name)) {
materialName = conns.get(i).object1;
break;
}
}
if(materialName != null) {
Stack<FBXMaterial> materials = mFbx.objects.materials;
num = materials.size();
for(int i=0; i<num; ++i) {
if(materials.get(i).name.equals(materialName)) {
material = materials.get(i);
break;
}
}
}
if(material != null) {
mat.setDiffuseMethod(new DiffuseMethod.Lambert());
mat.enableLighting(true);
Vector3 color = material.properties.diffuseColor;
mat.setColor(Color.rgb((int)(color.x * 255.f), (int)(color.y * 255.f), (int)(color.z * 255.f)));
color = material.properties.ambientColor;
mat.setAmbientColor(Color.rgb((int)(color.x * 255.f), (int)(color.y * 255.f), (int)(color.z * 255.f)));
float intensity = material.properties.ambientFactor.floatValue();
mat.setAmbientIntensity(intensity, intensity, intensity);
if(material.shadingModel.equals("phong"))
{
SpecularMethod.Phong method = new SpecularMethod.Phong();
if(material.properties.specularColor != null)
{
color = material.properties.specularColor;
method.setSpecularColor(Color.rgb((int)(color.x * 255.f), (int)(color.y * 255.f), (int)(color.z * 255.f)));
}
if(material.properties.shininess != null)
method.setShininess(material.properties.shininess);
}
}
return mat;
}
示例10: Grid
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
public Grid(int size, int step, float thickness, int color) {
super(calculatePoints(size, step), thickness, color);
Material material = new Material();
material.setColor(color);
this.setMaterial(material);
}
示例11: getMaterialForMesh
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
private Material getMaterialForMesh(Object3D o, String name) {
Material mat = new Material();
FBXMaterial material = null;
Stack<Connect> conns = mFbx.connections.connections;
int num = conns.size();
String materialName = null;
for(int i=0; i<num; ++i) {
if(conns.get(i).object2.equals(name)) {
materialName = conns.get(i).object1;
break;
}
}
if(materialName != null) {
Stack<FBXMaterial> materials = mFbx.objects.materials;
num = materials.size();
for(int i=0; i<num; ++i) {
if(materials.get(i).name.equals(materialName)) {
material = materials.get(i);
break;
}
}
}
if(material != null) {
mat.setDiffuseMethod(new DiffuseMethod.Lambert());
mat.enableLighting(true);
Vector3 color = material.properties.diffuseColor;
mat.setColor(Color.rgb((int)(color.x * 255.f), (int)(color.y * 255.f), (int)(color.z * 255.f)));
color = material.properties.ambientColor;
mat.setAmbientColor(Color.rgb((int)(color.x * 255.f), (int)(color.y * 255.f), (int)(color.z * 255.f)));
float intensity = material.properties.ambientFactor.floatValue();
mat.setAmbientIntensity(intensity, intensity, intensity);
if(material.shadingModel.equals("phong"))
{
SpecularMethod.Phong method = new SpecularMethod.Phong();
if(material.properties.specularColor != null)
{
color = material.properties.specularColor;
method.setSpecularColor(Color.rgb((int)(color.x * 255.f), (int)(color.y * 255.f), (int)(color.z * 255.f)));
}
if(material.properties.shininess != null)
method.setShininess(material.properties.shininess);
}
}
return mat;
}
示例12: renderColorPicking
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
/**
* Renders the object for color-picking
*
* @param camera The camera
* @param pickingMaterial The color-picking Material
*/
public void renderColorPicking(final Camera camera, final Material pickingMaterial) {
if (!mIsVisible && !mRenderChildrenAsBatch)
// Neither the object nor any of its children are visible
return;
// Color-picking assumes much of the object state set in the prior frame is intact:
// No need to prerender (color-picking always runs before any children changes)
// All matrices already updated during prior frame
// Bounding box already transformed
mIsInFrustum = true; // only if mFrustrumTest == true it check frustum
if (mFrustumTest && mGeometry.hasBoundingBox()) {
BoundingBox bbox = mGeometry.getBoundingBox();
if (!camera.getFrustum().boundsInFrustum(bbox)) {
mIsInFrustum = false;
}
}
// Render this object only if it has visible geometry and didn't fail frustum test
if (!mIsContainerOnly && mIsInFrustum && mIsVisible) {
// Render same faces as visible render
if (mDoubleSided) {
GLES20.glDisable(GLES20.GL_CULL_FACE);
} else {
GLES20.glEnable(GLES20.GL_CULL_FACE);
if (mBackSided) {
GLES20.glCullFace(GLES20.GL_FRONT);
} else {
GLES20.glCullFace(GLES20.GL_BACK);
GLES20.glFrontFace(GLES20.GL_CCW);
}
}
// Blending and depth testing are set up globally in Scene.doColorPicking()
// Material setup is independent of batching, and has no need for
// shader params, textures, normals, vertex colors, or current object...
pickingMaterial.useProgram();
pickingMaterial.setVertices(mGeometry.getVertexBufferInfo());
pickingMaterial.setColor(mPickingColor);
pickingMaterial.applyParams();
// Unbind the array buffer
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
// Apply this object's matrices to the pickingMaterial
pickingMaterial.setMVPMatrix(mMVPMatrix);
pickingMaterial.setModelMatrix(mMMatrix);
pickingMaterial.setModelViewMatrix(mMVMatrix);
// Draw the object using its picking color
int bufferType = mGeometry.getIndexBufferInfo().bufferType == Geometry3D.BufferType.SHORT_BUFFER ? GLES20.GL_UNSIGNED_SHORT : GLES20.GL_UNSIGNED_INT;
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, mGeometry.getIndexBufferInfo().bufferHandle);
GLES20.glDrawElements(mDrawingMode, mGeometry.getNumIndices(), bufferType, 0);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
// Only need to undo face culling
if (mDoubleSided) {
GLES20.glEnable(GLES20.GL_CULL_FACE);
} else if (mBackSided) {
GLES20.glCullFace(GLES20.GL_BACK);
}
}
// No need to draw bounding volumes..
// Draw children without frustum test
for (int i = 0, j = mChildren.size(); i < j; i++) {
// Child rendering is independent of batching, and matrices already updated
mChildren.get(i).renderColorPicking(camera, pickingMaterial);
}
// No textures to unbind, all done
}
示例13: makeFixedObjects
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
private void makeFixedObjects() {
try {
// Make fixed objects
Object3D obj = null;
LoaderOBJ loader = new LoaderOBJ(mContext.getResources(),
mRenderer.getTextureManager(), R.raw.destroyer_obj);
loader.parse();
obj = loader.getParsedObject();
obj.enableLookAt();
obj.setScale(20f);
Material objMaterial = new Material();
objMaterial.setDiffuseMethod(new DiffuseMethod.Lambert());
//objMaterial.setColorInfluence(0);
objMaterial.enableLighting(true);
objMaterial.setColor(0xff444444);
obj.setMaterial(objMaterial);
mRenderer.getCurrentScene().addChild(obj);
// LoaderAWD loader = new LoaderAWD(mContext.getResources(), mRenderer.getTextureManager(),
// R.raw.space_cruiser);
// loader.parse();
//
// Material cruiserMaterial = new Material();
// cruiserMaterial.setDiffuseMethod(new DiffuseMethod.Lambert());
// cruiserMaterial.setColorInfluence(0);
// cruiserMaterial.enableLighting(true);
// cruiserMaterial.addTexture(new Texture("spaceCruiserTex", R.drawable.space_cruiser_4_color_1));
//
// Object3D obj = loader.getParsedObject();
// obj.setMaterial(cruiserMaterial);
// obj.setScale(10);
// obj.setZ(-6);
// obj.setY(1);
// mRenderer.getCurrentScene().addChild(obj);
mDestroyer = new Destroyer(obj);
mDestroyer.initBoundingBox();
} catch(Exception e) {
e.printStackTrace();
}
}