Comments (2)
I just updated the VertexAnimationObject3D to work the EXTRA SLOW effect:
private float[] mInterPolatedVerts =null;
private float[] mInterPolatedNormals =null;
public VertexAnimationObject3D() {
super();
}
public VertexAnimationObject3D(SerializedObject3D ser) {
super(ser);
float[][] v = ser.getFrameVertices();
float[][] n = ser.getFrameNormals();
mNumFrames = v.length;
for(int i=0; i<mNumFrames; ++i) {
VertexAnimationFrame frame = new VertexAnimationFrame();
frame.getGeometry().setVertices(v[i]);
frame.getGeometry().setNormals(n[i]);
frame.getGeometry().createVertexAndNormalBuffersOnly();
mFrames.add(frame);
}
}
public void preRender() {
if (!mIsPlaying || !mUpdateVertices) return;
mCurrentTime = System.currentTimeMillis();
VertexAnimationFrame currentFrame = (VertexAnimationFrame) mFrames.get(mCurrentFrameIndex);
VertexAnimationFrame nextFrame = (VertexAnimationFrame) mFrames.get((mCurrentFrameIndex + 1) % mNumFrames);
if (mCurrentFrameName != null && !mCurrentFrameName.equals(currentFrame.getName())) {
if (!mLoop)
stop();
else
mCurrentFrameIndex = mLoopStartIndex;
return;
}
/*
mMaterial.setInterpolation(mInterpolation);
mMaterial.setNextFrameVertices(nextFrame.getGeometry().getVertexBufferHandle());
mMaterial.setNextFrameNormals(nextFrame.getGeometry().getNormalBufferHandle());
*/
int numVerts = currentFrame.getGeometry().getVerticesF().length;
float[] currentVerts = currentFrame.getGeometry().getVerticesF();
float[] nextVerts = nextFrame.getGeometry().getVerticesF();
float[] currentNormals = currentFrame.getGeometry().getNormalsF();
float[] nextNormals = nextFrame.getGeometry().getNormalsF();
if (mInterPolatedVerts==null) {
mInterPolatedVerts = new float[numVerts];
mInterPolatedNormals = new float[numVerts];
}
for (int i = 0; i < numVerts; i += 3) {
mInterPolatedVerts[i] = currentVerts[i] + mInterpolation * (nextVerts[i] - currentVerts[i]);
mInterPolatedVerts[i + 1] = currentVerts[i + 1] + mInterpolation * (nextVerts[i + 1] - currentVerts[i + 1]);
mInterPolatedVerts[i + 2] = currentVerts[i + 2] + mInterpolation * (nextVerts[i + 2] - currentVerts[i + 2]);
mInterPolatedNormals[i] = currentNormals[i] + mInterpolation * (nextNormals[i] - currentNormals[i]);
mInterPolatedNormals[i + 1] = currentNormals[i + 1] + mInterpolation * (nextNormals[i + 1] - currentNormals[i + 1]);
mInterPolatedNormals[i + 2] = currentNormals[i + 2] + mInterpolation * (nextNormals[i + 2] - currentNormals[i + 2]);
}
//setVertices
mGeometry.setVertices(mInterPolatedVerts);
mGeometry.setNormals(mInterPolatedNormals);
mGeometry.createVertexAndNormalBuffersOnly();
mGeometry.setVertexBufferHandle(mGeometry.getVertexBufferHandle());
mGeometry.setNormalBufferHandle(mGeometry.getNormalBufferHandle());
mMaterial.setInterpolation(mInterpolation);
mMaterial.setNextFrameVertices(mGeometry.getVertexBufferHandle());
mMaterial.setNextFrameNormals(mGeometry.getNormalBufferHandle());
//
mInterpolation += (float) mFps * (mCurrentTime - mStartTime) / 1000;
if (mInterpolation >= 1) {
mInterpolation = 0;
mCurrentFrameIndex++;
if (mCurrentFrameIndex >= mNumFrames)
mCurrentFrameIndex = 0;
/*
mGeometry.setVertexBufferHandle(nextFrame.getGeometry().getVertexBufferHandle());
mGeometry.setNormalBufferHandle(nextFrame.getGeometry().getNormalBufferHandle());
*/
}
mStartTime = mCurrentTime;
}
public void reload() {
super.reload();
for (int i = 0; i < mNumFrames; i++) {
mFrames.get(i).getGeometry().reload();
}
}
and in the mGeometry.java
public float[] getNormalsF() {
return this.mNormalsF;
}
and
public float[] getVerticesF() {
return this.mVerticesF;
}
returns the vertices, and normals array
lacroix
from rajawali.
Cheers man, very much appreciated.
Why not fork Rajawali, make the changes and then submit a pull request?
Will save me some work and we'll use the true power of Github :-)
from rajawali.
Related Issues (20)
- jcenter repository has been depracated
- Seeking Luminance based desaturation
- Seeking Lighten and Darken Blend Modes
- Seeking point texture plugin
- improving SpriteSheetMaterialPlugin efficiency HOT 1
- Seeking Flexible Sprite Sheet Animation
- Seeking runtime adjustment of AlphaMask threshold
- Please restore AnimatedSpritesFragment to example app
- Stencil Buffer is not initializing corrrectly,
- Some `ScreenQuad` materials spew error messages at frame rate
- Objects starts to render with delay when camera if far from them HOT 1
- How to translate object with touch screen?
- anyway to implement ray in the library?
- Create Sphere with phiStart, phiLength, thetaStart, thetaLength HOT 1
- LoaderFBX.java:347 ArrayIndexOutOfBoundsException
- display obj model in AR
- Examples are broken
- When will the new version be released?
- load obj file fail,NumberFormatException: For input string: "nan"
- Caused by: org.rajawali3d.loader.ParsingException: Couldn't find texture ingrid HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rajawali.