本文整理汇总了C++中CObject3D类的典型用法代码示例。如果您正苦于以下问题:C++ CObject3D类的具体用法?C++ CObject3D怎么用?C++ CObject3D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CObject3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SplitOneSector
/*
* Split one sector by a 3D object.
*/
void CWorld::SplitOneSector(CBrushSector &bscToSplit, CObject3D &obToSplitBy)
{
// get the brush mip from sector to split
CBrushMip *pbmMip = bscToSplit.bsc_pbmBrushMip;
// create object to split from sector to split and destroy the sector
CBrushSectorSelectionForCSG selbscToSplit;
selbscToSplit.Select(bscToSplit);
CObject3D obToSplit;
pbmMip->ToObject3D(obToSplit, selbscToSplit);
pbmMip->DeleteSelectedSectors(selbscToSplit);
// copy ambient value from the sector to split to the sector to split with
obToSplitBy.ob_aoscSectors.Lock();
obToSplitBy.ob_aoscSectors[0].osc_colAmbient = bscToSplit.bsc_colAmbient;
obToSplitBy.ob_aoscSectors[0].osc_colColor = bscToSplit.bsc_colColor;
obToSplitBy.ob_aoscSectors[0].osc_ulFlags[0] = bscToSplit.bsc_ulFlags;
obToSplitBy.ob_aoscSectors[0].osc_ulFlags[1] = bscToSplit.bsc_ulFlags2;
obToSplitBy.ob_aoscSectors[0].osc_ulFlags[2] = bscToSplit.bsc_ulVisFlags;
obToSplitBy.ob_aoscSectors.Unlock();
// do 'split sectors' CSG with the objects
CObject3D obResult;
_pfWorldEditingProfile.StartTimer(CWorldEditingProfile::PTI_OBJECTCSG);
obResult.CSGSplitSectors(obToSplit, obToSplitBy);
_pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_OBJECTCSG);
// return the result to the source brush mip
try {
pbmMip->AddFromObject3D_t(obResult);
} catch (char *strError) {
FatalError("Unexpected error during split sectors operation: %s", strError);
}
}
示例2: glPushMatrix
void CSceneGraph::glDraw4Picking(void)
{
const int pickingstype = (int)m_nPickingType;
int i, k;
int nsize = m_SceneList.size();
//Apr. 25, 2007
//in volman, the startobjid is modified as 1
const int startobjid = 0;
for (i=k=startobjid; i<nsize; i++){
CSceneNode &node = m_SceneList[i];
glPushMatrix();
if (node.m_pFrame) glMultMatrixd(node.m_pFrame->matrix());
CObject3D *pobj = node.m_pObject;
CGLDrawParms *pdraw = &node.m_DrawParms;
assert(pobj!=NULL);
pdraw->BeginDrawing();
switch(pickingstype){
case 0:
pobj->DrawPickingObject(k);
break;
case 1:
pobj->DrawPickingObjectFace(k);
break;
case 2:
pobj->DrawPickingObjectLine(k);
break;
};
k+= pobj->GetPickableElementCount(pickingstype);
pdraw->PostDrawing();
glPopMatrix();
}
}
示例3: CPointLight
CRocket::CRocket(void)
{
static bool loaded = false;
static CObject3D *model = CModelLoader::Get("models/Small_Rocket_B.3ds");
if (!loaded)
{
((CMesh*)model->children[0]->children[0])->Reposition();
loaded = true;
}
CObject3D* mesh = model->Copy();
mesh->SetScale(0.1);
mesh->MoveRight(-1.25f);
mesh->MoveForward(-0.5 + 1);
mesh->MoveUp(-0.25-0.2f);
this->Add(mesh);
boundingShape = EBoundingShape::Sphere;
followTarget = false;
light = new CPointLight(Vector3(), YELLOW);
//light->range = 3.0f;
this->Add(light);
}
示例4: UnsplitObjectCount
int CCia3dObj::GetTotalTriangleCount(void)
{
int i, ntri=0;
int nobj = UnsplitObjectCount();
for (i=0; i<nobj; i++){
CObject3D * p = m_pObjList[i];
const char *des = p->Description();
if (strcmp(des, "tri") == 0){ //a triangle mesh;
CTriangleObj *ptri = (CTriangleObj*)p;
int nn = ptri->m_nPolygonCount;
ntri+=nn;
}
}
return ntri;
}
示例5: _exportPovrayMesh
void CSceneGraph::_exportPovrayMesh(FILE *fp)
{
int i;
const int nsize = m_SceneList.size();
//draw all the objects;
for (i=0; i<nsize; i++){
CSceneNode &node = m_SceneList[i];
CObject3D *pobj = node.m_pObject;
assert(pobj!=NULL);
const double *matrix = node.m_pFrame->matrix();
fprintf(fp, "#declare %s =\n", pobj->GetObjectName());
pobj->exportFile(fp, ".pov", matrix);
fprintf(fp, "\n\n\n");
}
}
示例6:
int CCia3dObj::ObjectCount(int objidbuff[], const int bufflen)
{
int i, j;
CDynamicArray<int> A;
for (i=0; i<CIA3D_SUBOBJ_LIMIT; i++){
CObject3D *p = m_pObjList[i];
if (p==NULL) continue;
int bsize= p->ObjectCount(objidbuff, bufflen);
for (j=0; j<bsize; j++)
A.AddWithNoDuplication(objidbuff[j]);
}
int asize = A.GetSize();
assert(asize>0 && asize<bufflen);
for (i=0; i<asize; i++)
objidbuff[i] = A[i];
return asize;
}
示例7: _getObjectAndLineID
static void
_getObjectAndLineID(const int picktype, const int pickedid, CSceneGraph &scene, int& objid, int& vid1, int &vid2)
{
int i, c1, c2;
for (i=0, c1=0; i<scene.size(); i++){
CSceneNode *p = scene.GetSceneNode(i);
CObject3D *pobj = p->m_pObject;
if (!pobj) continue;
c2 = c1+ pobj->GetPickableElementCount(picktype);
if (pickedid>=c1 && objid<c2){ //obj found;
pobj->GetPickedLine(pickedid-c1, vid1, vid2);
objid = i;
if (picktype==CSceneGraph::PICK_LINE)
DUMP_LINE_INFO((CPolyObj*)pobj, vid1, vid2);
break;
}
c1=c2;
}
}
示例8: ExportPovrayObjects
static void ExportPovrayObjects(CSceneGraph & sg, FILE *fp)
{
int i;
const int nsize = sg.size();
if (nsize==0) return;
//draw all the objects;
fprintf(fp, "union{\n");
for (i=0; i<nsize; i++){
CSceneNode *node = sg.GetSceneNode(i);
CObject3D *pobj = node->m_pObject;
assert(pobj!=NULL);
fprintf(fp, "object {\n");
fprintf(fp, "\t%s\n", pobj->GetObjectName());
fprintf(fp, "\ttexture { CIA3DTex%d }\n", i);
//fprintf(fp, "\ttexture { White_Chocolate }\n");
fprintf(fp, "}\n");
}
fprintf(fp, "}\n\n\n");
}
示例9: _getObjectAndFaceID
static void
_getObjectAndFaceID(const CSceneGraph::PICKING_TYPE_ID picktype,
const int pickedid, CSceneGraph &scene, int& objid, int& faceid)
{
int c1=0, c2=0;
objid=-1, faceid=-1;
for (int i=0; i<scene.size(); i++){
CSceneNode *p = scene.GetSceneNode(i);
CObject3D *pobj = p->m_pObject;
if (!pobj) continue;
c2 = c1+ pobj->GetPickableElementCount(picktype);
if (pickedid>=c1 && pickedid<c2){ // find obj;
objid = i;
faceid = pickedid - c1;
if (picktype==CSceneGraph::PICK_FACE)
DUMP_POLY_INFO((CPolyObj*)pobj, faceid);
break;
}
c1=c2;
}
}
示例10: _glDrawNodeBoundingBox
static void _glDrawNodeBoundingBox(CSceneNode *pnode, const Vector3f &linecolor)
{
if (pnode==NULL) return;
glPushMatrix();
if (pnode->m_pFrame) glMultMatrixd(pnode->m_pFrame->matrix());
CGLDrawParms *pdraw = &pnode->m_DrawParms;
pdraw->BeginDrawing();
CObject3D *p = pnode->m_pObject;
if (p == NULL)
p= pnode->m_pSimulationObject;
AxisAlignedBox box;
p->GetBoundingBox(box);
glDisable(GL_TEXTURE_1D);
glDisable(GL_TEXTURE_2D);
glLineWidth(2);
glColor3f(linecolor.x, linecolor.y, linecolor.z);
glDisable(GL_LIGHTING);
const Vector3d& p0=box.minp;
const Vector3d& p1=box.maxp;
DrawBoundingBox(p0, p1);
const Vector3d dist = (p1 - p0)*0.33;
glLineWidth(4);
glColor3f(1.0,0,0);
glBegin(GL_LINES);
glVertex3f(p0.x, p0.y, p0.z);
glVertex3f(p0.x+dist.x, p0.y, p0.z);
glEnd();
glColor3f(0,1,0);
glBegin(GL_LINES);
glVertex3f(p0.x, p0.y, p0.z);
glVertex3f(p0.x, dist.y+p0.y, p0.z);
glEnd();
glColor3f(0,0,1);
glBegin(GL_LINES);
glVertex3f(p0.x, p0.y, p0.z);
glVertex3f(p0.x, p0.y, p0.z+dist.z);
glEnd();
pdraw->PostDrawing();
glPopMatrix();
}
示例11: ASSERT
/*
* Copy selected sectors of a source brush to a 3D object.
*/
void CWorld::CopySourceBrushSectorsToObject(
CEntity &enBrush,
CBrushSectorSelectionForCSG &bscselSectors,
const CPlacement3D &plSourcePlacement,
CObject3D &obObject,
const CPlacement3D &plTargetPlacement,
DOUBLEaabbox3D &boxSourceAbsolute
)
{
ASSERT(GetFPUPrecision()==FPT_53BIT);
// get the brush mip from the entity
CBrushMip &bmBrushMip = *GetBrushMip(enBrush);
// calculate placement of the brush in absolute space (taking relative
// world placement and entity placement in account)
CPlacement3D plBrush = enBrush.en_plPlacement;
plBrush.RelativeToAbsolute(plSourcePlacement);
// copy selected sectors of brush to object3d object
bmBrushMip.ToObject3D(obObject, bscselSectors);
// make a copy of the object and find its box in absolute space
CObject3D obAbsolute;
obAbsolute = obObject;
CSimpleProjection3D_DOUBLE prToAbsolute;
prToAbsolute.ObjectPlacementL() = plBrush;
prToAbsolute.ViewerPlacementL() = CPlacement3D(FLOAT3D(0,0,0), ANGLE3D(0,0,0));
prToAbsolute.Prepare();
obAbsolute.Project(prToAbsolute);
obAbsolute.GetBoundingBox(boxSourceAbsolute);
// project the brush into target space
CSimpleProjection3D_DOUBLE prSimple;
prSimple.ObjectPlacementL() = plBrush;
prSimple.ViewerPlacementL() = plTargetPlacement;
prSimple.Prepare();
obObject.Project(prSimple);
}
示例12: TransformCallback
void CPhysics::TransformCallback(const NewtonBody* body, const float* matrix, int threadIndex)
{
CObject3D *object = (CObject3D*)NewtonBodyGetUserData(body);
float m[16];
NewtonBodyGetMatrix(body, m);
Matrix4 M = Matrix4(m);
Vector3 destination = M.GetPosition();
Vector3 velocity = (destination - object->GetWorldPosition()) * object->physicsDelay;
object->velocity = velocity;
Vector3 pos = object->position;
object->SetMatrix( Matrix4(m) );
object->SetPosition(pos);
// setting entire matrix each physics frame might cause desync with the renderer,
// that might run more often, resulting in drawing the object in the same location
// twice in a row
// Instead each physics frame we set the object's velocity so that it reaches
// the desginated position in 1/10th of a second
}
示例13: while
void CScene3D::Render()
{
if(m_Camera)
{
CMatrix4 viewproj = m_Camera->GetProjection();
viewproj *= m_Camera->GetView();
m_Render->SetTransform(ETT_VIEWPROJ, viewproj);
}
else
return;
const CViewFrustum& frustum = m_Camera->GetFrustum();
m_RenderList.Clear();
m_Octree.GetVisibleList(frustum, m_RenderList);
CList<CObject3D*>::CIterator its = m_RenderList.Begin();
while(its != m_RenderList.End())
{
CObject3D* drw = *its;
drw->Render();
#ifdef _DEBUG
drw->DebugRender();
#endif
++its;
}
#ifdef _DEBUG
m_Octree.DebugRender(frustum);
m_Render->SetTransform(ETT_MODEL, CMatrix4::IDENTY);
CDebugRenderer::Instance()->Render();
#endif
}
示例14: CheckMesh
//////////////////////////////////////////////////////////////////////////
// Check if given object is in frustum
//////////////////////////////////////////////////////////////////////////
bool CFrustum::CheckMesh( CObject3D &mesh )
{
Vector3 pos = mesh.GetWorldPosition();
if (mesh.boundingShape == EBoundingShape::Box)
{
Vector3 size = mesh.geometry->boundingBox.GetSize();
size.x *= mesh.scale.x;
size.y *= mesh.scale.y;
size.z *= mesh.scale.z;
Vector3 pos = mesh.GetWorldPosition();
pos.x += (mesh.geometry->boundingBox.min.x + size.x/2) * mesh.scale.x;
pos.y += (mesh.geometry->boundingBox.min.y + size.y/2) * mesh.scale.y;
pos.z += (mesh.geometry->boundingBox.min.z + size.z/2) * mesh.scale.z;
return CheckBox(pos.x, pos.y, pos.z, size.x, size.y, size.z);
}
else
{
float maxScale = max(max(mesh.scale.x, mesh.scale.y), mesh.scale.z);
float boundingRadius = maxScale * mesh.geometry->boundingSphere;
return CheckSphere(pos.x, pos.y, pos.z, boundingRadius);
}
}
示例15: ObjectCount
int CCia3dObj::ObjectSplit(CCia3dObj * buff[], const int bufflen)
{
const int idsize = 2048;
int objidbuff[idsize], objidbuff2[idsize];
CObject3D * pobjs[idsize];
const int n1 = ObjectCount(objidbuff, idsize);
if (n1==1){
printf("There is only one object, no need to split!\n");
assert(0);
}
for (int i=0; i<n1; i++){
buff[i] = new CCia3dObj;
assert(buff[i]!=NULL);
}
for (int i=0; i<CIA3D_SUBOBJ_LIMIT; i++){
CObject3D *p = m_pObjList[i];
if (p==NULL)
break;
const int n2 = p->ObjectCount(objidbuff2, idsize);
if (n2==1){
int key = objidbuff2[0];
int index = SEARCH_KEY_POS(objidbuff, n1, key);
buff[index]->addObject(p);
p->SetCustomizedObjectName(index);
}
else{
const int n3 = p->SplitIntoSubObj(objidbuff2, n2, pobjs);
assert(n3==n2);
for (int j=0; j<n2; j++){
CObject3D * pobj = pobjs[j];
int key = objidbuff2[j];
int index = SEARCH_KEY_POS(objidbuff, n1, key);
buff[index]->addObject(pobj);
pobj->SetCustomizedObjectName(index);
}
delete p;
}
m_pObjList[i] = NULL;
}
return 1;
}