If you think the Android project Schooner-3D listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright 2012 Dan Mercer//www.java2s.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.supermercerbros.gameengine.objects;
import android.util.Log;
import com.supermercerbros.gameengine.animation.AnimationData;
import com.supermercerbros.gameengine.animation.MeshAnimation;
import com.supermercerbros.gameengine.engine.Normals;
import com.supermercerbros.gameengine.engine.shaders.Material;
/**
* Represents an animated 3D mesh object.
*/publicclass AnimatedMeshObject extends GameObject {
privatestaticfinal String TAG = "com.supermercerbros.gameengine.objects.GameObject";
private MeshAnimation anim;
private AnimationData data;
/**
* Contains {@link MeshAnimation}s associated with this GameObject. The
* GameObject itself doesn't do anything with them; this is merely for
* transportation to the client.
*/private MeshAnimation[] anims;
public AnimatedMeshObject(float[] verts, short[] indices, float[] uvs,
float[] normals, Material mtl, short[][] doubles) {
super(verts, indices, normals, uvs, doubles, mtl);
data = new AnimationData();
}
@Override
publicvoid drawVerts(long time) {
Log.d(TAG, "AnimatedMeshObject.drawVerts(" + time + ") was called.");
if (anim != null) {
anim.getFrame(time, data, this);
Normals.calculate(this);
}
super.drawVerts(time);
}
publicvoid setAnimation(MeshAnimation anim, long startTime, long duration,
int loop) {
this.anim = anim;
this.data.setDuration(duration);
this.data.setStartTime(startTime);
this.data.setLoop(loop);
this.data.setInitialState(verts);
this.data.setCallTime(System.currentTimeMillis());
}
publicvoid clearAnimation() {
this.anim = null;
}
/**
* Attaches the given {@link MeshAnimation}s to this AnimatedMeshObject.
* These animations are not used by the GameObject in any way - this is
* used solely for transportation to the client.
*
* @param anims The animations to attach.
*/publicvoid attachAnims(MeshAnimation[] anims) {
this.anims = anims;
}
/**
* Gets the {@link MeshAnimation}s attached to this AnimatedMeshObject.
* These animations are not used by the GameObject in any way - this is
* used solely for transportation to the client.
*
* @return The {@link MeshAnimation}s attached to this AnimatedMeshObject.
*/public MeshAnimation[] getAnims() {
return this.anims;
}
}