verts[0].Set (0, 0, 0);
verts[1].Set (10.0, 0, 0);
verts[2].Set(0, 10.0, 0);
Those vertices are directly on the plane of the camera. That means you cannot
see it. Try putting the z component a bit in front of the camera (like 1 or 2).
Additionally you didn't set up a material for this mesh. That's needed.
Greetings,
On Mon, Jun 16, 2008 at 6:24 AM, Scott Johnson <[EMAIL PROTECTED]> wrote:
> Certainly. It follows.
>
> Thanks!
>
> ~Scott
>
> Apptri3d.h:
> -----------------------
> #ifndef _APP_TRI3DTEST_H_
> #define _APP_TRI3DTEST_H_
>
> #include <iostream>
> #include <string>
> #include "crystalspace.h"
> #include "csgeom/triangulate3d.h"
>
> class Tri3DTest : public csApplicationFramework, public csBaseEventHandler {
> private:
> iObjectRegistry* object_reg;
> csRef<iPluginManager> plugManager;
> csRef<iEngine> engine;
> csRef<iGraphics3D> g3d;
> csRef<iView> view;
> csRef<iLoader> loader;
> iSector* room;
> //csRef<iReporter> report;
> csRef<iRenderManager> rm;
>
> float rotX, rotY;
>
> public:
> Tri3DTest();
>
> // Crystal Space Functions
> bool OnInitialize(int argc, char* argv[]);
> bool Application();
> void Frame();
> bool SetupModules();
>
> CS_EVENTHANDLER_NAMES("application.tri3dtest")
> CS_EVENTHANDLER_NIL_CONSTRAINTS
> };
>
> #endif
>
>
> Apptri3d.cpp:
> -----------------------
>
> #include "tri3dtest.h"
> #include "csgeom/plane3.h"
>
> using namespace std;
> using CS::Geom::Triangulate3D;
> using CS::Geom::csContour3;
>
> CS_IMPLEMENT_APPLICATION
>
> Tri3DTest::Tri3DTest()
> {
> SetApplicationName("crystalspace.tri3dtest");
> }
>
> bool Tri3DTest::OnInitialize(int argc, char* argv[])
> {
> if (!csInitializer::RequestPlugins(GetObjectRegistry(),
> CS_REQUEST_VFS,
> CS_REQUEST_OPENGL3D,
> CS_REQUEST_ENGINE,
> CS_REQUEST_FONTSERVER,
> CS_REQUEST_IMAGELOADER,
> CS_REQUEST_LEVELLOADER,
> CS_REQUEST_REPORTER,
> CS_REQUEST_REPORTERLISTENER,
> CS_REQUEST_END))
> return ReportError("Failed to initialize plugins!");
>
> object_reg = GetObjectRegistry();
>
> csBaseEventHandler::Initialize(object_reg);
> if (!RegisterQueue(object_reg, csevAllEvents(GetObjectRegistry())))
> return ReportError("Failed to set up event handler!");
>
> plugManager = csQueryRegistry<iPluginManager> (object_reg);
>
> return true;
> }
>
> bool Tri3DTest::Application()
> {
> if (!OpenApplication(GetObjectRegistry()))
> return ReportError("Error: Unable to fetch Object Registry!");
>
> /* csPlane3 testing code
>
> csVector3 norm(1, 0, 0);
>
> csPlane3 myPlane(norm);
>
> csVector3 p (3, 4, 16);
> csVector3 newVector = myPlane.ProjectOnto(p);
>
> ReportWarning("Projected vector: (%f, %f, %f)", newVector.x,
> newVector.y, newVector.z);
>
> End of csPlane3 testing code */
>
> /* Old Testing Code -- Will be reinserted later */
> csContour3 polygon;
>
> csVector3 point1(1, 1, 1);
> csVector3 point2(1, 2, 1);
> csVector3 point3(1, 3, 1);
> csVector3 point4 (1, 4, 1);
>
> polygon.Insert(0, point1);
> polygon.Insert(1, point2);
> polygon.Insert(2, point3);
> polygon.Insert(3, point4);
>
> /*
> csVector3 point1(0, 10.0, 10.0);
> csVector3 point2(0, -10.0, 10.0);
> csVector3 point3(0.0, -10.0, -10.0);
> csVector3 point4(20.0, 5.0, -10.0);
> csVector3 point5(10.0, 0.0, -10.0);
> csVector3 point6(0, 10.0, -10.0);
>
> polygon.Insert(0, point1);
> polygon.Insert(1, point2);
> polygon.Insert(2, point3);
> polygon.Insert(3, point4);
> polygon.Insert(4, point5);
> polygon.Insert(5, point6);
> */
>
> csContour3 result_vertices;
> csTriangleMesh result;
>
> // set result to be some value, so that we can draw it
> result.AddVertex(csVector3(0.0, 0.0, 0.0));
> result.AddVertex(csVector3(5.0, 0.0, 0.0));
> result.AddVertex(csVector3(0.0, 5.0, 0.0));
>
> result.AddTriangle(0, 1, 2);
>
> //Triangulate3D::Process(polygon, result);
> /* End of Old testing code */
>
> /* Testing Code for new addition to csTriangleMesh: AddTriangleMesh()
>
> csTriangleMesh mesh1, mesh2;
> csVector3 *verts1, *verts2;
> csTriangle *tris1, *tris2;
>
> mesh1.AddVertex(csVector3(0.0, 0.0, 0.0));
> mesh1.AddVertex(csVector3(1.0, 1.0, 1.0));
> mesh1.AddVertex(csVector3(2.0, 2.0, 2.0));
> mesh1.AddTriangle(0, 1, 2);
>
> verts1 = mesh1.GetVertices();
> tris1 = mesh1.GetTriangles();
>
> mesh2.AddVertex(csVector3(11.0, 11.0, 11.0));
> mesh2.AddVertex(csVector3(15.0, 15.0, 15.0));
> mesh2.AddVertex(csVector3(20.0, 20.0, 20.0));
> mesh2.AddTriangle(0, 1, 2);
>
> verts2 = mesh2.GetVertices();
> tris2 = mesh2.GetTriangles();
>
> ReportWarning("Mesh 1 contains %d vertices. Mesh 2 contains %d
> vertices", mesh1.GetVertexCount(), mesh2.GetVertexCount());
> ReportWarning("Mesh 1 contains %d triangles. Mesh 2 contains %d
> triangles", mesh1.GetTriangleCount(), mesh2.GetTriangleCount());
>
> for (int i = 0; i < (int)mesh1.GetVertexCount(); i++)
> {
> ReportWarning("Mesh 1 vertex number %d: (%f, %f, %f)", i,
> verts1[i].x, verts1[i].y, verts1[i].z);
> }
>
> for (int i = 0; i < (int)mesh2.GetVertexCount(); i++)
> {
> ReportWarning("Mesh 2 vertex number %d: (%f, %f, %f)", i,
> verts2[i].x, verts2[i].y, verts2[i].z);
> }
>
> for (int i = 0; i < (int)mesh1.GetTriangleCount(); i++)
> {
> ReportWarning("Mesh 1 Triangle number %d connects vertices %d,
> %d, and %d", i, tris1[i].a, tris1[i].b, tris1[i].c);
> }
>
> for (int i = 0; i < (int)mesh2.GetTriangleCount(); i++)
> {
> ReportWarning("Mesh 2 Triangle number %d connects vertices %d,
> %d, and %d", i, tris2[i].a, tris2[i].b, tris2[i].c);
> }
>
> ReportWarning("Merging mesh 1 into mesh2...");
>
> mesh2.AddTriangleMesh(mesh1);
>
> for (int i = 0; i < (int)mesh2.GetVertexCount(); i++)
> {
> ReportWarning("Mesh 2 vertex number %d: (%f, %f, %f)", i,
> verts2[i].x, verts2[i].y, verts2[i].z);
> }
>
> for (int i = 0; i < (int)mesh2.GetTriangleCount(); i++)
> {
> ReportWarning("Mesh 2 Triangle number %d connects vertices %d,
> %d, and %d", i, tris2[i].a, tris2[i].b, tris2[i].c);
> }
> */
>
> //csTriangle tri = result.GetTriangle(0);
>
> //size_t numTris = result.GetTriangleCount();
>
> //ReportWarning("Number of Triangles: %d", numTris);
>
> if (SetupModules())
> {
> Run();
> }
>
> return true;
> }
>
> bool Tri3DTest::SetupModules()
> {
> // Now get the pointer to various modules we need. We fetch them
> // from the object registry. The RequestPlugins() call we did earlier
> // registered all loaded plugins with the object registry.
> g3d = csQueryRegistry<iGraphics3D> (GetObjectRegistry());
> if (!g3d) return ReportError("Failed to locate 3D renderer!");
>
> engine = csQueryRegistry<iEngine> (GetObjectRegistry());
> if (!engine) return ReportError("Failed to locate 3D engine!");
>
> //vc = csQueryRegistry<iVirtualClock> (GetObjectRegistry());
> //if (!vc) return ReportError("Failed to locate Virtual Clock!");
>
> //kbd = csQueryRegistry<iKeyboardDriver> (GetObjectRegistry());
> //if (!kbd) return ReportError("Failed to locate Keyboard Driver!");
>
> loader = csQueryRegistry<iLoader> (GetObjectRegistry());
> if (!loader) return ReportError("Failed to locate Loader!");
>
> // We need a View to the virtual world.
> view.AttachNew(new csView (engine, g3d));
> iGraphics2D* g2d = g3d->GetDriver2D ();
>
> // We use the full window to draw the world.
> view->SetRectangle (0, 0, g2d->GetWidth (), g2d->GetHeight ());
>
> // First disable the lighting cache. Our app is simple enough
> // not to need this.
> engine->SetLightingCacheMode (0);
>
> // Let the engine prepare all lightmaps for use and also free all images
> // that were loaded for the texture manager.
> engine->Prepare ();
>
> // these are used store the current orientation of the camera
> rotY = rotX = 0;
>
> // Now we need to position the camera in our world.
> view->GetCamera ()->GetTransform ().SetOrigin (csVector3 (0, 0, -10));
> view->GetCamera ()->GetTransform ().LookAt (csVector3(0, 0, 0),
> csVector3(0, 1, 0));
> }
>
> void Tri3DTest::Frame()
> {
> // we want to draw result
> csSimpleRenderMesh rendMesh;
> rendMesh.object2world.Identity();
>
> csVector3 verts[2];
> verts[0].Set (0, 0, 0);
> verts[1].Set (10.0, 0, 0);
> verts[2].Set(0, 10.0, 0);
>
> csVector4 cols[2];
> cols[0].Set(1.0, 0.0, 0.0, 1.0);
> cols[1].Set(1.0, 0.0, 0.0, 1.0);
> cols[2].Set(1.0, 0.0, 0.0, 1.0);
>
> rendMesh.vertices = verts; //result.GetVertices();
> rendMesh.vertexCount = 3; //result.GetVertexCount();
> rendMesh.colors = cols;
>
> rendMesh.meshtype = CS_MESHTYPE_TRIANGLES;
> csAlphaMode alf;
> alf.alphaType = alf.alphaSmooth;
> alf.autoAlphaMode = false;
> rendMesh.alphaType = alf;
>
> g3d->BeginDraw(engine->GetBeginDrawFlags() | CSDRAW_3DGRAPHICS);
> view->Draw();
> g3d->DrawSimpleMesh(rendMesh, 0);
> g3d->FinishDraw();
> }
>
> int main(int argc, char** argv)
> {
> return csApplicationRunner<Tri3DTest>::Run (argc, argv);
> }
>
>
> Jorrit Tyberghein wrote:
>> On Mon, Jun 16, 2008 at 4:55 AM, Scott Johnson <[EMAIL PROTECTED]> wrote:
>>
>>> Hmm.... for some odd reason, this still doesn't want to draw anything.
>>> Any other suggestions?
>>>
>>
>> Can you give the complete source code you have so far?
>>
>> Greetings,
>>
>>
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Crystal-main mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/crystal-main
> Unsubscribe: mailto:[EMAIL PROTECTED]
>
--
Project Manager of Crystal Space (http://www.crystalspace3d.org)
and CEL (http://cel.crystalspace3d.org)
Support Crystal Space. Donate at
https://sourceforge.net/donate/index.php?group_id=649
Visit my town at http://waldir.myminicity.com/
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]