moving vertex groups (without?) an armature?

Is it possible to move a vertex group without using an armature? I’m trying to make lasers that have their “endpoints” always at the ship’s target’s position… but am having a bit of difficulty. I tried experimenting with mesh.getVertex() but it appears that the setXYZ method isn’t accurate to world coords?

Any tips/suggestions? Here’s a few screenshots to better explain what I mean

As you can see, the endpoints don’t meet up with the target :stuck_out_tongue:


default laser position


I want to be able to move the ends via code so that they are always long enough to appear to be in contact with the target.


Firstly, you can use mesh.getXYZ to translate to world coordinates. Multiplying by the object.worldTransform will rotate and scale the corrdinates correctly. However there is a new feature with the mesh -> transform.
You could use a scale matrix and use this function http://www.blender.org/documentation/blender_python_api_2_66_release/bge.types.KX_MeshProxy.html#bge.types.KX_MeshProxy.transform

getXYZ did it, thanks for that :slight_smile:

result (using distance formula):




Much simpler is to scale the complete laserbeam. Ensure the origin is on one end of the beam mesh and the length is 1.0 when scale is 1.0 (along the length axis).

You can even do that with an action:
keyframe 1 = scale 1.0 (along the length axis)
Keyframe 2 = scale 2.0 (along the length axis)

Set the curve to extrapolation extension (Curve Editor).
Play in property mode. The size will be according to the property value

The advantage is you do not need different meshes for different beams.

great idea! but how would you figure out how much it needs to be scaled? (currently I use distance formula to figure out where to put the endpoints) but distance formula wouldn’t apply correctly to scaling (that I know of? I suppose i can give it a try).

The scale is simply the distance to the endpoint. Indeed you need to turn the beam into the right direction.

http://www.blender.org/documentation/blender_python_api_2_66_release/bge.types.KX_MeshProxy.html#bge.types.KX_MeshProxy.transform

transform(matid, matrix)Transforms the vertices of a mesh.[TABLE=“class: docutils field-list, width: 0”]
[TR=“class: field-odd field”]
[TH=“class: field-name, bgcolor: #EEDDEE, align: left”]Parameters:[/TH]

  • matid (integer) – material index, -1 transforms all.
  • matrix (4x4 matrix [[float]]) – transformation matrix.

[/TR]
[/TABLE]

transform -->> to ???

why is not written also in “XXX spaces” !? …just 2 words