internal LightData(BinaryReader br, Map map, SharedForms.Output outForm) { mNumSamples = br.ReadInt32(); int numFaces = br.ReadInt32(); mLightPoints = new Vector3[numFaces][]; mInSolid = new bool[numFaces][]; mPlanes = new GFXPlane[numFaces]; mFInfos = new FInfo[numFaces]; outForm.Print("Reading " + numFaces + " faces...\n"); outForm.UpdateProgress(0, numFaces, 0); int numPointsTotal = 0; for (int i = 0; i < numFaces; i++) { int numPoints = br.ReadInt32(); mLightPoints[i] = new Vector3[numPoints]; mInSolid[i] = new bool[numPoints]; for (int j = 0; j < numPoints; j++) { mLightPoints[i][j] = FileUtil.ReadVector3(br); mInSolid[i][j] = map.IsPointInSolidSpace(mLightPoints[i][j]); numPointsTotal++; } mPlanes[i] = new GFXPlane(); mPlanes[i].Read(br); bool bFInfo = br.ReadBoolean(); if (bFInfo) { mFInfos[i] = new FInfo(); mFInfos[i].ReadVecs(br); } outForm.UpdateProgress(0, numFaces, i); } outForm.UpdateProgress(0, numFaces, 0); outForm.Print("Read " + numPointsTotal + " total points.\n"); }
public void MakeDrawStuff(Device dev, Vector3 [] facePoints, bool [] inSolid, GFXPlane facePlane, int numSamples) { if (facePoints.Length <= 0) { return; } //free existing if any if (mVB != null) { mVB.Dispose(); } VPosNormCol0 [] vpc = new VPosNormCol0[facePoints.Length * 2]; int sampIdx = 0; int j = 0; int sampPoints = facePoints.Length / numSamples; int sampCounter = 0; for (int i = 0; i < facePoints.Length; i++) { vpc[j].Position = facePoints[i]; vpc[j].Normal.X = facePlane.mNormal.X; vpc[j].Normal.Y = facePlane.mNormal.Y; vpc[j].Normal.Z = facePlane.mNormal.Z; vpc[j].Normal.W = 1f; if (sampIdx == 0) { vpc[j++].Color0 = inSolid[i]? Color.Red : Color.Green; vpc[j].Position = facePoints[i] + facePlane.mNormal * 3f; vpc[j].Color0 = inSolid[i]? Color.Red : Color.Green; } else { vpc[j++].Color0 = Color.Blue; vpc[j].Position = facePoints[i] + facePlane.mNormal * 1f; vpc[j].Color0 = inSolid[i]? Color.Red : Color.Blue; } vpc[j].Normal.X = facePlane.mNormal.X; vpc[j].Normal.Y = facePlane.mNormal.Y; vpc[j].Normal.Z = facePlane.mNormal.Z; vpc[j++].Normal.W = 1f; sampCounter++; if (sampCounter >= sampPoints) { sampIdx++; sampCounter = 0; } } mVertCount = j; mVB = VertexTypes.BuildABuffer(dev, vpc, vpc[0].GetType()); mVBBinding = VertexTypes.BuildAVBB(VertexTypes.GetIndex(vpc[0].GetType()), mVB); }