Crazy Calculations ... why?
Posted: Sun Feb 15, 2015 3:04 am
Code: Select all
GroundMesh=LoadMesh(-1, "terrain0101gr.mesh")
GroundEntity=CreateEntity(-1, MeshID(GroundMesh), MaterialID(GroundMaterial), 0,0,0,1)
SizeX.f=(EntityBoundingBox(GroundEntity, #PB_Entity_MaxBoundingBoxX | #PB_Entity_LocalBoundingBox) - EntityBoundingBox(GroundEntity, #PB_Entity_MinBoundingBoxX | #PB_Entity_LocalBoundingBox))
SizeXA.f=(EntityBoundingBox(GroundEntity, #PB_Entity_MaxBoundingBoxX) - EntityBoundingBox(GroundEntity, #PB_Entity_MinBoundingBoxX))
ScaleX.f=1024.0 / SizeX
Debug SizeX
Debug SizeXA
Debug ScaleX
ScaleEntity(GroundEntity, ScaleX, ScaleX, ScaleX)
SizeX.f=(EntityBoundingBox(GroundEntity, #PB_Entity_MaxBoundingBoxX | #PB_Entity_LocalBoundingBox) - EntityBoundingBox(GroundEntity, #PB_Entity_MinBoundingBoxX | #PB_Entity_LocalBoundingBox))
SizeXA.f=(EntityBoundingBox(GroundEntity, #PB_Entity_MaxBoundingBoxX) - EntityBoundingBox(GroundEntity, #PB_Entity_MinBoundingBoxX))
Debug SizeX
Debug SizeXA
510.10809326171875
1.0
2.00741767883301
510.10809326171875
1.0
Code: Select all
Debug "X="+StrF(EntityX(TRexEntity),2)+" Y="+StrF(EntityY(TRexEntity),2)+" Z="+StrF(EntityZ(TRexEntity),2)
SizeX.f=(EntityBoundingBox(GroundEntity, #PB_Entity_MaxBoundingBoxX | #PB_Entity_LocalBoundingBox) - EntityBoundingBox(GroundEntity, #PB_Entity_MinBoundingBoxX | #PB_Entity_LocalBoundingBox))
SizeXA.f=(EntityBoundingBox(GroundEntity, #PB_Entity_MaxBoundingBoxX) - EntityBoundingBox(GroundEntity, #PB_Entity_MinBoundingBoxX))
Debug SizeX
Debug SizeXA
Debug Results
X=499.43 Y=9.00 Z=-501.21
510.10809326171875
1024.0
But the Corners are exact 500, 500 -500,500 etc.
They should be 512, 512 etc.
When I move the Model further than 502 (ModelBoundingBox 4x12 in meters) at the edges lets say to 511.9, 511.9 it falls down into the deep of virtual space
The point is: I made an Array where I placed Trees and Plants - but they did not fit exactly with my calcutated Positions. they are some Meters away as further they are placed to the edges
Actually the World Positions are 512,512 but it needs another Function to get them ...
Code: Select all
ConvertLocalToWorldPosition(EntityID(TRexEntity), EntityX(TRexEntity), EntityY(TRexEntity), EntityZ(TRexEntity))
Debug GetX()
Debug GetY()
Debug GetZ()
X=501.04 Y=72.15 Z=-501.51
P=0.00 Y=-22.00 R=0.00
X = 519.8310546875
Y = 74.22801208496094
Z = -509.49676513671875
And even that is not the last word as seen ... there must be at least another calculation to calculate Model and LandscapeMesh (No Terrain) Position that they fit ...
Was there really no way to solve this more elegant?
http://www.rrsoftware.net/uploads/Forum ... 035702.jpg
........................
PS to Forum Admin:
Is it not wanted to see images? As you can see, the link to the image works. When I add the img /img tags I get the message that the dimensions of the image could not be determined and I cannot submit this post.
No difference if its png or jpg