Rick Posted February 23, 2010 Posted February 23, 2010 Is there a way to convert the value returned from EntityDistance() to a value to pass as a scale to ScaleEntity()? Quote
Josh Posted February 23, 2010 Posted February 23, 2010 I am not sure what you are trying to do, but the math will be easiest if you give the mesh dimensions of 1.0 when it is scaled 1,1,1. I assume you are trying to make a mesh span from one point to another. Quote Let's build cool stuff and have fun.
Rick Posted February 23, 2010 Author Posted February 23, 2010 Yeah, I'm trying to scale a mesh from 1 point to another. I kind of have it working although I don't know 100% why it works. I put a pivot at the point of a character and another at the point of where the mouse is clicked on the terrain. Between these 2 points I get the distance between the x & z only. I then use that distance / 10 in the z value of ScaleEntity() and it seems to scale the plane correctly. I also point the character pivot to the mouse clicked pivot and then rotate the plane along the y. This all works, although I don't know why 10 is the magic number to divide by the distance. I also need to increase the segments of the plane a lot since the scale distance can be pretty far it needs a ton of segments in order to hug the terrain. TPick p; CameraPick(&p, GetLayerCamera(GetFrameworkLayer(0)), Vec3(MouseX(), MouseY(), 5000)); TPivot mousePivot = CreatePivot(); TPivot ownerPivot = CreatePivot(); // TODO: This doesn't work, but we only want to set things if it's on the terrain only if(p.surface != 0) { PositionEntity(mousePivot, Vec3(p.X, p.Y, p.Z)); PositionEntity(ownerPivot, GetOwner()->GetPosition()); TVec3 p1 = EntityPosition(mousePivot); TVec3 p2 = EntityPosition(ownerPivot); // Get 2D distance float x = p2.X - p1.X; float y = p2.Z - p1.Z; x = x * x; y = y * y; float distance = sqrt(x + y); PointEntity(ownerPivot, mousePivot); RotateEntity(_plane->GetPlane(), Vec3(0, EntityRotation(ownerPivot).Y, 0)); //float distance = EntityDistance(ownerPivot, mousePivot); ScaleEntity(_plane->GetPlane(), Vec3(1.0, 1.0, distance/10)); ShowEntity(_plane->GetPlane()); } Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.