Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
3DTools.h
1#if !defined(AFX_3DTOOLS_H__CA6BC29F_FAC2_11D1_A0DE_000000000000__INCLUDED_)
2#define AFX_3DTOOLS_H__CA6BC29F_FAC2_11D1_A0DE_000000000000__INCLUDED_
3
4BEGIN_MOOTOOLS_NAMESPACE
5
6#define SLICESCENE_VERTCOUNT_MODE 0
7#define SLICESCENE_VC_MODE 1
8
9#define SLICESCENE_MODE MAKE_CUSTOM_ID('M', 'O', 'D', 'E')
10#define SLICESCENE_X MAKE_CUSTOM_ID('X', ' ', ' ', ' ')
11#define SLICESCENE_Y MAKE_CUSTOM_ID('Y', ' ', ' ', ' ')
12#define SLICESCENE_Z MAKE_CUSTOM_ID('Z', ' ', ' ', ' ')
13#define SLICESCENE_MAX_VERTS MAKE_CUSTOM_ID('V' ,'E', 'R', 'T')
14
15// Usefuls
16// Return a C3DObject providing a list of triangles and quadrangles
17DLL_3DFUNCTION C3DObject *CreateObjectFromArrays(const float *coords, unsigned int coordsSizeOf, const int *triangles, unsigned int trianglesSizeOf, const int *quadrangles, unsigned int quadranglesSizeOf);
18
19// GetOneUVPerVertex (was called GetUVVertexFromUVFace before)
20// Return an int* array that contain the matching UV in the CUVWPointList a given vertex index. The array must be deallocated using xDeallocateArray once used.
21// Size is 0, or equal to C3DPointList size.
22//
23// This helper function is useful when the objet have no UV seams (meaning that there is one and only one UV per point).
24// This can be achieved during an import/export using SCENE_....._DISCONNECT_FACES or calling directly bool C3DGeomObject::DisconnectBorderFaces
25// For particular mesh, some UV might be missing for a given point. In that case, UV index return in the array is set to -1 and it's important to check that value and use a default UV value of your choice in that case.
26// Using that function you can export easily points with corresponding UV like this:
27//
28// C3DGeomObject* object = node->GetGeomObject();
29// CDependentChannels* channels = object->GetChannels();
30// C3DPointList* points = object->GetPointList();
31// CUVWPointList* uvpts = NULL;
32// CUVWFaceList* uvfaces = NULL;
33//
34// object->DisconnectBorderFaces(); // Remove any seams from the object by duplicating points
35// ChannelID globalChannelID = object->GlobalizeChannels(scene, true);
36// channels->GetUVWChannelByID(globalChannelID, uvfaces, uvpts);
37//
38// int i, size;
39// int* uvindex = GetOneUVPerVertex(object, globalChannelID, size); // Require
40//
41// XASSERT(points->GetSize() == size || !size);
42//
43// float u, v;
44// C3DPoint* point;
45// CUVWPoint* uvwpoint;
46// size = points->GetSize();
47// for (i = 0; i < size; i++)
48// {
49// point = (*points)[i];
50//
51// // Get matching UV
52// if (uvindex && uvindex[i] != -1)
53// {
54// uvwpoint = ((*uvpts)[uvindex[i]]);
55// u = uvwpoint->u;
56// v = uvwpoint->v;
57// }
58// else
59// {
60// XTRACE("undefined UV\n");
61//
62// u = 0;
63// v = 0;
64// }
65//
66// // Do what you want with UV
67// }
68//
69// xDeallocateArray((uvindex);
70DLL_3DFUNCTION int *GetOneUVPerVertex(C3DGeomObject *object, ChannelID id, int& size);
71
72// Create different geometry entities
73DLL_3DFUNCTION C3DSceneNode *CreateCapsule(const C3DPoint& center, float radius, float length, unsigned int sides, unsigned int sphereSegments, unsigned int tubeDivisions, AXIS_INFO axis, BOOL createUV = true, MaterialID matid = DEFAULT_MATERIAL_ID, ChannelID chnid = CHANNELID_UNDEFINED);
74DLL_3DFUNCTION C3DSceneNode *CreateSphere(const C3DPoint& center, double mRadius, const int mRings = 16, const int mSegments = 16, bool createUV = true, MaterialID matid = DEFAULT_MATERIAL_ID, ChannelID chnid = CHANNELID_UNDEFINED);
75DLL_3DFUNCTION C3DSceneNode *CreateCube(const C3DPoint& center, double xLength = 1.0f, double yLength = 1.0f, double zLength = 1.0f, bool createUV = true, MaterialID matid = DEFAULT_MATERIAL_ID, ChannelID chnid = CHANNELID_UNDEFINED);
76DLL_3DFUNCTION C3DSceneNode *CreateCone(const C3DPoint& center, double radius = 1.f, double height = 1.f, unsigned int numSegBase = 16, unsigned int numSegHeight = 1, bool createUV = true, MaterialID matid = DEFAULT_MATERIAL_ID, ChannelID chnid = CHANNELID_UNDEFINED);
77DLL_3DFUNCTION C3DSceneNode *CreateCylinder(const C3DPoint& center, double radius = 1.f, double height = 1.f, UP_AXIS_MODE axyz = UP_AXIS_Z, unsigned int numSegBase = 16, unsigned int numSegHeight = 8, bool capped = true, bool createUV = true, MaterialID matid = DEFAULT_MATERIAL_ID, ChannelID chnid = CHANNELID_UNDEFINED);
78DLL_3DFUNCTION C3DSceneNode* CreatePlane(const C3DPoint& center, const C3DVector& mNormal, double mSizeX, double mSizeY, unsigned int numSegX = 16, unsigned int numSegY = 16, bool createUV = true, MaterialID matid = DEFAULT_MATERIAL_ID, ChannelID chnid = CHANNELID_UNDEFINED);
79
80// Divide the whole scene geometry by a grid. The geometry of the mesh is put into cells of the grid (when using SLICESCENE_VERTCOUNT_MODE) or a vertex color channel is assigned and a given color is given to each point depending on the cell in which the point is located (SLICESCENE_VC_MODE)
81// Grid size is defined by SLICESCENE_X, SLICESCENE_Y, SLICESCENE_Z and a max number of point for a cell can be defined (SLICESCENE_MAX_VERTS).
82DLL_3DFUNCTION bool SliceScene(const CCustomData& settings, C3DScene *scene);
83
84END_MOOTOOLS_NAMESPACE
85
86#endif // !defined(AFX_3DTOOLS_H__CA6BC29F_FAC2_11D1_A0DE_000000000000__INCLUDED_)
AXIS_INFO
Definition 3DType.h:320
UP_AXIS_MODE
Definition 3DType.h:360
@ UP_AXIS_Z
Our default mode, nothing done.
Definition 3DType.h:362
This is the base class for any object containing geometry (curve, polygonal object,...
Definition 3DGeomObject.h:49
C3DObject handles polygonal mesh.
Definition 3DObject.h:24
The class allows to get access to the scene graph, node hierarchy, material.
Definition 3DScene.h:306
A node matches one element that is part of the C3DScene graph. It references a C3DBaseObject and has ...
Definition 3DSceneNode.h:64
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
CCustomData is a handly class for storing any kind of data.
Definition CustomData.h:106