本文整理汇总了C++中TriMesh::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ TriMesh::SetName方法的具体用法?C++ TriMesh::SetName怎么用?C++ TriMesh::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriMesh
的用法示例。
在下文中一共展示了TriMesh::SetName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateBox
//----------------------------------------------------------------------------
void EditMap::CreateBox (PX2::APoint pos)
{
PX2::Texture2D *tex = DynamicCast<PX2::Texture2D>(
ResourceManager::GetSingleton().BlockLoad("ToolRes/images/default.png"));
if (!tex)
return;
StandardMesh stdMesh(mVertexFormat);
TriMesh *mesh = stdMesh.Box(1, 1, 1);
mesh->SetName("NoName");
Texture2DMaterialPtr material = new0 Texture2DMaterial;
mesh->SetMaterialInstance(material->CreateInstance(tex));
ActorPtr actor = new0 Actor();
actor->SetName("NoName");
actor->SetMovable(mesh);
actor->SetPosition(pos);
actor->ComeInToEventWorld();
AddActor(actor);
Event *event = 0;
event = EditorEventSpace::CreateEventX
(EditorEventSpace::AddActor);
event->SetData<Actor*>(actor);
EventWorld::GetSingleton().BroadcastingLocalEvent(event);
ActorAddDeleteCommand *command = new0 ActorAddDeleteCommand(actor);
EditSystem::GetSingleton().GetCM()->PushUnDo(command);
}
示例2: ReadNextExactToken
Node<real>* SceneImporter<real>::ReadTriMesh( std::istream& stream, const std::string& name )
{
TriMesh<real>* triMesh = new TriMesh<real>;
triMesh->SetName( name );
ReadGeometryHeader( stream, triMesh ); ReadNextExactToken( stream, "," );
std::string filename = ReadString( stream );
triMesh->Load( filename );
return triMesh;
}
示例3: CreateFace
//----------------------------------------------------------------------------
BoxSurface::BoxSurface (BSplineVolumef* volume, int numUSamples,
int numVSamples, int numWSamples, VertexFormat* vformat[6])
:
mVolume(volume),
mNumUSamples(numUSamples),
mNumVSamples(numVSamples),
mNumWSamples(numWSamples),
mDoSort(false)
{
int permute[3];
TriMesh* mesh;
// u faces
permute[0] = 1;
permute[1] = 2;
permute[2] = 0;
// u = 0
mesh = CreateFace(mNumWSamples, mNumVSamples, vformat[0], false, 0.0f,
permute);
mesh->SetName("u0");
AttachChild(mesh);
// u = 1
mesh = CreateFace(mNumWSamples, mNumVSamples, vformat[1], true, 1.0f,
permute);
mesh->SetName("u1");
AttachChild(mesh);
// v faces
permute[0] = 0;
permute[1] = 2;
permute[2] = 1;
// v = 0
mesh = CreateFace(mNumWSamples, mNumUSamples, vformat[2], true, 0.0f,
permute);
mesh->SetName("v0");
AttachChild(mesh);
// v = 1
mesh = CreateFace(mNumWSamples, mNumUSamples, vformat[3], false, 1.0f,
permute);
mesh->SetName("v1");
AttachChild(mesh);
// w faces
permute[0] = 0;
permute[1] = 1;
permute[2] = 2;
// w = 0
mesh = CreateFace(mNumVSamples, mNumUSamples, vformat[4], false, 0.0f,
permute);
mesh->SetName("w0");
AttachChild(mesh);
// w = 1
mesh = CreateFace(mNumVSamples, mNumUSamples, vformat[5], true, 1.0f,
permute);
mesh->SetName("w1");
AttachChild(mesh);
}
示例4: GetMesh
//----------------------------------------------------------------------------
TriMesh* SkinnedBiped::GetMesh (const std::string& name, Node* biped)
{
// Load the triangle indices and material.
std::string filename = name + ".triangle.raw";
std::string path = Environment::GetPathR(filename);
FileIO inFile(path, FileIO::FM_DEFAULT_READ);
int numTriangles;
inFile.Read(sizeof(int), &numTriangles);
int numIndices = 3*numTriangles;
IndexBuffer* ibuffer = new0 IndexBuffer(numIndices, sizeof(int));
int* indices = (int*)ibuffer->GetData();
inFile.Read(sizeof(int), numIndices, indices);
Material* material = new0 Material();
Float4 emissive, ambient, diffuse, specular;
inFile.Read(sizeof(float), 3, &material->Emissive);
material->Emissive[3] = 1.0f;
inFile.Read(sizeof(float), 3, &material->Ambient);
material->Ambient[3] = 1.0f;
inFile.Read(sizeof(float), 3, &material->Diffuse);
material->Diffuse[3] = 1.0f;
inFile.Read(sizeof(float), 3, &material->Specular);
material->Specular[3] = 0.0f;
inFile.Close();
// Load the skin controller.
filename = name + ".skin.raw";
path = Environment::GetPathR(filename);
inFile.Open(path, FileIO::FM_DEFAULT_READ);
int repeat;
float minTime, maxTime, phase, frequency;
inFile.Read(sizeof(float), &repeat);
inFile.Read(sizeof(float), &minTime);
inFile.Read(sizeof(float), &maxTime);
inFile.Read(sizeof(float), &phase);
inFile.Read(sizeof(float), &frequency);
int numVertices, numBones;
inFile.Read(sizeof(int), &numVertices);
inFile.Read(sizeof(int), &numBones);
SkinController* ctrl = new0 SkinController(numVertices, numBones);
ctrl->Repeat = (Controller::RepeatType)repeat;
ctrl->MinTime = (double)minTime;
ctrl->MaxTime = (double)maxTime;
ctrl->Phase = (double)phase;
ctrl->Frequency = (double)frequency;
Node** bones = ctrl->GetBones();
int i;
for (i = 0; i < numBones; ++i)
{
int length;
inFile.Read(sizeof(int), &length);
char* boneName = new1<char>(length + 1);
inFile.Read(sizeof(char), length, boneName);
boneName[length] = 0;
bones[i] = (Node*)biped->GetObjectByName(boneName);
assertion(bones[i] != 0, "Failed to find bone.\n");
delete1(boneName);
}
float** weights = ctrl->GetWeights();
APoint** offsets = ctrl->GetOffsets();
for (int j = 0; j < numVertices; ++j)
{
for (i = 0; i < numBones; ++i)
{
inFile.Read(sizeof(float), &weights[j][i]);
inFile.Read(sizeof(float), 3, &offsets[j][i]);
}
}
inFile.Close();
int vstride = mVFormat->GetStride();
VertexBuffer* vbuffer = new0 VertexBuffer(numVertices, vstride);
// Set positions and normals to zero for now. The controller update
// will set the initial values.
memset(vbuffer->GetData(), 0, numVertices*vstride);
TriMesh* mesh = new0 TriMesh(mVFormat, vbuffer, ibuffer);
mesh->SetName(name);
mesh->AttachController(ctrl);
mesh->SetEffectInstance(LightDirPerVerEffect::CreateUniqueInstance(
mLight, material));
return mesh;
}
示例5: CreateControlBoxes
//----------------------------------------------------------------------------
void FreeFormDeformation::CreateControlBoxes ()
{
// Generate small boxes to represent the control points.
mControlRoot = new0 Node();
mTrnNode->AttachChild(mControlRoot);
// Create a single box to be shared by each control point box.
const float halfWidth = 0.02f;
VertexFormat* vformat = VertexFormat::Create(1,
VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0);
int vstride = vformat->GetStride();
VertexBuffer* vbuffer = new0 VertexBuffer(8, vstride);
VertexBufferAccessor vba(vformat, vbuffer);
vba.Position<Vector3f>(0) = Vector3f(-halfWidth, -halfWidth, -halfWidth);
vba.Position<Vector3f>(1) = Vector3f(+halfWidth, -halfWidth, -halfWidth);
vba.Position<Vector3f>(2) = Vector3f(+halfWidth, +halfWidth, -halfWidth);
vba.Position<Vector3f>(3) = Vector3f(-halfWidth, +halfWidth, -halfWidth);
vba.Position<Vector3f>(4) = Vector3f(-halfWidth, -halfWidth, +halfWidth);
vba.Position<Vector3f>(5) = Vector3f(+halfWidth, -halfWidth, +halfWidth);
vba.Position<Vector3f>(6) = Vector3f(+halfWidth, +halfWidth, +halfWidth);
vba.Position<Vector3f>(7) = Vector3f(-halfWidth, +halfWidth, +halfWidth);
IndexBuffer* ibuffer = new0 IndexBuffer(36, sizeof(int));
int* indices = (int*)ibuffer->GetData();
indices[ 0] = 0; indices[ 1] = 2; indices[ 2] = 1;
indices[ 3] = 0; indices[ 4] = 3; indices[ 5] = 2;
indices[ 6] = 4; indices[ 7] = 5; indices[ 8] = 6;
indices[ 9] = 4; indices[10] = 6; indices[11] = 7;
indices[12] = 0; indices[13] = 5; indices[14] = 4;
indices[15] = 0; indices[16] = 1; indices[17] = 5;
indices[18] = 3; indices[19] = 7; indices[20] = 6;
indices[21] = 3; indices[22] = 6; indices[23] = 2;
indices[24] = 1; indices[25] = 2; indices[26] = 6;
indices[27] = 1; indices[28] = 6; indices[29] = 5;
indices[30] = 0; indices[31] = 4; indices[32] = 7;
indices[33] = 0; indices[34] = 7; indices[35] = 3;
// Create the materials and light to be attached to each box.
Material* materialActive = new0 Material();
materialActive->Emissive = Float4(0.0f, 0.0f, 0.0f, 1.0f);
materialActive->Ambient = Float4(1.0f, 0.0f, 0.0f, 1.0f);
materialActive->Diffuse = Float4(1.0f, 0.0f, 0.0f, 1.0f);
materialActive->Specular = Float4(0.0f, 0.0f, 0.0f, 1.0f);
Material* materialInactive = new0 Material();
materialInactive->Emissive = Float4(0.0f, 0.0f, 0.0f, 1.0f);
materialInactive->Ambient = Float4(0.75f, 0.75f, 0.75f, 1.0f);
materialInactive->Diffuse = Float4(0.75f, 0.75f, 0.75f, 1.0f);
materialInactive->Specular = Float4(0.0f, 0.0f, 0.0f, 1.0f);
Light* light = new0 Light(Light::LT_AMBIENT);
light->Ambient = Float4(1.0f, 1.0f, 1.0f, 1.0f);
light->Diffuse = Float4(1.0f, 1.0f, 1.0f, 1.0f);
light->Specular = Float4(0.0f, 0.0f, 0.0f, 1.0f);
LightAmbEffect* effect = new0 LightAmbEffect();
mControlActive = effect->CreateInstance(light, materialActive);
mControlInactive = effect->CreateInstance(light, materialInactive);
for (int i0 = 0; i0 < mQuantity; ++i0)
{
for (int i1 = 0; i1 < mQuantity; ++i1)
{
for (int i2 = 0; i2 < mQuantity; ++i2)
{
TriMesh* box = new0 TriMesh(vformat, vbuffer, ibuffer);
Vector3f ctrl = mVolume->GetControlPoint(i0, i1, i2);
box->LocalTransform.SetTranslate(ctrl);
// Encode the indices in the name for later use. This will
// allow fast lookup of volume control points.
char name[32];
sprintf(name, "%d %d %d", i0, i1, i2);
box->SetName(name);
box->SetEffectInstance(mControlInactive);
mControlRoot->AttachChild(box);
}
}
}
}