Essentially what I have for attaching items is this:
if(attachMesh && attachMesh.name.toLowerCase().search("attachpoint") <
0)
{
newMesh = new
Mesh();
attachMesh.cloneAll(newMesh);
newMesh.x +=
containerCentriod.x - attachCentriod.x;
newMesh.y +=
containerCentriod.y - attachCentriod.y;
newMesh.z +=
containerCentriod.z - attachCentriod.z;
newMesh.rotationX = parentObject.rotationX;
newMesh.rotationY = parentObject.rotationY;
newMesh.rotationZ = parentObject.rotationZ;
parentObject.addToMesh(newMesh);
m_bAttached =
true;
}
We have a special model mesh in our models called the attachpoint.
This object specifies the location of where the attached Model,
newMesh is added to in our parentObject.
On Jun 3, 5:06 pm, Fabrice3D <[email protected]> wrote:
> > Kind of but not really
> > The issue is that the mesh itself adopts the
> > parents coordinates,
>
> mmm, that's what I do not follow entirely... any code, url ??
> you mean you say m.x = 100, move its parent container and its position is
> still 100.
> why not read/use scenePosition instead to calculate the offsets you want to
> apply to mesh position.
>
> > However, according to the faces, in the mathematical
> > sense they have not moved, only the mesh.
>
> thats what I ment in previous mesaage. you need to apply the faces at object
> coordinates not at scene coordinates.
>
> but at this point we need see stuff in order to be able to help...
>
> Fabrice
>
> On Jun 3, 2010, at 9:51 PM, Reinorvak wrote:
>
> > Hey Fabrice,
>
> > Kind of but not really. The issue is that the mesh itself adopts the
> > parents coordinates, then I offset that mesh by a set amount to get it
> > visually correct. However, according to the faces, in the mathematical
> > sense they have not moved, only the mesh. This creates a box within
> > another box if you were to construct 2 BVHs. This however, according
> > to the visual model it is not correct since the attached mesh has been
> > offset by a certain amount.
>
> > I've tried using the function updateVertex by the new Mesh's position
> > but to no avail.
>
> > On Jun 3, 2:51 pm, Fabrice3D <[email protected]> wrote:
> >> i'm not sure I follow your description,
> >> But if you have an object in a container, if you access the mesh, you need
> >> to add the faces at space object coordinates
> >> they automatically get the offset of the parent coordinates.
>
> >> now, another possible cause is the goemetry object.
> >> somehow, that thing sticks in ram.
> >> so before fill with new faces, just m.geometry = null, m.geometry=new
> >> Geometry(), then fill using addface.
> >> of course if previous geometry object olds faces, loop over the faces
> >> array and delete them or store them, if you want to reuse.
>
> >> but thats a shot in the dark to help you, as I'm not certain of the exact
> >> issue you're having.
>
> >> Fabrice
> >> On Jun 3, 2010, at 8:12 PM, Reinorvak wrote:
>
> >>> Greetings everyone,
>
> >>> Alright here's the scoop this time. I've got my own custom BVH,
> >>> Bounding Volume Hierarchy, class set up to surround all the objects in
> >>> this game. This was set up before 3.5 came out and we don't have
> >>> enough time to switch over to the newest version so we're using 2.3.
>
> >>> The big problem is, when I add a new mesh to a previously existing
> >>> object, the faces of the new mesh believe they are at the origin of
> >>> the object it was attached to. Visually, the items show up fine, but
> >>> this offset of having the item at 0,0,0 instead of its correct local
> >>> space position is ruining the BVH creation algorithm.
>
> >>> So mostly what I'm asking for is this, is there anyway to update the
> >>> faces correctly to the new mesh position with distorting the model in
> >>> any way or form. I've tried a few things here and there, but nothing
> >>> solid has occurred out yet.
>
> >>> Most appreciated,
> >>> Rein