画torus包围盒正确
This commit is contained in:
@@ -25,6 +25,7 @@ constexpr const COLOR TestColor[]=
|
|||||||
COLOR::BlenderAxisBlue,
|
COLOR::BlenderAxisBlue,
|
||||||
|
|
||||||
COLOR::BananaYellow,
|
COLOR::BananaYellow,
|
||||||
|
COLOR::CherryBlossomPink
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr const size_t COLOR_COUNT=sizeof(TestColor)/sizeof(COLOR);
|
constexpr const size_t COLOR_COUNT=sizeof(TestColor)/sizeof(COLOR);
|
||||||
@@ -54,7 +55,7 @@ private:
|
|||||||
MeshComponentData *data;
|
MeshComponentData *data;
|
||||||
ComponentDataPtr cdp;
|
ComponentDataPtr cdp;
|
||||||
|
|
||||||
MeshComponent *component;
|
MeshComponent *component[7];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -233,14 +234,16 @@ private:
|
|||||||
{
|
{
|
||||||
cci.mat=ScaleMatrix(10,10,1);
|
cci.mat=ScaleMatrix(10,10,1);
|
||||||
|
|
||||||
rm_plane->component=CreateComponent<MeshComponent>(&cci,rm_plane->cdp);
|
//rm_plane->component=CreateComponent<MeshComponent>(&cci,rm_plane->cdp);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
cci.mat=AxisYRotate(deg2rad(90));
|
for(int i=0;i<6;i++)
|
||||||
|
{
|
||||||
rm_torus->component=CreateComponent<MeshComponent>(&cci,rm_torus->cdp);
|
cci.mat=AxisYRotate(deg2rad(i*30.0f));
|
||||||
rm_torus->component->SetOverrideMaterial(solid.mi[1]);
|
rm_torus->component[i]=CreateComponent<MeshComponent>(&cci,rm_torus->cdp);
|
||||||
|
rm_torus->component[i]->SetOverrideMaterial(solid.mi[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
@@ -250,22 +253,44 @@ private:
|
|||||||
{
|
{
|
||||||
CreateComponentInfo cci(GetSceneRoot());
|
CreateComponentInfo cci(GetSceneRoot());
|
||||||
|
|
||||||
ParsePrimitiveType
|
AABB aabb;
|
||||||
OBB obb;
|
// OBB obb;
|
||||||
rm_torus->component->GetWorldOBB(obb);
|
|
||||||
|
|
||||||
cci.mat=TranslateMatrix(obb.GetCenter()) *
|
for(int i=0;i<6;i++)
|
||||||
obb.GetRotationMatrix() *
|
{
|
||||||
ScaleMatrix(obb.GetHalfExtend()*2.0f); //*2.0f并不是因为OBB尺寸不对,是因为CUBE的原始尺寸就是1
|
PrimitiveComponent *component=rm_torus->component[i];
|
||||||
|
|
||||||
|
component->GetLocalAABB(aabb);
|
||||||
|
|
||||||
|
//Matrix4f translate_matrix=obb.GetRotationMatrix();
|
||||||
|
//Matrix4f rotate_matrix=obb.GetRotationMatrix();
|
||||||
|
//Matrix4f scale_matrix=ScaleMatrix(obb.GetHalfExtend()*2.0f);
|
||||||
|
|
||||||
|
Matrix3f rotate_scale_matrix=component->GetLocalToWorldMatrix();
|
||||||
|
|
||||||
|
rotate_scale_matrix[0]=glm::normalize(rotate_scale_matrix[0]);
|
||||||
|
rotate_scale_matrix[1]=glm::normalize(rotate_scale_matrix[1]);
|
||||||
|
rotate_scale_matrix[2]=glm::normalize(rotate_scale_matrix[2]);
|
||||||
|
|
||||||
|
Matrix4f rotate_matrix=rotate_scale_matrix;
|
||||||
|
|
||||||
|
Matrix4f translate_matrix=TranslateMatrix(aabb.GetCenter());
|
||||||
|
Matrix4f scale_matrix=ScaleMatrix(aabb.GetLength());
|
||||||
|
|
||||||
|
cci.mat=translate_matrix*rotate_matrix*scale_matrix;
|
||||||
|
|
||||||
CreateComponent<MeshComponent>(&cci,rm_box->cdp);
|
CreateComponent<MeshComponent>(&cci,rm_box->cdp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetCamera()
|
||||||
|
{
|
||||||
CameraControl *camera_control=GetCameraControl();
|
CameraControl *camera_control=GetCameraControl();
|
||||||
|
|
||||||
camera_control->SetPosition(Vector3f(8,8,8));
|
camera_control->SetPosition(Vector3f(8,8,8));
|
||||||
camera_control->SetTarget(Vector3f(0,0,0));
|
camera_control->SetTarget(Vector3f(0,0,0));
|
||||||
|
|
||||||
return(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -308,6 +333,8 @@ public:
|
|||||||
if(!InitBoundingBoxScene())
|
if(!InitBoundingBoxScene())
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
|
SetCamera();
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
};//class TestApp:public CameraAppFramework
|
};//class TestApp:public CameraAppFramework
|
||||||
|
Reference in New Issue
Block a user