Recent Posts

Pages: 1 ... 8 9 [10]
91
Support / Asymmetrical Scaling
« Last post by AGP on June 21, 2018, 06:24:00 am »
I'm trying to create a flickering glow. To that end, I wrote the following thickening method in a vertex controller. The problem happens when the base object, from which the glow object is created, is rotated because the glow appears to be modified in worldspace as opposed to in objectspace. What should I do to calculate the x/z distortion in objectspace?

Code: [Select]
     public void thicken(final float deltaTime) {
SimpleVector[] vertices = this.getSourceMesh();
SimpleVector[] destination = this.getDestinationMesh();
for (int i = 0; i < vertices.length; i++) {
     SimpleVector v = vertices[i];
     v.x *= (1f+deltaTime);
     v.z *= (1f+deltaTime);
     destination[i] = v;
}
this.updateMesh();
     }
92
 Since I've already solved it, there's no problem. But what I did there was a splitter: the MD2 exporter exports all animations as a single stream. My program splits them and saves a serialized copy.
93
I think that I don't understand your actual problem. The idea is: You create a new sub sequence, add all the keyframes, continue with the next one. If you animate a sequence, it's limited to that sequence's animations unless you animate 0, which includes all keyframes. What's the actual issue with that?
94
Some things use the 0, some don't. This print works. The above parsing had but one problem: it was always restarting the keyframes (I just added a delta at the end of the inner loop).

Code: [Select]
     private void printAnimations() {
System.out.println("****************Animations****************");
Animation animation = model.getAnimationSequence();
animationNames = new String[animation.getSequenceCount()];
for (int i = 0; i < animationNames.length; i++) {
     animationNames[i] = animation.getName(i+1);//i+1
     int[] borders = animation.getSequenceBorders(animation.getSequence(animationNames[i]));
     System.out.println("Animation: "+animationNames[i] +", start: "+borders[0] +" end: "+borders[1]);
}
System.out.println("****************Animations****************\n");
      }
95
OK, but if it's by design that the animation in slot 0, as printed by the following code, is "complete," then my problem is that the last animation sub-sequence isn't being created. But there are no complaints about the amount of frames and my method prints a message after finishing its parsing.

Code: [Select]
     private void print() {
Animation animation = model.getAnimationSequence();
String[] animationNames = new String[animation.getSequenceCount()];
for (int i = 0; i < animationNames.length; i++) {
     animationNames[i] = animation.getName(i);
     System.out.println("Animation: "+animationNames[i] +", start: "+animation.getSequenceBorders(i+1)[0] +" end: "+animation.getSequenceBorders(i+1)[1]);
}
     }
96
IIRC, it's by design. The docs say:

Quote
The sub-sequence will be numbered starting from 1. 0 is a special case as is represents the animation as a whole.

Isn't that what you are experiencing?
97
This is an animation splitter. The following code, instead of naming the first clip the first animation's name, names the second animation that. The second gets the first one's name, the third the second's, and so forth. The first clip seems to get an automatic name of "complete:"

Code: [Select]
     Mesh[] keyFrames = singleStream.getKeyFrames();
     Animation animations = new Animation(keyFrames.length);
     int numberOfAnimations, totalFramesInMax = 0;
     for (numberOfAnimations = 0; numberOfAnimations < nameFields.length && nameFields[numberOfAnimations].getText().trim().length() > 0; numberOfAnimations++)
totalFramesInMax += Integer.parseInt(numberOfFramesFields[numberOfAnimations].getText().trim());
     double divider = (double)totalFramesInMax/(double)keyFrames.length;
     System.out.println("Total Frames in Max: "+totalFramesInMax +" Divider: "+divider +" Number of KeyFrames: "+keyFrames.length);
     for (int i = 0; i < numberOfAnimations; i++) {
final int animationFrames = Integer.parseInt(numberOfFramesFields[i].getText().trim());
final int totalFrames = keyFrames.length;
animations.createSubSequence(nameFields[i].getText().trim());
for (int kf = 0; kf < animationFrames/divider; kf++)
     animations.addKeyFrame(keyFrames[kf]);
System.out.println("Finished for: "+nameFields[i].getText());
     }
     model.setAnimationSequence(animations);

Is this a jpct bug?
98
...of keyframes? You should put that in the docs.

For now, I'm going to assume that it is. ; )
99
Thank you. It's done.
100
Hi, as you told,

Quote
1. assign the corresponding texture to the object before merging them all into one
2. let the auto-assignment do it's magic. Looking at your code, it seems like that should work already. Have you tried to remove your texture assigment code and see if works then?

I am not sure how point 1 can be achieved, like how to assign corresponding texture?

And about point 2, I tried removing assignment of texture, but it just displayed the white model.

I tried below code for point 2.

Code: [Select]
.......................................
 Object3D[] objectsArray2 = Loader.loadOBJ
                        (context.getResources().getAssets().open(objFileName), context.getResources()
                                .getAssets().open("smile.mtl"), 4.3f);
                Log.e("obj and mtl", "obj and mtl");

                newObject = Object3D.mergeAll(objectsArray2);

                newObject.setOrigin(new SimpleVector(0, -20, 200));
                newObject.rotateX(-0.2f);
                newObject.rotateY(160.2f);
                newObject.rotateZ(160.2f);
                newObject.setName("smile.obj");
................................................

I don't think this is the right way. If you can elaborate more, how can I achieve, it will be so helpful. Thank you in advance.
Pages: 1 ... 8 9 [10]