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
/* ----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ Copyright (c) 2000-2006 Torus Knot Software Ltd Also see acknowledgements in Readme.html You may use this sample code for anything you like, it is not covered by the LGPL like the rest of the engine. ----------------------------------------------------------------------------- */ /** \file Bezier.h \brief Specialisation of OGRE's framework application to show off the bezier patch support. */ #include "ExampleApplication.h" // Hack struct for test PatchMeshPtr patch; Pass* patchPass; // Event handler to add ability to alter subdivision class BezierListener : public ExampleFrameListener { protected: public: BezierListener(RenderWindow* win, Camera* cam) : ExampleFrameListener(win, cam) { } bool frameStarted(const FrameEvent& evt) { if( ExampleFrameListener::frameStarted(evt) == false ) return false; static Real timeLapse = 0.0f; static Real factor = 0.0; static bool wireframe = 0; timeLapse += evt.timeSinceLastFrame; // Prgressively grow the patch if (timeLapse > 1.0f) { factor += 0.2; if (factor > 1.0f) { wireframe = !wireframe; //mCamera->setPolygonMode(wireframe ? PM_WIREFRAME : PM_SOLID); patchPass->setPolygonMode(wireframe ? PM_WIREFRAME : PM_SOLID); factor = 0.0f; } patch->setSubdivision(factor); mDebugText = "Bezier subdivision factor: " + StringConverter::toString(factor); timeLapse = 0.0f; } // Call default return true; } }; class BezierApplication : public ExampleApplication { protected: VertexDeclaration* patchDecl; float* patchCtlPoints; public: BezierApplication() : patchDecl(NULL), patchCtlPoints(NULL) { } ~BezierApplication() { if (patchCtlPoints) delete [] patchCtlPoints; // patch vertex declaration will be deleted automatically } protected: #if OGRE_COMPILER == OGRE_COMPILER_MSVC #pragma pack(push) #pragma pack(1) #endif struct PatchVertex { float x, y, z; float nx, ny, nz; float u, v; }; #if OGRE_COMPILER == OGRE_COMPILER_MSVC #pragma pack(pop) #endif // Just override the mandatory create scene method void createScene(void) { // Set ambient light mSceneMgr->setAmbientLight(ColourValue(0.2, 0.2, 0.2)); // Create a point light Light* l = mSceneMgr->createLight("MainLight"); // Accept default settings: point light, white diffuse, just set position // NB I could attach the light to a SceneNode if I wanted it to move automatically with // other objects, but I don't l->setType(Light::LT_DIRECTIONAL); l->setDirection(-0.5, -0.5, 0); // Create patch patchDecl = HardwareBufferManager::getSingleton().createVertexDeclaration(); patchDecl->addElement(0, 0, VET_FLOAT3, VES_POSITION); patchDecl->addElement(0, sizeof(float)*3, VET_FLOAT3, VES_NORMAL); patchDecl->addElement(0, sizeof(float)*6, VET_FLOAT2, VES_TEXTURE_COORDINATES, 0); // Make a 3x3 patch for test patchCtlPoints = (float*)( new PatchVertex[9] ); // Patch data PatchVertex *pVert = (PatchVertex*)patchCtlPoints; pVert->x = -500.0; pVert->y = 200.0; pVert->z = -500.0; pVert->nx = -0.5; pVert->ny = 0.5; pVert->nz = 0.0; pVert->u = 0.0; pVert->v = 0.0; pVert++; pVert->x = 0.0; pVert->y = 500.0; pVert->z = -750.0; pVert->nx = 0.0; pVert->ny = 0.5; pVert->nz = 0.0; pVert->u = 0.5; pVert->v = 0.0; pVert++; pVert->x = 500.0; pVert->y = 1000.0; pVert->z = -500.0; pVert->nx = 0.5; pVert->ny = 0.5; pVert->nz = 0.0; pVert->u = 1.0; pVert->v = 0.0; pVert++; pVert->x = -500.0; pVert->y = 0.0; pVert->z = 0.0; pVert->nx = -0.5; pVert->ny = 0.5; pVert->nz = 0.0; pVert->u = 0.0; pVert->v = 0.5; pVert++; pVert->x = 0.0; pVert->y = 500.0; pVert->z = 0.0; pVert->nx = 0.0; pVert->ny = 0.5; pVert->nz = 0.0; pVert->u = 0.5; pVert->v = 0.5; pVert++; pVert->x = 500.0; pVert->y = -50.0; pVert->z = 0.0; pVert->nx = 0.5; pVert->ny = 0.5; pVert->nz = 0.0; pVert->u = 1.0; pVert->v = 0.5; pVert++; pVert->x = -500.0; pVert->y = 0.0; pVert->z = 500.0; pVert->nx = -0.5; pVert->ny = 0.5; pVert->nz = 0.0; pVert->u = 0.0; pVert->v = 1.0; pVert++; pVert->x = 0.0; pVert->y = 500.0; pVert->z = 500.0; pVert->nx = 0.0; pVert->ny = 0.5; pVert->nz = 0.0; pVert->u = 0.5; pVert->v = 1.0; pVert++; pVert->x = 500.0; pVert->y = 200.0; pVert->z = 800.0; pVert->nx = 0.5; pVert->ny = 0.5; pVert->nz = 0.0; pVert->u = 1.0; pVert->v = 1.0; pVert++; patch = MeshManager::getSingleton().createBezierPatch( "Bezier1", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, patchCtlPoints, patchDecl, 3, 3, 5, 5, PatchSurface::VS_BOTH); // Start patch at 0 detail patch->setSubdivision(0.0f); // Create entity based on patch Entity* patchEntity = mSceneMgr->createEntity("Entity1", "Bezier1"); MaterialPtr pMat = MaterialManager::getSingleton().create("TextMat", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); pMat->getTechnique(0)->getPass(0)->createTextureUnitState( "BumpyMetal.jpg" ); patchEntity->setMaterialName("TextMat"); patchPass = pMat->getTechnique(0)->getPass(0); // Attach the entity to the root of the scene mSceneMgr->getRootSceneNode()->attachObject(patchEntity); mCamera->setPosition(500,500, 1500); mCamera->lookAt(0,200,-300); } void destroyScene(void) { // free up the pointer before we shut down OGRE patch.setNull(); } void createFrameListener(void) { // This is where we instantiate our own frame listener mFrameListener= new BezierListener(mWindow, mCamera); mRoot->addFrameListener(mFrameListener); } };
Bezier.h
Page URL
File URL
Prev 1/35
Next
Download
( 6 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.