I noticed by experience that a Curve (created via a Spline, at least) is not affected by the parent Node’s scale (or so it seems), however it is affected by the Node’s LocalTranslation and LocalRotation
More explicitly, I had
rootNode->subNode->geoBox
rootNode->subNode->geoCurve
and I am trying to rotate the geoBox (which is a Box) and make a Curve geoCurve show a trail of one of this box’s corners, specifically the Vector3f(getXExtent(), getYExtent(), getZExtent()) corner by using this as the in vector to geoBox.getLocalTransform().transformVector( inCorner, store ); in order to find it while the box is rotated/scaled/positioned who knows where, and I use this store as an input to Spline.addControlPoint(store); then I create a new Curve by passing it the Spline each time I update that… I know it’s a bad way, but I am learning so to speak, both jme3 and java, by the way, any hints would be appreciated!
This works “well” if I comment the scale line in simpleInitApp():
subNode.scale(1.3f, 0.7f, 0.4f );
otherwise if I allow it, the Courve is detached from that corner, although the box changed shape, not sure if it considers the box with scale 1… all right, I now see that if I use subNode.scale(anyNumf); it works well, this leads me to believe that only when I use scale(x,y,z) method it doesn’t work as expected. I’m not sure if it’s my fault or anything…
I would’ve posted the code except it’s quite a mess and a part of something more, let me know if I should extract only the needed parts and post it? I wouldn’t mind
Ok here’s the code and screenies(sorry looks like the indentation was lost):
pre type="java" package org.jme3;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Spline;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Curve;
/**
Sample 2 - How to use nodes as handles to manipulate objects in the scene
graph. You can rotate, translate, and scale objects by manipulating their
parent nodes. The Root Node is special: Only what is attached to the Root
Node appears in the scene.
/
public class HelloNode4 extends SimpleApplication {
ok, I looked into this a bit more. I’m not completely sure what’s the issue…but it’s math related. The scale is correctly applied in the engine.
the thing is, you attach th e curve geom and the box geom to a node, you scale the node in the init of the application.
Then you recreate the mesh of the curve on each frame.
The problem is that doing than you change the center of mass of the curve geom, and thus it’s position relative to it’s parent (the scaled node). It works fine with uniform scale because all the dimensions are scaled, but with non uniform it creates some kind of offset. I don’t know for sure the math behind this, but I feel it’s the issue.
Btw it works if just scale the box alone.
I don’t know what you are trying to do here, if it’s for learning purpose it’s fine, but if it’s an effect you want to reuse later, you should not recreate the mesh on each frame. You will trash the memory in no time making the GC crazy, and this will yield poor performance.
If you really want a trailing effect i suggest you use a particle emitter instead of the curve. Use the very same “corner” method for positioning the emitter on each frame, and you’ll have a nice effect.
It was definitely for learning purposes though if I wanted to do it for real I wouldn’t know how, maybe if I rewrite a new Curve class and somehow keep adding to the existing mesh when a new spline point is added, no idea how to do this yet, hopefully after more learning I’d get a clue lol
I’ll try that emitter as you said, though I did want something permanent(like exactly what the Curve does but I did want to avoid ‘new’-ing all the time - did not know how lol), not sure if emitter does that (it was my impression so far that it fades out)
By the way, I did try this after I updated my drivers and restored settings to defaults (had 2 other issues that were existent because of them) though (obviously since you tested it) this issue kept persisting. Hope someone can fix this if it’s an issue in jme3 - hmm, this reminded me of some old code in jme2 which had some issue with the same scale when non-uniform like it wouldn’t detect it hit the sphere… maybe I can find it and test it again (if I remember right, it was one of the main reasons I gave up at that time)
where I basically fail to properly rotate a normal but only when translation of the rootNode is different than 0,0,0 , seems to be unaffected by rootNode’s scale & rotation though
I’ll be posting there my latest modifs which include both this topic’s “bug” and that topic’s “bug” or whatever they are
what that does is showing how the white tip boxes on top of the arrows coords are being affected somehow when parent nodes are transformed, look at rootNode is perfect, yet I’m using the same method of setLocalTranslation
surely I must be missing something, can’t be a jme3 r7281 bug
Finally, this is what’s been done (after 2 jme3 bugfixes by momoko_fan) and after I re-edited my code, this is what works:
a red rotating wireframe Box that leaves a green trail from one of its corners, no matter what the parents of the box and curve are (that is, regardless of their parents’ transforms, the curve is correctly shown)