DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
#include
#include
#include
#include
#include
#include "NXU_Geometry.h" #include "NxMat34.h" #include "NXU_hull.h" namespace NXU { static void set(float *p, int index, float x, float y, float z,const NxMat34 *localPose) { NxVec3 v(x,y,z); if ( localPose ) { NxVec3 t; localPose->multiply(v,t); v = t; } p = &p[index *3]; p[0] = v.x; p[1] = v.y; p[2] = v.z; } static unsigned int *addTri(unsigned int i1, unsigned int i2, unsigned int i3, unsigned int *idx) { idx[0] = i1; idx[1] = i2; idx[2] = i3; idx += 3; return idx; } bool createBox(NxVec3 &dimensions,NxuGeometry &g,const NxMat34 *localPose, float shrink,unsigned int maxV) { g.reset(); g.mVertices = new float[8 *3]; g.mVcount = 8; g.mTcount = 12; g.mIndices = new unsigned int[12 *3]; float bmin[3]; float bmax[3]; bmin[0] = -dimensions.x*shrink; bmin[1] = -dimensions.y*shrink; bmin[2] = -dimensions.z*shrink; bmax[0] = dimensions.x*shrink; bmax[1] = dimensions.y*shrink; bmax[2] = dimensions.z*shrink; set(g.mVertices, 0, bmin[0], bmin[1], bmin[2], localPose); set(g.mVertices, 1, bmax[0], bmin[1], bmin[2], localPose); set(g.mVertices, 2, bmax[0], bmax[1], bmin[2], localPose); set(g.mVertices, 3, bmin[0], bmax[1], bmin[2], localPose); set(g.mVertices, 4, bmin[0], bmin[1], bmax[2], localPose); set(g.mVertices, 5, bmax[0], bmin[1], bmax[2], localPose); set(g.mVertices, 6, bmax[0], bmax[1], bmax[2], localPose); set(g.mVertices, 7, bmin[0], bmax[1], bmax[2], localPose); unsigned int *indices = g.mIndices; indices = addTri(0, 3, 2, indices); indices = addTri(0, 2, 1, indices); indices = addTri(2, 6, 5, indices); indices = addTri(1, 2, 5, indices); indices = addTri(6, 7, 4, indices); indices = addTri(5, 6, 4, indices); indices = addTri(4, 7, 3, indices); indices = addTri(4, 3, 0, indices); indices = addTri(5, 4, 0, indices); indices = addTri(5, 0, 1, indices); indices = addTri(3, 7, 6, indices); indices = addTri(2, 3, 6, indices); return true; } static float *createSphere(float r, int stepsize, unsigned int &vcount) { float a = 0; float astep = (3.141592654f *2.0f) / (float)stepsize; vcount = stepsize * stepsize; float *points = new float[stepsize *stepsize * 3]; for (int i = 0; i < stepsize; i++) { float b = 0; float bstep = (3.141592654f *2.0f) / stepsize; for (int j = 0; j < stepsize; j++) { float p[3]; p[0] = r * sinf(a) *cosf(b); p[1] = r * sinf(a) *sinf(b); p[2] = r * cosf(a); int index = (i *stepsize) + j; points[index *3+0] = p[0]; points[index *3+1] = p[1]; points[index *3+2] = p[2]; b += bstep; } a += astep; } return points; } bool createSphere(float r,NxuGeometry &g,const NxMat34 *localPose,int stepsize,NxReal shrink,unsigned int maxV) { unsigned int vcount; float *points = createSphere(r, stepsize, vcount); bool ret = createHull(vcount, points, g,localPose, shrink, maxV); delete points; return ret; } static void SwapYZ(float *p) { float t = p[1]; p[1] = p[2]; p[2] = t; } static void SwapXZ(float *p) { float t = p[0]; p[0] = p[2]; p[2] = t; } bool createCapsule(float radius, float height, NxuGeometry &g,const NxMat34 *localPose,int axis, int stepsize, NxReal shrink,unsigned int maxV) { unsigned int vcount; float *points = createSphere(radius, stepsize, vcount); float spread = height * 0.5f; for (unsigned int i = 0; i < vcount; i++) { float *p = &points[i *3]; if (p[2] < 0) { p[2] -= spread; } else { p[2] += spread; } if (axis == 1) { SwapYZ(p); } else if (axis == 0) { SwapXZ(p); } } bool ret = createHull(vcount, points, g,localPose, shrink, maxV); delete points; return ret; } static void computeAABB(unsigned int vcount,const float *points,unsigned int pstride,float *bmin,float *bmax) { const unsigned char *source = (const unsigned char *) points; bmin[0] = points[0]; bmin[1] = points[1]; bmin[2] = points[2]; bmax[0] = points[0]; bmax[1] = points[1]; bmax[2] = points[2]; for (unsigned int i=1; i
bmax[0] ) bmax[0] = p[0]; if ( p[1] > bmax[1] ) bmax[1] = p[1]; if ( p[2] > bmax[2] ) bmax[2] = p[2]; } } bool createHull(unsigned int vcount, const float *points,NxuGeometry &g,const NxMat34 *localPose,NxReal shrink,unsigned int maxv) { bool ret = false; g.reset(); HullLibrary hl; HullDesc desc(QF_TRIANGLES, vcount, points, sizeof(float) *3); desc.mMaxVertices = maxv; HullResult result; HullError err = hl.CreateConvexHull(desc, result); if (err == QE_OK) { ret = true; g.mVertices = new float[result.mNumOutputVertices *3]; float bmin[3]; float bmax[3]; computeAABB( result.mNumOutputVertices, result.mOutputVertices, sizeof(float)*3, bmin, bmax ); NxVec3 center; center.x = (bmax[0]-bmin[0])*0.5f + bmin[0]; center.y = (bmax[1]-bmin[1])*0.5f + bmin[1]; center.z = (bmax[2]-bmin[2])*0.5f + bmin[2]; const float *source = result.mOutputVertices; float *dest = g.mVertices; for (NxU32 i=0; i
multiply(v,t); v = t; } dest[0] = v.x; dest[1] = v.y; dest[2] = v.z; source+=3; dest+=3; } g.mIndices = new unsigned int[result.mNumIndices]; memcpy(g.mIndices, result.mIndices, sizeof(unsigned int) *result.mNumIndices); g.mVcount = result.mNumOutputVertices; g.mTcount = result.mNumFaces; hl.ReleaseResult(result); } return ret; } };
NXU_Geometry.cpp
Page URL
File URL
Prev
7/21
Next
Download
( 5 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.