本文整理汇总了Java中org.rajawali3d.materials.Material.enableLighting方法的典型用法代码示例。如果您正苦于以下问题:Java Material.enableLighting方法的具体用法?Java Material.enableLighting怎么用?Java Material.enableLighting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.rajawali3d.materials.Material
的用法示例。
在下文中一共展示了Material.enableLighting方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareMissile
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
private void prepareMissile() {
// Make object model of missile.
// When user fire missile, this object will be cloned
try {
mMissileObj = new Cube(0.12f);
Material boxMaterial = new Material();
boxMaterial.setDiffuseMethod(new DiffuseMethod.Lambert());
//material.setColorInfluence(0);
boxMaterial.enableLighting(false);
//mMissileObj.setMaterial(new DiffuseMaterial());
mMissileObj.setMaterial(boxMaterial);
mMissileObj.setX(0); mMissileObj.setY(0); mMissileObj.setZ(0);
//mMissileObj.setRenderChildrenAsBatch(true);
mRenderer.getCurrentScene().addChild(mMissileObj);
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: 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);
}
示例3: initScene
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
protected void initScene() {
mLight = new DirectionalLight(.3f, -.3f, -1);
mLight.setPower(1f);
getCurrentScene().addLight(mLight);
mLight.setPosition(-2, 1, 4);
mPicker = new ObjectColorPicker(this);
mPicker.setOnObjectPickedListener(this);
ArcballCamera arcball = new ArcballCamera(mContext, ((Activity)mContext).findViewById(R.id.drawer_layout));
arcball.setPosition(0, 0, 10);
getCurrentScene().replaceAndSwitchCamera(getCurrentCamera(), arcball);
Material material = new Material();
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
LoaderOBJ objParser = new LoaderOBJ(mContext.getResources(), mTextureManager, R.raw.industryrobot_obj);
try {
objParser.parse();
mObjectGroup = objParser.getParsedObject();
mObjectGroup.setScale(0.0025f);
mObjectGroup.setZ(-2);
mObjectGroup.setY(-5);
mPicker.registerObject(mObjectGroup);
//getCurrentScene().addChild(mObjectGroup);
} catch (ParsingException e) {
e.printStackTrace();
}
box();
fillBox(material);
mObjectGroup.setMaterial(material);
}
示例4: initScene
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
@Override
protected void initScene() {
try {
mLight = new DirectionalLight(0.1f, -1.0f, -1.0f);
mLight.setColor(1.0f, 1.0f, 1.0f);
mLight.setPower(1);
getCurrentScene().addLight(mLight);
final LoaderAWD parser = new LoaderAWD(mContext.getResources(), mTextureManager, R.raw.head_object_new);
parser.parse();
mMonkey = parser.getParsedObject();
mMonkey.setScale(0.005f);
//mMonkey.setZ(-2f);
// getCurrentScene().addChild(mMonkey);
int[] resourceIds = new int[]{R.drawable.posx, R.drawable.negx,
R.drawable.posy, R.drawable.negy, R.drawable.posz,
R.drawable.negz};
Material material = new Material();
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
CubeMapTexture envMap = new CubeMapTexture("environmentMap",
resourceIds);
envMap.isEnvironmentTexture(true);
material.addTexture(envMap);
material.setColorInfluence(0);
mMonkey.setMaterial(material);
LoaderOBJ objParser1 = new LoaderOBJ(mContext.getResources(), mTextureManager, R.raw.glasses_obj);
objParser1.parse();
mGlasses = objParser1.getParsedObject();
mGlasses.setScale(0.005f);
//mGlasses.setZ(-0.2f);
mGlasses.setZ(0.3f);
mGlasses.rotate(Vector3.Axis.X, -90.0f);
LoaderOBJ objParser2 = new LoaderOBJ(mContext.getResources(), mTextureManager, R.raw.hair_band_obj);
objParser2.parse();
mHairBand = objParser2.getParsedObject();
mHairBand.setScale(0.006f);
mHairBand.setY(0.27f);
mHairBand.setZ(-0.25f);
mHairBand.rotate(Vector3.Axis.X, -90.0f);
LoaderOBJ objParser3 = new LoaderOBJ(mContext.getResources(), mTextureManager, R.raw.moustache_obj);
objParser3.parse();
mMoustache = objParser3.getParsedObject();
mMoustache.setScale(0.007f);
mMoustache.setY(-0.25f);
mMoustache.setZ(0.3f);
mMoustache.rotate(Vector3.Axis.X, -90.0f);
mContainer = new Object3D();
mContainer.addChild(mMonkey);
mContainer.addChild(mGlasses);
mContainer.addChild(mHairBand);
mContainer.addChild(mMoustache);
getCurrentScene().addChild(mContainer);
//getCurrentCamera().setZ(20);
} catch (Exception e) {
e.printStackTrace();
}
// -- set the background color to be transparent
// you need to have called setGLBackgroundTransparent(true); in the activity
// for this to work.
getCurrentScene().setBackgroundColor(0);
}
示例5: 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;
}
示例6: createObjects
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
private void createObjects() throws TextureException, ParsingException, SkeletalAnimationException {
SkeletalAnimationObject3D root = new SkeletalAnimationObject3D();
root.uBoneMatrix = mBindPoseMatrix;
root.mInverseBindPoseMatrix = mInverseBindPoseMatrix;
root.setJoints(mJoints);
mRootObject = root;
for (int i = 0; i < mNumMeshes; ++i) {
SkeletonMeshData mesh = mMeshes[i];
SkeletalAnimationChildObject3D o = new SkeletalAnimationChildObject3D();
o.setData(
mesh.vertices, GLES20.GL_STREAM_DRAW,
mesh.normals, GLES20.GL_STREAM_DRAW,
mesh.textureCoordinates, GLES20.GL_STATIC_DRAW,
null, GLES20.GL_STATIC_DRAW,
mesh.indices, GLES20.GL_STATIC_DRAW,
false);
o.setMaxBoneWeightsPerVertex(mesh.maxBoneWeightsPerVertex);
o.setSkeletonMeshData(mesh.numVertices, mesh.boneVertices, mesh.numWeights, mesh.boneWeights);
o.setName("MD5Mesh_" + i);
o.setSkeleton(mRootObject);
o.setInverseZScale(true);
boolean hasTexture = mesh.textureName != null && mesh.textureName.length() > 0;
Material mat = new Material();
mat.addPlugin(new SkeletalAnimationMaterialPlugin(mNumJoints, mesh.maxBoneWeightsPerVertex));
mat.enableLighting(true);
mat.setDiffuseMethod(new DiffuseMethod.Lambert());
o.setMaterial(mat);
if (!hasTexture) {
o.setColor(0xff000000 + (int) (Math.random() * 0xffffff));
} else {
int identifier = mResources.getIdentifier(mesh.textureName, "drawable",
mResources.getResourcePackageName(mResourceId));
if (identifier == 0) {
throw new ParsingException("Couldn't find texture " + mesh.textureName);
}
mat.setColorInfluence(0);
mat.addTexture(new Texture("md5tex" + i, identifier));
}
mRootObject.addChild(o);
mesh.destroy();
mesh = null;
}
}
示例7: 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;
}
示例8: createObjects
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
private void createObjects() throws TextureException, ParsingException, SkeletalAnimationException {
SkeletalAnimationObject3D root = new SkeletalAnimationObject3D();
root.uBoneMatrix = mBindPoseMatrix;
root.mInverseBindPoseMatrix = mInverseBindPoseMatrix;
root.setJoints(mJoints);
mRootObject = root;
for (int i = 0; i < mNumMeshes; ++i) {
SkeletonMeshData mesh = mMeshes[i];
SkeletalAnimationChildObject3D o = new SkeletalAnimationChildObject3D();
o.setData(
mesh.vertices, GLES20.GL_STREAM_DRAW,
mesh.normals, GLES20.GL_STREAM_DRAW,
mesh.textureCoordinates, GLES20.GL_STATIC_DRAW,
null, GLES20.GL_STATIC_DRAW,
mesh.indices, GLES20.GL_STATIC_DRAW,
false);
o.setMaxBoneWeightsPerVertex(mesh.maxBoneWeightsPerVertex);
o.setSkeletonMeshData(mesh.numVertices, mesh.boneVertices, mesh.numWeights, mesh.boneWeights);
o.setName("MD5Mesh_" + i);
o.setSkeleton(mRootObject);
o.setInverseZScale(true);
boolean hasTexture = mesh.textureName != null && mesh.textureName.length() > 0;
Material mat = new Material();
mat.addPlugin(new SkeletalAnimationMaterialPlugin(mNumJoints, mesh.maxBoneWeightsPerVertex));
mat.enableLighting(true);
mat.setDiffuseMethod(new DiffuseMethod.Lambert());
o.setMaterial(mat);
if (!hasTexture) {
o.setColor(0xff000000 + (int) (Math.random() * 0xffffff));
} else {
int identifier = mResources.getIdentifier(mesh.textureName, "drawable",
mResources.getResourcePackageName(mResourceId));
if (identifier == 0) {
throw new ParsingException("Couldn't find texture " + mesh.textureName);
}
mat.setColorInfluence(0);
mat.addTexture(new Texture("md5tex" + i, identifier));
}
mRootObject.addChild(o);
mesh.destroy();
mesh = null;
}
}
示例9: 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();
}
}
示例10: makeMothership
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
private void makeMothership() {
try {
CatmullRomCurve3D path;
LoaderAWD loader = new LoaderAWD(mContext.getResources(),
mRenderer.getTextureManager(), R.raw.capital);
loader.parse();
Material capitalMaterial = new Material();
capitalMaterial.setDiffuseMethod(new DiffuseMethod.Lambert());
capitalMaterial.setColorInfluence(0);
capitalMaterial.enableLighting(true);
capitalMaterial.addTexture(new Texture("capitalTex", R.drawable.hullw));
capitalMaterial.addTexture(new NormalMapTexture("capitalNormTex", R.drawable.hulln));
mMothershipObj = loader.getParsedObject();
mMothershipObj.setMaterial(capitalMaterial);
mMothershipObj.setScale(5);
mMothershipObj.enableLookAt();
mRenderer.getCurrentScene().addChild(mMothershipObj);
path = new CatmullRomCurve3D();
path.addPoint(new Vector3(0, 15, 100));
path.addPoint(new Vector3(-100, 15, 0));
path.addPoint(new Vector3(0, 15, -100));
path.addPoint(new Vector3(100, 15, 0));
path.isClosedCurve(true);
mMothershipAnim = new SplineTranslateAnimation3D(path);
mMothershipAnim.setDurationMilliseconds(ANIM_DURATION);
mMothershipAnim.setRepeatMode(Animation.RepeatMode.INFINITE);
mMothershipAnim.setOrientToPath(true);
mMothershipAnim.setTransformable3D(mMothershipObj);
mRenderer.getCurrentScene().registerAnimation(mMothershipAnim);
mMothershipAnim.play();
mMothership = new Mothership(mMothershipObj);
} catch (Exception e) {
e.printStackTrace();
}
}