Add to Favorites    Make Home Page 1766 Online  
 Language Categories  
 Our Services  

Home » C++ Home » Computer Graphics Home » Moving 3D Box in free space.

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Moving 3D Box in free space.
Author Sharif Shah Newaj Bhuiyan
Author Email srabbis [at] hotmail.com
Description Its a Cool 3D programming as far i know. Just Use
mathmatical logic (Graph logic). Here i made a little animation like moving a 3D box around free space/place without any difficulty in C++.
Category C++ » Computer Graphics
Hits 395747
Code Select and Copy the Code
#include <stdio.h> #include <dos.h> #include <graphics.h> #include <conio.h> #define MAGFY 20 class Bline { private: int CEN_X,CEN_Y,radius,X,Y,i,j; public: void line1(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4); }; void Bline::line1(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4) { CEN_X = (x1+x2)/2 + (x3-x2)/2; CEN_Y = (y1+y2)/2 + (y3-y2)/2; //radius = (x1+x2)/2; for(;!kbhit();) { delay(300); cleardevice(); //1st box line(x1,y1,x2,y2); line(x1,y1-20,x2,y2-20); // line(x3,y3,x4,y4); line(x3,y3-20,x4,y4-20); // line(x1,y1,x4,y4); line(x1,y1-20,x4,y4-20); // line(x2,y2,x3,y3); line(x2,y2-20,x3,y3-20); // //2nd box line(x1,y1,x1,y1-20); line(x2,y2,x2,y2-20); line(x3,y3,x3,y3-20); line(x4,y4,x4,y4-20); //some point which will be moving around 3Dbox //line(x2+40,y2-20,x2+40,y2-20); //rectangle(x2,y2,x4,y4); //1st Quadrant if(x1>CEN_X && y1<CEN_Y) x1--,y1--; if(x1==CEN_X && y1<CEN_Y) x1--,y1++; if(x1<CEN_X && y1<CEN_Y) x1--,y1++; if(x1<CEN_X && y1==CEN_Y) x1++,y1++; if(x1<CEN_X && y1>CEN_Y) x1++,y1++; if(x1==CEN_X && y1>CEN_Y) x1++,y1--; if(x1>CEN_X && y1>CEN_Y) x1++,y1--; if(x1>CEN_X && y1==CEN_Y) x1--,y1--; //2nd Quadrant if(x2>CEN_X && y2<CEN_Y) x2--,y2--; if(x2==CEN_X && y2<CEN_Y) x2--,y2++; if(x2<CEN_X && y2<CEN_Y) x2--,y2++; if(x2<CEN_X && y2==CEN_Y) x2++,y2++; if(x2<CEN_X && y2>CEN_Y) x2++,y2++; if(x2==CEN_X && y2>CEN_Y) x2++,y2--; if(x2>CEN_X && y2>CEN_Y) x2++,y2--; if(x2>CEN_X && y2==CEN_Y) x2--,y2--; //3rd Quadrant if(x3>CEN_X && y3<CEN_Y) x3--,y3--; if(x3==CEN_X && y3<CEN_Y) x3--,y3++; if(x3<CEN_X && y3<CEN_Y) x3--,y3++; if(x3<CEN_X && y3==CEN_Y) x3++,y3++; if(x3<CEN_X && y3>CEN_Y) x3++,y3++; if(x3==CEN_X && y3>CEN_Y) x3++,y3--; if(x3>CEN_X && y3>CEN_Y) x3++,y3--; if(x3>CEN_X && y3==CEN_Y) x3--,y3--; //4th Quadrant if(x4>CEN_X && y4<CEN_Y) x4--,y4--; if(x4==CEN_X && y4<CEN_Y) x4--,y4++; if(x4<CEN_X && y4<CEN_Y) x4--,y4++; if(x4<CEN_X && y4==CEN_Y) x4++,y4++; if(x4<CEN_X && y4>CEN_Y) x4++,y4++; if(x4==CEN_X && y4>CEN_Y) x4++,y4--; if(x4>CEN_X && y4>CEN_Y) x4++,y4--; if(x4>CEN_X && y4==CEN_Y) x4--,y4--; } } int main() { int GD=DETECT,GM; Bline line1; initgraph(&GD,&GM,"c:\tc\bgi"); //according to your own computer (TC\BIN) Directory line1.line1(5*MAGFY,7*MAGFY,1*MAGFY,3*MAGFY,3*MAGFY,1*MAGFY,7*MAGFY,5*MAGFY); getch(); restorecrtmode(); closegraph(); return 0; }

Related Source Codes

Script Name Author
Moving ball screen saver karlmarx
The Classic Game of Snake & Ladder Lakshmi Narayana .A
Railway seat reservation question which comes in sapient VyomWorld
To calculate percentile Ravi Mathur
Send to folder ANIMESH SAHU
Analog clock and calendar Nazia & Rida
HIGH/LOW GAME MOLLY ARORA
Data structure (stack Implimentation) Swapnil B Adsure
Memory Game AnirudhSanyal
Easy Calc Anirudh Sanyal
GK Quiz Anirudh Sanyal
Hangman Game Manish Jain
Snakeman Manish Jain
Full month Calendar Nigi
Cursor shapes nigi

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=813


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review