OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: Create Tetrahedron with MOGRE
View page
Source of version: 20
(current)
{DIV(align="right",float="right")}||{img src="img/wiki_up/Tetrahedron-turning-120px.gif" alt="Tetrahedron-turning-120px.gif"} {img src="img/wiki_up/Tetrahedron.jpg" alt="" align="right"}||{DIV} This is a method to create a tetrahedron as ((ManualObject)). For Ogre users it should be easy to port. If somebody do so, please publish the code (or send it to user ((User:Beauty|Beauty))). It's going easy on resources (just 4 ((-vertex|vertices)) and 4 triangles) and usefull if you need many objects in your scene. For example to add marks at different positions where an airplane was flying along. If there are problems with the code ask user ((User:Beauty|Beauty)). Alternatively you can use ((-Particle))s. They can have nice visual effects and needs low performance (depends to its complexity). !!!CreateTetrahedron() {CODE(wrap="1", colors="c#")}/// <summary> /// Create a tetrahedron with point of origin in middle of volume. /// It will be added to the SceneManager as ManualObject. The material must still exists. /// </summary> /// <param name="position">Position in scene</param> /// <param name="scale">Size of the tetrahedron</param> /// <param name="name">Name of the ManualObject that will be created</param> /// <param name="materialName">Name of the used material</param> /// void CreateTetrahedron(String name, Vector3 position, Single scale, String materialName) { ManualObject manObTetra = new ManualObject(name); manObTetra.CastShadows = false; // render just before overlays (so all objects behind the transparent tetrahedron are visible) manObTetra.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY - 1; // = 99 Vector3[] c = new Vector3[4]; // corners // calculate corners of tetrahedron (with point of origin in middle of volume) Single mbot = scale * 0.2f; // distance middle to bottom Single mtop = scale * 0.62f; // distance middle to top Single mf = scale * 0.289f; // distance middle to front Single mb = scale * 0.577f; // distance middle to back Single mlr = scale * 0.5f; // distance middle to left right // width / height / depth c[0] = new Vector3(-mlr, -mbot, mf); // left bottom front c[1] = new Vector3( mlr, -mbot, mf); // right bottom front c[2] = new Vector3( 0, -mbot, -mb); // (middle) bottom back c[3] = new Vector3( 0, mtop, 0); // (middle) top (middle) // add position offset for all corners (move tetrahedron) for (Int16 i = 0; i <= 3; i++) c[i] += position; // create bottom manObTetra.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST); manObTetra.Position(c[2]); manObTetra.Position(c[1]); manObTetra.Position(c[0]); manObTetra.Triangle(0, 1, 2); manObTetra.End(); // create right back side manObTetra.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST); manObTetra.Position(c[1]); manObTetra.Position(c[2]); manObTetra.Position(c[3]); manObTetra.Triangle(0, 1, 2); manObTetra.End(); // create left back side manObTetra.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST); manObTetra.Position(c[3]); manObTetra.Position(c[2]); manObTetra.Position(c[0]); manObTetra.Triangle(0, 1, 2); manObTetra.End(); // create front side manObTetra.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST); manObTetra.Position(c[0]); manObTetra.Position(c[1]); manObTetra.Position(c[3]); manObTetra.Triangle(0, 1, 2); manObTetra.End(); } // CreateTetrahedron{CODE} %%% !Usage example {CODE(wrap="1", colors="c#")}// a material with the name materialName must be created or loaded! Vector3 position = new Vector3(1, 1, -1); Single size = 1; String tetraName = "tetra"; // create manual object CreateTetrahedron(tetraName, position, size, materialName); // attach to scene mScene.Smgr.RootSceneNode.AttachObject(mScene.Smgr.GetManualObject(tetraName));{CODE} {CODE(wrap="1", colors="c#")}// remove tetrahedrons if (mScene.Smgr.HasManualObject(tetraName)) mScene.Smgr.GetManualObject(tetraName).Clear();{CODE} %%% !See also * ((MOGRE Line 3D)) - includes some code how to __create a material__ on the fly * ((ManualObject)) * [http://www.ogre3d.org/docs/api/html/classOgre_1_1ManualObject.html#ManualObject|ManualObject API] - class reference with description * ((Manual Object|CodeSnippets for ManualObject)) * ((-Material|Material)) * ((-Particle|Particle)) * ((Ogre Procedural Geometry Library)) - A library to quickly create geometric primitives * ((GeometricMesh)) - Creating various geometric/geodesic shapes * ((Debug Drawing Utility Class)) ** [http://www.ogre3d.org/addonforums/viewtopic.php?f=8&t=14554|Mogre port] of Debug Drawing Utility Class
Search by Tags
Search Wiki by Freetags
Latest Changes
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
Critter AI
Mogre Add-ons
MOGRE
Mogre MyGUI wrapper
MOGRE Editable Terrain Manager
...more
Search
Find
Advanced
Search Help
Online Users
14 online users