| 1023 | } |
| 1024 | |
| 1025 | bool MeshRoad::onAdd() |
| 1026 | { |
| 1027 | if ( !Parent::onAdd() ) |
| 1028 | return false; |
| 1029 | |
| 1030 | // Reset the World Box. |
| 1031 | //setGlobalBounds(); |
| 1032 | resetWorldBox(); |
| 1033 | |
| 1034 | // Set the Render Transform. |
| 1035 | setRenderTransform(mObjToWorld); |
| 1036 | |
| 1037 | // Add to ServerMeshRoadSet |
| 1038 | if ( isServerObject() ) |
| 1039 | { |
| 1040 | getServerSet()->addObject( this ); |
| 1041 | } |
| 1042 | |
| 1043 | if ( isClientObject() ) |
| 1044 | _initMaterial(); |
| 1045 | |
| 1046 | // If this road was not created from a file, give profile two default nodes |
| 1047 | if(mSideProfile.mNodes.empty()) |
| 1048 | { |
| 1049 | // Initialize with two nodes in vertical line with unit length |
| 1050 | MeshRoadProfileNode node1(Point3F(0.0f, 0.0f, 0.0f)); |
| 1051 | MeshRoadProfileNode node2(Point3F(0.0f, -5.0f, 0.0f)); |
| 1052 | |
| 1053 | mSideProfile.mNodes.push_back(node1); |
| 1054 | mSideProfile.mNodes.push_back(node2); |
| 1055 | |
| 1056 | // Both node normals are straight to the right, perpendicular to the profile line |
| 1057 | VectorF norm(1.0f, 0.0f, 0.0f); |
| 1058 | |
| 1059 | mSideProfile.mNodeNormals.push_back(norm); |
| 1060 | mSideProfile.mNodeNormals.push_back(norm); |
| 1061 | |
| 1062 | mSideProfile.mSegMtrls.push_back(MeshRoad::Side); |
| 1063 | } |
| 1064 | else |
| 1065 | mSideProfile.generateNormals(); |
| 1066 | |
| 1067 | // Generate the Vert/Index buffers and everything else. |
| 1068 | _regenerate(); |
| 1069 | |
| 1070 | // Add to Scene. |
| 1071 | addToScene(); |
| 1072 | |
| 1073 | return true; |
| 1074 | } |
| 1075 | |
| 1076 | void MeshRoad::onRemove() |
| 1077 | { |
nothing calls this directly
no test coverage detected