Crystal Space
Welcome, Guest. Please login or register.
August 20, 2014, 07:54:26 am

Login with username, password and session length
Search:     Advanced search
9008 Posts in 2046 Topics by 8328 Members
Latest Member: Billyrasheed
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Opengl in crystal space
« previous next »
Pages: [1] Print
Author Topic: Opengl in crystal space  (Read 2909 times)
raq77
Newbie
*
Posts: 41


View Profile Email
« on: November 16, 2007, 06:20:46 pm »

     Hello I have created a geometry in crystal space and now I want to draw a glpoint inside this geometry by I don't know how to do it. My geometry is:
void Entorno::CreaGeometria ()
{
  foc->GetEngine ()->SetLightingCacheMode (0);
  if (!foc->GetLoader()->LoadTexture ("sky", "/lib/escenario/noche4.jpg"))
   foc->ReportError("Error loading 'sky' texture!");
  iMaterialWrapper* tm = foc->GetEngine()->GetMaterialList ()->FindByName ("sky");
  room = foc->GetEngine()->CreateSector ("room");
  csRef<iMeshWrapper> walls (foc->GetEngine()->CreateSectorWallsMesh (room, "walls"));
  iMeshObject* walls_object = walls->GetMeshObject ();
  iMeshObjectFactory* walls_factory = walls_object->GetFactory();
  csRef<iThingFactoryState> walls_state = scfQueryInterface<iThingFactoryState> (walls_factory);
  walls_state->AddInsideBox (csVector3 (-40, -40, -40), csVector3 (40, 40, 40));
  walls_state->SetPolygonMaterial (CS_POLYRANGE_LAST, tm);
  walls_state->SetPolygonTextureMapping (CS_POLYRANGE_LAST, 40);
 
  iGraphics2D* g2d = foc->GetGraphics3D()->GetDriver2D ();
  foc->GetView()->SetRectangle (0, 0, g2d->GetWidth (), g2d->GetHeight ());
  foc->GetView()->GetCamera()->SetSector(room);
  foc->GetView()->GetCamera ()->GetTransform ().SetOrigin (csVector3 (0, -6, -35));
 
  iTextureWrapper* txt = foc->GetLoader()->LoadTexture ("spark", "/lib/std/explo.png");
  if (txt == 0)
  {
     csReport (foc->GetObjectRegistry(), CS_REPORTER_SEVERITY_ERROR,
      "crystalspace.application.phystut", "Error loading texture!");
  }
}

Can anyone help me? Thanks in advance.
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #1 on: November 16, 2007, 07:32:10 pm »

You can use g2d->DrawPixel() to draw pixels.

Greetings,
Logged
raq77
Newbie
*
Posts: 41


View Profile Email
« Reply #2 on: November 17, 2007, 05:39:16 pm »

    Thanks, but this doesn't help me. I need to draw particles (points) and these will change position in each frame simulating fireworks. I have tried to create a system of particles and use LockForExternalControl, but when I run it my PC restarts.

void Sistema::StartExplosion (iSector* sector, Particula *part) {
  csRef<iMeshWrapper> sys = foc->GetEngine ()->CreateMeshWrapper (system_factory, "system", sector, part->pos);
  if (!sys)
  {
       foc->ReportError ("Error creating particles system mesh!");
       return;
  }
  csRef<iParticleSystem> particulas = scfQueryInterface<iParticleSystem> (sys->GetMeshObject());
  particulas->SetParticleSize (csVector2 (0.08f, 0.08f));
  csParticleBuffer *partbuffer = particulas->LockForExternalControl(5);
  partbuffer->particleCount = 50;
  partbuffer->particleData[0].position = part->pos;
  partbuffer->particleAuxData[0].color = part->color;
}

      Thanks
« Last Edit: November 17, 2007, 07:08:23 pm by raq77 » Logged
res
Develazyoper
CS Developer
Full Member
*****
Posts: 206


View Profile Email
« Reply #3 on: November 18, 2007, 04:05:15 am »

    Thanks, but this doesn't help me. I need to draw particles (points) and these will change position in each frame simulating fireworks. I have tried to create a system of particles and use LockForExternalControl, but when I run it my PC restarts.

You're not using it correctly.
Logged
raq77
Newbie
*
Posts: 41


View Profile Email
« Reply #4 on: November 18, 2007, 07:29:04 pm »

Ok, Can anyone tell me as I do? Can someone show me an example? I have read the manual but obviously this has not been enough. Also I tried to do:
void Sistema::StartExplosion (iSector* sector, Particula *part)
{
  csPrintf("StartExplosion\n");
  csRef<iMeshWrapper> sys = foc->GetEngine ()->CreateMeshWrapper (system_factory, "system", sector, part->pos);
  if (!sys)
  {
   foc->ReportError ("Error creating particles system mesh!");
    return;
  }
  csRef<iParticleSystem> particulas = scfQueryInterface<iParticleSystem> (sys->GetMeshObject());
  csParticleBuffer *partbuffer = particulas->LockForExternalControl(50);
  partbuffer->particleCount = 50;
  for (size_t i = 0; i < 50; i++)
  {
   partbuffer->particleData[0].position = part->pos;
   partbuffer->particleAuxData[0].color = part->color;
  }
}

But this also restart my PC. Thanks un advance. 
« Last Edit: November 18, 2007, 07:43:33 pm by raq77 » Logged
res
Develazyoper
CS Developer
Full Member
*****
Posts: 206


View Profile Email
« Reply #5 on: November 19, 2007, 12:54:55 am »

You've fixed the maximum particle count, and you intend to actually initialize all particles ... however, you don't. Perhaps it's the garbage data that causes problems with your graphics driver. (My guess since it's one of the few software components seeing the data actually able to cause a reset. FWIW, a rather shitty driver, in my opinion.)
Logged
raq77
Newbie
*
Posts: 41


View Profile Email
« Reply #6 on: November 19, 2007, 03:49:00 pm »

 Ok, I understand that I am doing it wrong, but I don't know how to do really. If I could see an example perhaps I'd understand this. Anyway, I'd like to know how I can draw a three-dimensional pixel inside the room without using particle systems.

    Thanks. Raquel
Logged
raq77
Newbie
*
Posts: 41


View Profile Email
« Reply #7 on: November 20, 2007, 08:56:30 pm »

Nobody can help me? Nobody has had the same problem? Anything would help me. Thanks
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 7.188 seconds with 15 queries.