Scaling a mesh attached to a pivot

Blitz3D Forums/Blitz3D Programming/Scaling a mesh attached to a pivot

PowerPC603(Posted 2004) [#1]
I'm using 3DS Max to create my models and use the B3D pipeline for export to B3D.

When I export the models, I use the option "Add Scene Root" (which AFAIK creates a pivot and attaches all objects in the scene to it).

If I would scale the meshes in Blitz, should I use ScaleEntity or ScaleMesh (when loaded with LoadAnimMesh)?

Or should all children be scaled (and moved) separately within a "For i = 1 to CountChildren(object%)"-loop?

The entire model will be used to represent a spacestation, but with separate pivots at certain points (which indicate where a docking port, defensive turrets, etc. must be attached via code).

I cannot load the stations as 1 object (LoadMesh), as I need the names of those pivots for positioning the correct sub-object at the correct positions.


AntonyWells(Posted 2004) [#2]
You could always export the pivots in a seperate geo-less info .b3d, and just load the visual mesh as a static one. I do it in cryo to get light positions for the cubic lighting, as i had similar probs to do with scaling.


AntonyWells(Posted 2004) [#3]
But to answer your question, children entities don't seem to be updated. When I scaled up the levels, and found the light pivots, I then had to scale the x,y,z manually to match the entity scale. I.e,

scaleMesh yourentity,200,150,200

light=findChild("light")

lightX=entityX(light)*200
lightY=entityY(light)*150
lightZ=entityZ(light)*200


PowerPC603(Posted 2004) [#4]
Then I think the best way to do it is to scale the entire station in 3DS MAX itself.
Then I don't have to scale them anymore.

This way it seems easier to implement.
If all objects must be scaled, then I have to remember the scale for each object separately.
And it makes more code, which isn't really needed if the objects are pre-scaled to fit directly into the game.

Loading the meshes as static meshes isn't an option either.
In the future, some children will be animated with code (rotated and such).

I'm only this far to load the objects and put their handle in an array of types and then fly through the space with a camera.

Much more to come...


PowerPC603(Posted 2004) [#5]
I've just updated my routines and implemented the scaling with ScaleEntity.

And it scales all children too (in fact the entire mesh is scaled).



But one more question:

I intend to put only 1 texture onto the entire station (including the children), so the entire station has only 1 surface.
The texture would be applied with code, so I can put "texture1" onto the station in sector A, and put another texture "texture2" onto the same mesh in sector B.

This way I can create the illusion that these 2 stations are not the same mesh (because they look different in different sectors in space).

But when I would apply the texture onto the mesh (which has a Scene Root), the texture would only be applied to the Scene Root Pivot, am I right?

Then I would have to put the same texture onto all children of the station.
Would this mean that the texture only exists once in memory, or does every child keep it's own copy of the texture (having 10 children would mean the same texture exists 10x in memory)?

The stations are loaded this way:

; Create the 3D-object and store the handle in a temporary variable
TempObject% = LoadMesh("Data\Objects\FFX2Cube.b3d")
TempTex% = LoadTexture("Data\Textures\FFX2.bmp")

EntityTexture TempObject%, TempTex%

; Store the handle to the object in the array for future reference
ArrayJumpgates(SectorNumber%, i)\ObjectHandle% = TempObject%


This would become:

; Create the 3D-object and store the handle in a temporary variable
TempObject% = LoadAnimMesh("Data\Objects\FFX2Cube.b3d")
TempTex% = LoadTexture("Data\Textures\FFX2.bmp")

For i = 1 to CountChildren(TempObject%)
    TempChild% = GetChild(TempObject%, i)
    EntityTexture TempChild%, TempTex%
Next

; Store the handle to the object in the array for future reference
ArrayJumpgates(SectorNumber%, i)\ObjectHandle% = TempObject%


The second code would apply the same texture onto all children.

Is this correct?